Skip to content

Commit

Permalink
add test for template and reference
Browse files Browse the repository at this point in the history
  • Loading branch information
lilike-adsk committed Feb 16, 2024
1 parent 5251eca commit d3dcee3
Show file tree
Hide file tree
Showing 8 changed files with 352 additions and 0 deletions.
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 @@ -18,6 +18,7 @@ set(INTERACTIVE_TEST_SCRIPT_FILES
testUSDLights.py
testArnoldLights.py
testLookThrough.py
testTemplateAndReference.py
testStandardSurface.py
testFlowViewportAPI.py
testStageVariants.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.
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.
77 changes: 77 additions & 0 deletions test/lib/mayaUsd/render/mayaToHydra/testTemplateAndReference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#
# Copyright 2024 Autodesk, Inc. All rights reserved.
#
# 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 mayaUtils
import platform

class TestTemplateAndReference(mtohUtils.MtohTestCase): #Subclassing mtohUtils.MtohTestCase to be able to call self.assertSnapshotClose
# MayaHydraBaseTestCase.setUpClass requirement.
_file = __file__

@property
def imageDiffFailThreshold(self):
return 0.01

@property
def imageDiffFailPercent(self):
# HYDRA-837 : Wireframes seem to have a slightly different color on macOS. We'll increase the thresholds
# for that platform specifically for now, so we can still catch issues on other platforms.
if platform.system() == "Darwin":
return 3
return 0.2

#Test object display & selection under Template & Reference modes.
def test_TemplateAndReference(self):
cmds.file(new=True, force=True)

# Load a maya scene with a maya native cubic and sphere
testFile = mayaUtils.openTestScene(
"testTemplateAndReference",
"testTemplateAndReference.ma")
cmds.refresh()

#Verify Default display
panel = mayaUtils.activeModelPanel()
self.assertSnapshotClose("default" + ".png", self.imageDiffFailThreshold, self.imageDiffFailPercent)

#Verify template mode
#Display
cmds.setAttr('layer_sphere.displayType', 1)
cmds.refresh()
self.assertSnapshotClose("templateMode" + ".png", self.imageDiffFailThreshold, self.imageDiffFailPercent)
#Selection
cmds.select( clear=True )
cmds.select( 'pSphere1', r=True )
cmds.refresh()
self.assertSnapshotClose("templateModeSelection" + ".png", self.imageDiffFailThreshold, self.imageDiffFailPercent)

#Verify reference mode
#Display
cmds.setAttr('layer_cubic.displayType', 2)
cmds.refresh()
self.assertSnapshotClose("referenceMode" + ".png", self.imageDiffFailThreshold, self.imageDiffFailPercent)
#Selection
cmds.select( clear=True )
cmds.select( 'pCube1', r=True )
cmds.refresh()
self.assertSnapshotClose("referenceModeSelection" + ".png", self.imageDiffFailThreshold, self.imageDiffFailPercent)


if __name__ == '__main__':
fixturesUtils.runTests(globals())
274 changes: 274 additions & 0 deletions test/testSamples/testTemplateAndReference/testTemplateAndReference.ma

Large diffs are not rendered by default.

0 comments on commit d3dcee3

Please sign in to comment.