Skip to content

Commit

Permalink
Automated test for the feature
Browse files Browse the repository at this point in the history
  • Loading branch information
vlasovi committed Mar 21, 2024
1 parent 9a47a5b commit 7dc2057
Show file tree
Hide file tree
Showing 5 changed files with 62 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 @@ -12,6 +12,7 @@ set(INTERACTIVE_TEST_SCRIPT_FILES
testSceneBrowser.py
testStageAddPrim.py
testTransforms.py
testRefinement.py
testMaterialXOnNative.py
testNewSceneWithStage.py
testMayaDisplayModes.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.
61 changes: 61 additions & 0 deletions test/lib/mayaUsd/render/mayaToHydra/testRefinement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2024 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 unittest
import testUtils

class TestRefinement(mtohUtils.MtohTestCase):
_file = __file__

IMAGEDIFF_FAIL_THRESHOLD = 0.01
IMAGEDIFF_FAIL_PERCENT = 0.1

def verifySnapshot(self, imageName):
cmds.refresh()
self.assertSnapshotClose(imageName,
self.IMAGEDIFF_FAIL_THRESHOLD,
self.IMAGEDIFF_FAIL_PERCENT)

@unittest.skipUnless(mtohUtils.checkForMayaUsdPlugin(), "Requires Maya USD Plugin.")
def test_usdPrim(self):
import usdUtils
usdScenePath = testUtils.getTestScene('testStagePayloadsReferences', 'cube.usda')
usdUtils.createStageFromFile(usdScenePath)

self.setBasicCam(1)
self.setHdStormRenderer()
cmds.mayaHydra(createRenderGlobals=1)

cmds.setAttr("defaultRenderGlobals.mtohRefinementLevel", 0)
cmds.mayaHydra(updateRenderGlobals="mtohRefinementLevel")
self.verifySnapshot("usd_cube_refined_0.png")

cmds.setAttr("defaultRenderGlobals.mtohRefinementLevel", 2)
cmds.mayaHydra(updateRenderGlobals="mtohRefinementLevel")
self.verifySnapshot("usd_cube_refined_2.png")

cmds.setAttr("defaultRenderGlobals.mtohRefinementLevel", 4)
cmds.mayaHydra(updateRenderGlobals="mtohRefinementLevel")
self.verifySnapshot("usd_cube_refined_4.png")

#restore the default
cmds.setAttr("defaultRenderGlobals.mtohRefinementLevel", 0)
cmds.mayaHydra(updateRenderGlobals="mtohRefinementLevel")

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

0 comments on commit 7dc2057

Please sign in to comment.