Skip to content

Added Maya file reference test. #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ set(INTERACTIVE_TEST_SCRIPT_FILES
testSceneModified.py
testStageInstanceablePrimsSelHighlight.py|skipOnPlatform:osx # HYDRA-1315 : Wire not showing on OSX
testIsolateSelectWithGeomSubset.py
testMayaReference.py
cpp/testColorPreferences.py
cpp/testCppFramework.py
cpp/testDataProducerExample.py
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions test/lib/mayaUsd/render/mayaToHydra/testMayaReference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright 2025 Autodesk
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import maya.cmds as cmds
import fixturesUtils
import mtohUtils
import testUtils

class TestMayaReference(mtohUtils.MayaHydraBaseTestCase):
# MayaHydraBaseTestCase.setUpClass requirement.
_file = __file__

_requiredPlugins = ['mayaHydraCppTests']

IMAGE_DIFF_FAIL_THRESHOLD = 0.1
IMAGE_DIFF_FAIL_PERCENT = 2

def referenceScene(self):

# Add a non-referenced object in the scene so that the scene
# with the unloaded reference will still contain an object.
cmds.polySphere()
cmds.move(0, 0, -2)

# Move the camera in closer
self.setBasicCam(5)

testFile = testUtils.getTestScene("testMayaReference", "aCube.ma")
return cmds.file(testFile, reference=True, namespace='aCube')

def test_LoadMayaReference(self):

file = self.referenceScene()
refNode = cmds.file(file, query=True, referenceNode=True)

cmds.refresh()

self.assertSnapshotClose('loadMayaReference.png', self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)

# Unload the reference
cmds.file(unloadReference=refNode)

cmds.refresh()

self.assertSnapshotClose('unloadMayaReference.png', self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)

def test_EditMayaReference(self):

self.referenceScene()

cmds.move(0, 0, 2, '|aCube:pCube1')

cmds.refresh()

self.assertSnapshotClose('editMayaReference.png', self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)

def test_RemoveMayaReference(self):

file = self.referenceScene()

cmds.refresh()

# Remove the reference
cmds.file(file, removeReference=True)

cmds.refresh()

# Same snapshot as unloaded reference.
self.assertSnapshotClose('unloadMayaReference.png', self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)

if __name__ == '__main__':
fixturesUtils.runTests(globals())
Loading