diff --git a/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_black.jpg b/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_black.jpg new file mode 100644 index 0000000000..53c40b27c3 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_black.jpg differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_blue.jpg b/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_blue.jpg new file mode 100644 index 0000000000..ffba818eac Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_blue.jpg differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_gray.jpg b/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_gray.jpg new file mode 100644 index 0000000000..747660e762 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_gray.jpg differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_green.jpg b/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_green.jpg new file mode 100644 index 0000000000..3ef40e1598 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_green.jpg differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_red.jpg b/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_red.jpg new file mode 100644 index 0000000000..8d5143a570 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_red.jpg differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_white.jpg b/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_white.jpg new file mode 100644 index 0000000000..4e3e4da09d Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/BackgroundColorTest/background_white.jpg differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt b/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt index cabf4f99b2..ba6e2bf94e 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt +++ b/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt @@ -33,6 +33,8 @@ set(INTERACTIVE_TEST_SCRIPT_FILES testCurveTools.py testPolygonPrimitives.py testFootPrintNode.py + testBackgroundColor.py + testGrid.py cpp/testColorPreferences.py cpp/testCppFramework.py cpp/testMayaSceneFlattening.py diff --git a/test/lib/mayaUsd/render/mayaToHydra/GridTest/grid_disabled.png b/test/lib/mayaUsd/render/mayaToHydra/GridTest/grid_disabled.png new file mode 100644 index 0000000000..dbedef32fd Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/GridTest/grid_disabled.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/GridTest/grid_enabled.png b/test/lib/mayaUsd/render/mayaToHydra/GridTest/grid_enabled.png new file mode 100644 index 0000000000..c08e74edb7 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/GridTest/grid_enabled.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/README.md b/test/lib/mayaUsd/render/mayaToHydra/README.md index f0a17c47cd..5d7babf853 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/README.md +++ b/test/lib/mayaUsd/render/mayaToHydra/README.md @@ -67,6 +67,7 @@ To add a new Python-only test suite : Some important notes : - Before each test, a new file will be opened and the renderer will be switched to Hydra. If you need to switch between renderers, you can use the `self.setHdStormRenderer()` and `self.setViewport2Renderer()` methods. +- Some test settings (such as turning color management off, disabling the grid, etc.) are applied by default when opening a scene using `mayaUtils.openNewScene` or `mayaUtils.openTestScene`. The new scene opened before each test is opened using `mayaUtils.openNewScene`, meaning those test settings will automatically be applied before each test. These methods provide the option not to apply those settings if desired, by passing in `useTestSettings=False`. If you want to test a setting that is modified as part of those test settings, you can either re-set it explicitly in the test, and/or load a scene with the desired settings by calling `mayaUtils.openTestScene(, useTestSettings=False)`. In case you want to avoid ever changing the test settings entirely, you can also override the `setUp` method. # Best practices - Don't skip tests unless necessary. If a test requires a certain plugin to be loaded, don't skip the test if the plugin fails to load, as this will falsely be reported as a pass. For such cases, prefer setting the `_requiredPlugins` variable in your test class. diff --git a/test/lib/mayaUsd/render/mayaToHydra/testArnoldLights.py b/test/lib/mayaUsd/render/mayaToHydra/testArnoldLights.py index a8333ac307..f3a1a96fce 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testArnoldLights.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testArnoldLights.py @@ -66,8 +66,6 @@ def verifyLightingModes(self, shadowOn): #Test arnold lights (e.g., aiSkyDomeLight,etc.) with a maya native sphere and usd sphere. def test_ArnoldLights(self): - cmds.file(new=True, force=True) - # Load a maya scene with a maya native sphere, usd sphere and some lights, with HdStorm already being the viewport renderer. # The sphere is not at the origin on purpose testFile = mayaUtils.openTestScene( diff --git a/test/lib/mayaUsd/render/mayaToHydra/testBackgroundColor.py b/test/lib/mayaUsd/render/mayaToHydra/testBackgroundColor.py new file mode 100644 index 0000000000..d002808e60 --- /dev/null +++ b/test/lib/mayaUsd/render/mayaToHydra/testBackgroundColor.py @@ -0,0 +1,49 @@ +# 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 + +class TestBackgroundColor(mtohUtils.MayaHydraBaseTestCase): + # MayaHydraBaseTestCase.setUpClass requirement. + _file = __file__ + + IMAGE_DIFF_FAIL_THRESHOLD = 0.05 + IMAGE_DIFF_FAIL_PERCENT = 1 + + def compareBackgroundColor(self, imageName): + self.setViewport2Renderer() + self.assertSnapshotClose(imageName, self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) + self.setHdStormRenderer() + self.assertSnapshotClose(imageName, self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) + + def test_BackgroundColor(self): + cmds.displayRGBColor('background', 0.5, 0, 0) + self.compareBackgroundColor("background_red.jpg") + cmds.displayRGBColor('background', 0, 0.5, 0) + self.compareBackgroundColor("background_green.jpg") + cmds.displayRGBColor('background', 0, 0, 0.5) + self.compareBackgroundColor("background_blue.jpg") + + cmds.displayRGBColor('background', 0, 0, 0) + self.compareBackgroundColor("background_black.jpg") + cmds.displayRGBColor('background', 0.5, 0.5, 0.5) + self.compareBackgroundColor("background_gray.jpg") + cmds.displayRGBColor('background', 1, 1, 1) + self.compareBackgroundColor("background_white.jpg") + +if __name__ == '__main__': + fixturesUtils.runTests(globals()) diff --git a/test/lib/mayaUsd/render/mayaToHydra/testFootPrintNode.py b/test/lib/mayaUsd/render/mayaToHydra/testFootPrintNode.py index e6c8f51cd4..9e15682960 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testFootPrintNode.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testFootPrintNode.py @@ -231,7 +231,6 @@ def test_MultipleViewports(self): #Test loading a scene def test_Load(self): with PluginLoaded('mayaHydraFootPrintNode'): - cmds.file(new=True, force=True) testFile = mayaUtils.openTestScene( "testFootPrintNode", "testFootPrintNodeSaved.ma") diff --git a/test/lib/mayaUsd/render/mayaToHydra/testGrid.py b/test/lib/mayaUsd/render/mayaToHydra/testGrid.py new file mode 100644 index 0000000000..566a261a33 --- /dev/null +++ b/test/lib/mayaUsd/render/mayaToHydra/testGrid.py @@ -0,0 +1,34 @@ +# 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 + +class TestGrid(mtohUtils.MayaHydraBaseTestCase): + # MayaHydraBaseTestCase.setUpClass requirement. + _file = __file__ + + IMAGE_DIFF_FAIL_THRESHOLD = 0.15 + IMAGE_DIFF_FAIL_PERCENT = 2 + + def test_Grid(self): + cmds.grid(toggle=True) + self.assertSnapshotClose("grid_enabled.png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) + cmds.grid(toggle=False) + self.assertSnapshotClose("grid_disabled.png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) + +if __name__ == '__main__': + fixturesUtils.runTests(globals()) diff --git a/test/lib/mayaUsd/render/mayaToHydra/testMayaLights.py b/test/lib/mayaUsd/render/mayaToHydra/testMayaLights.py index d929113308..6d2b111155 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testMayaLights.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testMayaLights.py @@ -86,8 +86,6 @@ def verifyLightingModes(self, shadowOn): #Test maya lights (e.g., default,directional,point,spot,etc.) with a maya native sphere and usd sphere. def test_MayaLights(self): - cmds.file(new=True, force=True) - # Load a maya scene with a maya native sphere, usd sphere and some lights, with HdStorm already being the viewport renderer. # The sphere is not at the origin on purpose testFile = mayaUtils.openTestScene( diff --git a/test/lib/mayaUsd/render/mayaToHydra/testMtohBasicRender.py b/test/lib/mayaUsd/render/mayaToHydra/testMtohBasicRender.py index 7b974d9d14..824082fc39 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testMtohBasicRender.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testMtohBasicRender.py @@ -26,8 +26,6 @@ class TestSnapshot(mtohUtils.MayaHydraBaseTestCase): _file = __file__ def test_flat_orange(self): - cmds.file(new=1, f=1) - activeEditor = cmds.playblast(activeEditor=1) # Note that we use the default viewport2 renderer, because we're not testing diff --git a/test/lib/mayaUsd/render/mayaToHydra/testMtohDagChanges.py b/test/lib/mayaUsd/render/mayaToHydra/testMtohDagChanges.py index 838b807170..0bfd4eeff7 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testMtohDagChanges.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testMtohDagChanges.py @@ -17,6 +17,7 @@ import maya.mel import fixturesUtils +import mayaUtils import mtohUtils class TestDagChanges(mtohUtils.MayaHydraBaseTestCase): @@ -271,7 +272,7 @@ def test_node_creation_undo(self): cmds.undoInfo(state=0) try: - cmds.file(new=1, f=1) + mayaUtils.openNewScene() self.setBasicCam() self.setHdStormRenderer() diff --git a/test/lib/mayaUsd/render/mayaToHydra/testObjectTemplate.py b/test/lib/mayaUsd/render/mayaToHydra/testObjectTemplate.py index 095f5e8bbe..8ffc27f517 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testObjectTemplate.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testObjectTemplate.py @@ -29,8 +29,6 @@ class TestObjectTemplate(mtohUtils.MayaHydraBaseTestCase): #Subclassing mtohUtil #Test object display & selection when template attribute is on. def test_ObjectTemplate(self): - cmds.file(new=True, force=True) - # Load a maya scene with a maya native sphere testFile = mayaUtils.openTestScene( "testObjectTemplate", diff --git a/test/lib/mayaUsd/render/mayaToHydra/testStagePayloadsReferences.py b/test/lib/mayaUsd/render/mayaToHydra/testStagePayloadsReferences.py index 504ac064ea..3cd3e05bed 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testStagePayloadsReferences.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testStagePayloadsReferences.py @@ -30,7 +30,6 @@ class TestUsdStagePayloadsAndReferences(mtohUtils.MayaHydraBaseTestCase): #Subcl IMAGE_DIFF_FAIL_PERCENT = 2 def loadUsdPayloadScene(self): - cmds.file(new=True, force=True) mayaUtils.openTestScene( "testStagePayloadsReferences", "FlowerPot.ma") @@ -38,7 +37,6 @@ def loadUsdPayloadScene(self): cmds.refresh() def loadUsdReferencesScene(self): - cmds.file(new=True, force=True) mayaUtils.openTestScene( "testStagePayloadsReferences", "References.ma") @@ -49,7 +47,7 @@ def setUpReferenceScene(self): from mayaUsd import lib as mayaUsdLib import mayaUsd_createStageWithNewLayer - cmds.file(new=True, force=True) + mayaUtils.openNewScene() # Create a simple scene with a Def prim with a USD reference. psPathStr = mayaUsd_createStageWithNewLayer.createStageWithNewLayer() @@ -66,7 +64,7 @@ def setUpReferenceScene(self): self.setHdStormRenderer() def setUpPayloadScene(self): - cmds.file(new=True, force=True) + mayaUtils.openNewScene() import mayaUsd_createStageWithNewLayer from mayaUsd import lib as mayaUsdLib import usdUtils diff --git a/test/lib/mayaUsd/render/mayaToHydra/testStageVariants.py b/test/lib/mayaUsd/render/mayaToHydra/testStageVariants.py index 1b97fcd4ea..15ef9999d2 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testStageVariants.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testStageVariants.py @@ -32,7 +32,6 @@ def test_UsdStageVariants(self): from mayaUsd import lib as mayaUsdLib # usdUtils imports mayaUsd.ufe import usdUtils - cmds.file(new=True, force=True) testFile = mayaUtils.openTestScene( "testStageVariants", diff --git a/test/lib/mayaUsd/render/mayaToHydra/testStandardSurface.py b/test/lib/mayaUsd/render/mayaToHydra/testStandardSurface.py index a5fcf60386..ff3a526097 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testStandardSurface.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testStandardSurface.py @@ -28,8 +28,6 @@ class TestStandardSurface(mtohUtils.MayaHydraBaseTestCase): #Subclassing mtohUti #Test the translation from maya standard surface with a maya native plane to usd preview surface. def test_StandardSurface(self): - cmds.file(new=True, force=True) - # Load a maya scene with a maya native plane, which has autodesk standard surface as material testFile = mayaUtils.openTestScene( "testStandardSurface", diff --git a/test/lib/mayaUsd/render/mayaToHydra/testTransforms.py b/test/lib/mayaUsd/render/mayaToHydra/testTransforms.py index 70f27b2d6a..7efbf12d91 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testTransforms.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testTransforms.py @@ -15,6 +15,7 @@ import maya.cmds as cmds import fixturesUtils +import mayaUtils import mtohUtils class TestTransforms(mtohUtils.MayaHydraBaseTestCase): @@ -59,7 +60,7 @@ def test_usdPrim(self): import mayaUsd_createStageWithNewLayer from pxr import UsdGeom, Gf - cmds.file(new=True, force=True) + mayaUtils.openNewScene() self.setBasicCam(10) self.setHdStormRenderer() diff --git a/test/lib/mayaUsd/render/mayaToHydra/testUSDLights.py b/test/lib/mayaUsd/render/mayaToHydra/testUSDLights.py index 3389191806..5afb988821 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testUSDLights.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testUSDLights.py @@ -73,8 +73,6 @@ def verifyLightingModes(self, shadowOn): #Test usd lights (e.g., disk,distant,dome,etc.) with a maya native sphere and usd sphere. def test_USDLights(self): - cmds.file(new=True, force=True) - # Load a maya scene with a maya native sphere, usd sphere and some lights, with HdStorm already being the viewport renderer. # The sphere is not at the origin on purpose testFile = mayaUtils.openTestScene( diff --git a/test/testUtils/imageUtils.py b/test/testUtils/imageUtils.py index b2fc7ae144..19459aff05 100644 --- a/test/testUtils/imageUtils.py +++ b/test/testUtils/imageUtils.py @@ -15,8 +15,6 @@ # import os import maya.cmds as cmds -import maya.mel -import mayaUtils import subprocess KNOWN_FORMATS = { @@ -31,19 +29,8 @@ 'bmp': 20, 'png': 32, } -def resetDefaultLightIntensity(): - """If the current Maya version supports setting the default light intensity, - then restore it to 1 so snapshots look equal across versions.""" - if maya.mel.eval("optionVar -exists defaultLightIntensity"): - maya.mel.eval("optionVar -fv defaultLightIntensity 1") - if cmds.attributeQuery('defaultLightIntensity', node='hardwareRenderingGlobals', exists=True): - cmds.setAttr('hardwareRenderingGlobals.defaultLightIntensity', 1.0) -resetDefaultLightIntensity() -def snapshot(outputPath, width=400, height=None, hud=False, grid=False, colorManagementEnabled=False, camera=None): - resetDefaultLightIntensity() - cmds.displayRGBColor('background', 0.36, 0.36, 0.36) - +def snapshot(outputPath, width=400, height=None): if height is None: height = width @@ -60,24 +47,8 @@ def snapshot(outputPath, width=400, height=None, hud=False, grid=False, colorMan # save the old output image format oldFormat = cmds.getAttr("defaultRenderGlobals.imageFormat") - # save the hud setting - oldHud = cmds.headsUpDisplay(q=1, layoutVisibility=1) - # save the grid setting - oldGrid = cmds.grid(q=1, toggle=1) - # save the old color management status - oldColorManagementEnabled = cmds.colorManagementPrefs(q=1, cmEnabled=1) - - # Find the current model panel for playblasting - # to make sure the desired camera is set, if any - panel = mayaUtils.activeModelPanel() - oldCamera = cmds.modelPanel(panel, q=True, cam=True) - if camera: - cmds.modelEditor(panel, edit=True, camera=camera) cmds.setAttr("defaultRenderGlobals.imageFormat", formatNum) - cmds.headsUpDisplay(layoutVisibility=hud) - cmds.grid(toggle=grid) - cmds.colorManagementPrefs(edit=True, cmEnabled=colorManagementEnabled) try: cmds.refresh() cmds.playblast(cf=outputPath, viewer=False, format="image", @@ -85,12 +56,6 @@ def snapshot(outputPath, width=400, height=None, hud=False, grid=False, colorMan widthHeight=(width, height), percent=100) finally: cmds.setAttr("defaultRenderGlobals.imageFormat", oldFormat) - cmds.headsUpDisplay(layoutVisibility=oldHud) - cmds.grid(toggle=oldGrid) - cmds.colorManagementPrefs(edit=True, cmEnabled=oldColorManagementEnabled) - - if camera: - cmds.lookThru(panel, oldCamera) def imageDiff(imagePath1, imagePath2, verbose, fail, failpercent, hardfail, warn, warnpercent, hardwarn, perceptual): diff --git a/test/testUtils/mayaUtils.py b/test/testUtils/mayaUtils.py index 62412e8db8..e5ee67781a 100644 --- a/test/testUtils/mayaUtils.py +++ b/test/testUtils/mayaUtils.py @@ -29,6 +29,7 @@ pass from maya import cmds +from maya import mel from maya.api import OpenMaya as om import ufe @@ -132,75 +133,31 @@ def isHydraRenderer(): activeRenderer = cmds.modelEditor(activeEditor, q=True,rendererOverrideName=True) return activeRenderer == HD_STORM_OVERRIDE -def openTestScene(*args): - filePath = testUtils.getTestScene(*args) - cmds.file(filePath, force=True, open=True) - # To err on the safe side, disable color management in case the scene had color management on. - # If/when we add color management tests, they will need to re-enable it manually. +def resetDefaultLightIntensity(): + """If the current Maya version supports setting the default light intensity, + then restore it to 1 so snapshots look equal across versions.""" + if mel.eval("optionVar -exists defaultLightIntensity"): + mel.eval("optionVar -fv defaultLightIntensity 1") + if cmds.attributeQuery('defaultLightIntensity', node='hardwareRenderingGlobals', exists=True): + cmds.setAttr('hardwareRenderingGlobals.defaultLightIntensity', 1.0) + +def applyTestSettings(): + resetDefaultLightIntensity() + cmds.headsUpDisplay(layoutVisibility=False) + cmds.grid(toggle=False) cmds.colorManagementPrefs(edit=True, cmEnabled=False) - if isHydraRenderer(): - cmds.setAttr("hardwareRenderingGlobals.multiSampleEnable", True) - - -def openTopLayerScene(): - ''' - The test scene hierarchy is represented as : - |world - |pSphere1 - |pSphereShape1 - |transform1 - |proxyShape1 - /Room_set - /Props - /Ball_1 - /Ball_2 - ... - /Ball_35 - ''' - # Open top_layer file which contains the USD scene - return openTestScene("ballset", "StandaloneScene", "top_layer.ma" ) - -def openCylinderScene(): - return openTestScene("cylinder", "usdCylinder.ma" ) - -def openTwoSpheresScene(): - return openTestScene("twoSpheres", "twoSpheres.ma" ) - -def openSphereAnimatedRadiusScene(): - return openTestScene("sphereAnimatedRadius", "sphereAnimatedRadiusProxyShape.ma" ) - -def openTreeScene(): - return openTestScene("tree", "tree.ma" ) - -def openTreeRefScene(): - return openTestScene("tree", "treeRef.ma" ) - -def openAppleBiteScene(): - return openTestScene("appleBite", "appleBite.ma" ) - -def openGroupBallsScene(): - return openTestScene("groupBalls", "ballset.ma" ) + cmds.setAttr("hardwareRenderingGlobals.multiSampleEnable", True) # TODO : Turn anti-aliasing off by default. -def openPrimitivesScene(): - return openTestScene("reorderCmd", "primitives.ma" ) - -def openPointInstancesGrid14Scene(): - return openTestScene("pointInstances", "PointInstancer_Grid_14.ma" ) - -def openPointInstancesGrid7kScene(): - return openTestScene("pointInstances", "PointInstancer_Grid_7k.ma" ) - -def openPointInstancesGrid70kScene(): - return openTestScene("pointInstances", "PointInstancer_Grid_70k.ma" ) - -def openVariantSetScene(): - return openTestScene("variantSet", "Variant.ma" ) - -def openCompositionArcsScene(): - return openTestScene("compositionArcs", "compositionArcs.ma" ) +def openNewScene(useTestSettings=True): + cmds.file(new=True, force=True) + if useTestSettings: + applyTestSettings() -def openPrimPathScene(): - return openTestScene("primPath", "primPath.ma" ) +def openTestScene(*args, useTestSettings=True): + filePath = testUtils.getTestScene(*args) + cmds.file(filePath, force=True, open=True) + if useTestSettings: + applyTestSettings() def setMayaTranslation(aMayaItem, t): '''Set the translation on the argument Maya scene item.''' @@ -254,23 +211,6 @@ def createProxyFromFile(filePath): return shapeNode,shapeStage -def createSingleSphereMayaScene(directory=None): - '''Create a Maya scene with a single polygonal sphere. - Returns the file path. - ''' - - cmds.file(new=True, force=True) - cmds.CreatePolygonSphere() - tempMayaFile = 'simpleSphere.ma' - if directory is not None: - tempMayaFile = os.path.join(directory, tempMayaFile) - # Prevent Windows single backslash from being interpreted as a control - # character. - tempMayaFile = tempMayaFile.replace(os.sep, '/') - cmds.file(rename=tempMayaFile) - cmds.file(save=True, force=True, type='mayaAscii') - return tempMayaFile - def mayaMajorVersion(): return int(cmds.about(majorVersion=True)) diff --git a/test/testUtils/mtohUtils.py b/test/testUtils/mtohUtils.py index d61b621065..b8240bbea0 100644 --- a/test/testUtils/mtohUtils.py +++ b/test/testUtils/mtohUtils.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import inspect import os import unittest @@ -21,6 +20,7 @@ import maya.mel import fixturesUtils +import mayaUtils import testUtils from imageUtils import ImageDiffingTestCase @@ -88,7 +88,7 @@ def setUp(self): # Maya is not closed/reset between each test of a test suite, # so open a new file before each test to minimize leftovers # from previous tests. - cmds.file(new=True, force=True) + mayaUtils.openNewScene() self.setHdStormRenderer() @classmethod @@ -108,7 +108,6 @@ def setHdStormRenderer(self): cmds.modelEditor( self.activeEditor, e=1, rendererOverrideName=HD_STORM_OVERRIDE) - cmds.setAttr("hardwareRenderingGlobals.multiSampleEnable", True) cmds.refresh(f=1) self.delegateId = cmds.mayaHydra(renderer=HD_STORM, sceneDelegateId="MayaHydraSceneDelegate") @@ -125,7 +124,7 @@ def setBasicCam(self, dist=DEFAULT_CAM_DIST): cmds.setAttr('persp.translate', dist, .75 * dist, dist, type='float3') def makeCubeScene(self, camDist=DEFAULT_CAM_DIST): - cmds.file(f=1, new=1) + mayaUtils.openNewScene() self.cubeTrans = cmds.polyCube()[0] self.cubeShape = cmds.listRelatives(self.cubeTrans)[0] self.setHdStormRenderer()