diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/flat_orange.png b/test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/flat_orange.png similarity index 100% rename from test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/flat_orange.png rename to test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/flat_orange.png diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/flat_orange_bad.png b/test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/flat_orange_bad.png similarity index 100% rename from test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/flat_orange_bad.png rename to test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/flat_orange_bad.png diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/lambertDefaultMaterial/cube_selected.png b/test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/lambert/cube_selected.png similarity index 100% rename from test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/lambertDefaultMaterial/cube_selected.png rename to test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/lambert/cube_selected.png diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/lambertDefaultMaterial/cube_unselected.png b/test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/lambert/cube_unselected.png similarity index 100% rename from test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/lambertDefaultMaterial/cube_unselected.png rename to test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/lambert/cube_unselected.png diff --git a/test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/standardSurface/cube_selected.png b/test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/standardSurface/cube_selected.png new file mode 100644 index 0000000000..9d07d33910 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/standardSurface/cube_selected.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/standardSurface/cube_unselected.png b/test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/standardSurface/cube_unselected.png new file mode 100644 index 0000000000..60970e22e7 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/BasicRenderTest/standardSurface/cube_unselected.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt b/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt index 34ac5227d0..1153f952db 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt +++ b/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt @@ -9,8 +9,8 @@ set(INTERACTIVE_TEST_SCRIPT_FILES testImageDiffing.py testMtohCommand.py # Fail as of 22-Feb-2023. Entered as MAYA-127898. -# testMtohBasicRender.py -# testMtohDagChanges.py + testBasicRender.py + testDagChanges.py testMeshes.py testNamespaces.py testVisibility.py diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_0.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_0.png similarity index 100% rename from test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_0.png rename to test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_0.png diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_1.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_1.png similarity index 100% rename from test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_1.png rename to test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_1.png diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_12.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_12.png similarity index 100% rename from test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_12.png rename to test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_12.png diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_123.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_123.png similarity index 100% rename from test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_123.png rename to test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_123.png diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_1234.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_1234.png similarity index 100% rename from test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_1234.png rename to test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_1234.png diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_123456.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_123456.png similarity index 100% rename from test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_123456.png rename to test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_123456.png diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_1235.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_1235.png similarity index 100% rename from test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_1235.png rename to test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_1235.png diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_3.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_3.png similarity index 100% rename from test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_3.png rename to test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_3.png diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_35.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_35.png similarity index 100% rename from test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_35.png rename to test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/lambert/instances_35.png diff --git a/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_0.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_0.png new file mode 100644 index 0000000000..dbedef32fd Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_0.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_1.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_1.png new file mode 100644 index 0000000000..87710ebf2e Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_1.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_12.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_12.png new file mode 100644 index 0000000000..34409bf153 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_12.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_123.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_123.png new file mode 100644 index 0000000000..f3ea5c00ca Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_123.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_1234.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_1234.png new file mode 100644 index 0000000000..302b0df222 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_1234.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_123456.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_123456.png new file mode 100644 index 0000000000..1c0072e545 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_123456.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_1235.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_1235.png new file mode 100644 index 0000000000..1122d5af61 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_1235.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_3.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_3.png new file mode 100644 index 0000000000..df0cb362a6 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_3.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_35.png b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_35.png new file mode 100644 index 0000000000..e3d74f75a7 Binary files /dev/null and b/test/lib/mayaUsd/render/mayaToHydra/DagChangesTest/standardSurface/instances_35.png differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/cube_selected.png b/test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/cube_selected.png deleted file mode 100644 index 06e7660601..0000000000 Binary files a/test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/cube_selected.png and /dev/null differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/cube_unselected.png b/test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/cube_unselected.png deleted file mode 100644 index 0353a7ec33..0000000000 Binary files a/test/lib/mayaUsd/render/mayaToHydra/MtohBasicRenderTest/cube_unselected.png and /dev/null differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_1.png b/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_1.png deleted file mode 100644 index a7df40de14..0000000000 Binary files a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_1.png and /dev/null differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_12.png b/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_12.png deleted file mode 100644 index 1a9cc23bba..0000000000 Binary files a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_12.png and /dev/null differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_123.png b/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_123.png deleted file mode 100644 index 9741969af0..0000000000 Binary files a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_123.png and /dev/null differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_1234.png b/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_1234.png deleted file mode 100644 index 1265595bd5..0000000000 Binary files a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_1234.png and /dev/null differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_123456.png b/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_123456.png deleted file mode 100644 index e1ec30c4e0..0000000000 Binary files a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_123456.png and /dev/null differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_1235.png b/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_1235.png deleted file mode 100644 index dc1725c7fc..0000000000 Binary files a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_1235.png and /dev/null differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_3.png b/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_3.png deleted file mode 100644 index 7cdb3cf91a..0000000000 Binary files a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_3.png and /dev/null differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_35.png b/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_35.png deleted file mode 100644 index ece346ae07..0000000000 Binary files a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/instances_35.png and /dev/null differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_0.png b/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_0.png deleted file mode 100644 index f907027797..0000000000 Binary files a/test/lib/mayaUsd/render/mayaToHydra/MtohDagChangesTest/lambertDefaultMaterial/instances_0.png and /dev/null differ diff --git a/test/lib/mayaUsd/render/mayaToHydra/testMtohBasicRender.py b/test/lib/mayaUsd/render/mayaToHydra/testBasicRender.py similarity index 66% rename from test/lib/mayaUsd/render/mayaToHydra/testMtohBasicRender.py rename to test/lib/mayaUsd/render/mayaToHydra/testBasicRender.py index 824082fc39..8e21496fa5 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testMtohBasicRender.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testBasicRender.py @@ -20,7 +20,14 @@ import fixturesUtils import mtohUtils -class TestSnapshot(mtohUtils.MayaHydraBaseTestCase): +from string import digits + +class BasicRenderBaseTestCase(mtohUtils.MayaHydraBaseTestCase): + + IMAGE_DIFF_FAIL_THRESHOLD = 0.01 + IMAGE_DIFF_FAIL_PERCENT = 0.2 + +class TestSnapshot(BasicRenderBaseTestCase): """Tests whether our snapshot rendering works with basic Viewport 2.0""" _file = __file__ @@ -49,22 +56,27 @@ def test_flat_orange(self): cmds.setAttr('persp.rotate', 0, 0, 0, type='float3') cmds.setAttr('persp.translate', 0, .25, .7, type='float3') - self.assertSnapshotEqual("flat_orange.png") - self.assertRaises(AssertionError, - self.assertSnapshotEqual, "flat_orange_bad.png") + self.assertSnapshotClose( + "flat_orange.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT) + self.assertRaises( + AssertionError, self.assertSnapshotClose, "flat_orange_bad.png", + self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) -class TestMayaHydraRender(mtohUtils.MayaHydraBaseTestCase): +class TestMayaHydraRender(BasicRenderBaseTestCase): _file = __file__ def test_cube(self): - imageVersion = None - if maya.mel.eval("defaultShaderName") != "standardSurface1": - imageVersion = 'lambertDefaultMaterial' + imageVersion = maya.mel.eval("defaultShaderName").rstrip(digits) self.makeCubeScene(camDist=6) - self.assertSnapshotEqual("cube_unselected.png", imageVersion) + self.assertSnapshotClose( + "cube_unselected.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, imageVersion) cmds.select(self.cubeTrans) - self.assertSnapshotEqual("cube_selected.png", imageVersion) + self.assertSnapshotClose( + "cube_selected.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, imageVersion) if __name__ == '__main__': diff --git a/test/lib/mayaUsd/render/mayaToHydra/testMtohDagChanges.py b/test/lib/mayaUsd/render/mayaToHydra/testDagChanges.py similarity index 58% rename from test/lib/mayaUsd/render/mayaToHydra/testMtohDagChanges.py rename to test/lib/mayaUsd/render/mayaToHydra/testDagChanges.py index 0bfd4eeff7..e351554930 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testMtohDagChanges.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testDagChanges.py @@ -20,85 +20,91 @@ import mayaUtils import mtohUtils -class TestDagChanges(mtohUtils.MayaHydraBaseTestCase): +from string import digits + +def fullPath(nodeName): + return cmds.ls(nodeName, l=True)[0] + +class DagChangesBaseTestCase(mtohUtils.MayaHydraBaseTestCase): + + IMAGE_DIFF_FAIL_THRESHOLD = 0.01 + IMAGE_DIFF_FAIL_PERCENT = 0.2 + + def rprimPath(self, mayaPath): + return '/MayaHydraViewportRenderer/rprims/Lighted' + mayaPath.replace('|', '/') + +class TestDagChanges(DagChangesBaseTestCase): _file = __file__ def setUp(self): self.makeCubeScene() self.grp1 = cmds.createNode('transform', name='group1') - self.grp1Rprim = self.rprimPath(self.grp1) - self.grp2 = cmds.createNode('transform', name='group2') - self.grp2Rprim = self.rprimPath(self.grp2) - self.imageVersion = None - if maya.mel.eval("defaultShaderName") != "standardSurface1": - self.imageVersion = 'lambertDefaultMaterial' + self.imageVersion = maya.mel.eval("defaultShaderName").rstrip(digits) def test_reparent_transform(self): cmds.parent(self.cubeTrans, self.grp1) - grp1ShapeRprim = self.rprimPath(self.cubeShape) + grp1ShapeRprim = self.rprimPath(fullPath(self.cubeShape)) self.assertEqual( grp1ShapeRprim, self.rprimPath("|{self.grp1}|{self.cubeTrans}|{self.cubeShape}" .format(self=self))) cmds.refresh() - index = self.getIndex() - self.assertIn(grp1ShapeRprim, index) - self.assertNotIn(self.cubeRprim, index) + self.assertNodeNameInIndex(grp1ShapeRprim) + self.assertNodeNameNotInIndex(self.cubeRprim) cmds.parent(self.grp1, self.grp2) - grp2ShapeRprim = self.rprimPath(self.cubeShape) + grp2ShapeRprim = self.rprimPath(fullPath(self.cubeShape)) self.assertEqual( grp2ShapeRprim, self.rprimPath("|{self.grp2}|{self.grp1}|{self.cubeTrans}|{self.cubeShape}" .format(self=self))) cmds.refresh() - index = self.getIndex() - self.assertIn(grp2ShapeRprim, index) - self.assertNotIn(grp1ShapeRprim, index) - self.assertNotIn(self.cubeRprim, index) + self.assertNodeNameInIndex(grp2ShapeRprim) + self.assertNodeNameNotInIndex(grp1ShapeRprim) + self.assertNodeNameNotInIndex(self.cubeRprim) cmds.parent(self.cubeTrans, world=True) - origShapePrim = self.rprimPath(self.cubeShape) - self.assertEqual(origShapePrim, self.cubeRprim) + origShapePrim = self.rprimPath(fullPath(self.cubeShape)) + # A Maya Dag node that is reparented back to its original path will + # have a StandardShadedItem with a different numerical suffix, but its + # path will match. + self.assertIn(origShapePrim.rstrip(digits), self.cubeRprim) cmds.refresh() - index = self.getIndex() - self.assertIn(self.cubeRprim, index) - self.assertNotIn(grp2ShapeRprim, index) - self.assertNotIn(grp1ShapeRprim, index) + self.assertNodeNameInIndex(self.cubeRprim.rstrip(digits)) + self.assertNodeNameNotInIndex(grp2ShapeRprim) + self.assertNodeNameNotInIndex(grp1ShapeRprim) def test_reparent_shape(self): cmds.parent(self.cubeShape, self.grp1, shape=1, r=1) - grp1ShapeRprim = self.rprimPath(self.cubeShape) + grp1ShapeRprim = self.rprimPath(fullPath(self.cubeShape)) self.assertEqual( grp1ShapeRprim, self.rprimPath("|{self.grp1}|{self.cubeShape}" .format(self=self))) cmds.refresh() - index = self.getIndex() - self.assertIn(grp1ShapeRprim, index) - self.assertNotIn(self.cubeRprim, index) + self.assertNodeNameInIndex(grp1ShapeRprim) + self.assertNodeNameNotInIndex(self.cubeRprim) cmds.parent(self.cubeShape, self.cubeTrans, shape=1, r=1) - origShapePrim = self.rprimPath(self.cubeShape) - self.assertEqual(origShapePrim, self.cubeRprim) + origShapePrim = self.rprimPath(fullPath(self.cubeShape)) + self.assertIn(origShapePrim.rstrip(digits), self.cubeRprim) cmds.refresh() - index = self.getIndex() - self.assertIn(self.cubeRprim, index) - self.assertNotIn(grp1ShapeRprim, index) + self.assertNodeNameInIndex(self.cubeRprim.rstrip(digits)) + self.assertNodeNameNotInIndex(grp1ShapeRprim) def test_new_shape(self): otherCube = cmds.polyCube()[0] otherCubeShape = cmds.listRelatives(otherCube, fullPath=1)[0] - otherRprim = self.rprimPath(otherCubeShape) + otherRprim = self.rprimPath(fullPath(otherCubeShape)) cmds.refresh() - index = self.getIndex() - self.assertIn(self.cubeRprim, index) - self.assertIn(otherRprim, index) + self.assertNodeNameInIndex(self.cubeRprim) + self.assertNodeNameInIndex(otherRprim) def test_instances(self): + self.setBasicCam(dist=10) undoWasEnabled = cmds.undoInfo(q=1, state=1) cmds.undoInfo(state=0) @@ -111,14 +117,18 @@ def test_instances(self): # No instances to start # (1) |pCube1|pCubeShape1 - self.assertSnapshotEqual("instances_1.png", self.imageVersion) + self.assertSnapshotClose( + "instances_1.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) # Add |group1|pCube1 instance # (1) |pCube1|pCubeShape1 # (2) |group1|pCube1|pCubeShape1 cmds.parent(self.cubeTrans, self.grp1, add=1, r=1) cmds.select(clear=1) - self.assertSnapshotEqual("instances_12.png", self.imageVersion) + self.assertSnapshotClose( + "instances_12.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) # Add |pCube2|pCubeShape1 instance # (1) |pCube1|pCubeShape1 @@ -126,7 +136,9 @@ def test_instances(self): # (3) |pCube2|pCubeShape1 cmds.parent(self.cubeShape, pCube2, add=1, r=1, shape=1) cmds.select(clear=1) - self.assertSnapshotEqual("instances_123.png", self.imageVersion) + self.assertSnapshotClose( + "instances_123.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) # Add |group2|group1|pCube1 instance # (1) |pCube1|pCubeShape1 @@ -135,7 +147,9 @@ def test_instances(self): # (4) |group2||group1|pCube1|pCubeShape1 cmds.parent(self.grp1, self.grp2, add=1, r=1) cmds.select(clear=1) - self.assertSnapshotEqual("instances_1234.png", self.imageVersion) + self.assertSnapshotClose( + "instances_1234.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) # Add |group1|pCube2 instance # (1) |pCube1|pCubeShape1 @@ -146,7 +160,9 @@ def test_instances(self): # (6) |group2||group1|pCube2|pCubeShape1 cmds.parent(pCube2, self.grp1, add=1, r=1) cmds.select(clear=1) - self.assertSnapshotEqual("instances_123456.png", self.imageVersion) + self.assertSnapshotClose( + "instances_123456.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) # Delete group2 # [no shapes] @@ -155,7 +171,9 @@ def test_instances(self): try: cmds.delete(self.grp2) self.assertNotIn(self.cubeRprim, self.getIndex()) - self.assertSnapshotEqual("instances_0.png", self.imageVersion) + self.assertSnapshotClose( + "instances_0.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) finally: cmds.undoInfo(closeChunk=1) @@ -167,7 +185,9 @@ def test_instances(self): # (5) |group1|pCube2|pCubeShape1 # (6) |group2||group1|pCube2|pCubeShape1 cmds.undo() - self.assertSnapshotEqual("instances_123456.png", self.imageVersion) + self.assertSnapshotClose( + "instances_123456.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) # Remove |group2|group1 instance # (1) |pCube1|pCubeShape1 @@ -176,7 +196,9 @@ def test_instances(self): # (5) |group1|pCube2|pCubeShape1 cmds.parent('|{self.grp2}|{self.grp1}'.format(self=self), removeObject=1) - self.assertSnapshotEqual("instances_1235.png", self.imageVersion) + self.assertSnapshotClose( + "instances_1235.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) # Remove pCube2|pCubeShape1 instance # (1) |pCube1|pCubeShape1 @@ -186,7 +208,9 @@ def test_instances(self): cmds.parent('|{pCube2}|{self.cubeShape}'.format(self=self, pCube2=pCube2), removeObject=1, shape=1) - self.assertSnapshotEqual("instances_12.png", self.imageVersion) + self.assertSnapshotClose( + "instances_12.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) finally: cmds.undoInfo(closeChunk=1) @@ -196,7 +220,9 @@ def test_instances(self): # (3) |pCube2|pCubeShape1 # (5) |group1|pCube2|pCubeShape1 cmds.undo() - self.assertSnapshotEqual("instances_1235.png", self.imageVersion) + self.assertSnapshotClose( + "instances_1235.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) # Remove pCube1|pCubeShape1 (the "master" instance) # (3) |pCube2|pCubeShape1 @@ -205,7 +231,9 @@ def test_instances(self): try: cmds.parent('|{self.cubeTrans}|{self.cubeShape}'.format(self=self), removeObject=1, shape=1) - self.assertSnapshotEqual("instances_35.png", self.imageVersion) + self.assertSnapshotClose( + "instances_35.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) finally: cmds.undoInfo(closeChunk=1) @@ -220,7 +248,9 @@ def test_instances(self): # need to disable without flusing the queue, so we can test redo cmds.undoInfo(stateWithoutFlush=0) try: - self.assertSnapshotEqual("instances_1235.png", self.imageVersion) + self.assertSnapshotClose( + "instances_1235.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) finally: cmds.undoInfo(stateWithoutFlush=1) @@ -228,23 +258,33 @@ def test_instances(self): # (3) |pCube2|pCubeShape1 # (5) |group1|pCube2|pCubeShape1 cmds.redo() - self.assertSnapshotEqual("instances_35.png", self.imageVersion) + self.assertSnapshotClose( + "instances_35.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) # Remove |group1|pCube2 instance # (3) |pCube2|pCubeShape1 cmds.parent('{self.grp1}|{pCube2}'.format(self=self, pCube2=pCube2), removeObject=1) - self.assertSnapshotEqual("instances_3.png", self.imageVersion) + self.assertSnapshotClose( + "instances_3.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) finally: cmds.undoInfo(state=undoWasEnabled) def test_move(self): - self.assertSnapshotEqual("instances_1.png", self.imageVersion) + self.setBasicCam(dist=10) + self.assertSnapshotClose( + "instances_1.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) cmds.setAttr('{}.ty'.format(self.cubeTrans), 5) - self.assertSnapshotEqual("instances_3.png", self.imageVersion) + self.assertSnapshotClose( + "instances_3.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) def test_instance_move(self): + self.setBasicCam(dist=10) # Add |group1|pCube1 instance # (1) |pCube1|pCubeShape1 # (2) |group1|pCube1|pCubeShape1 @@ -253,40 +293,49 @@ def test_instance_move(self): # because we haven't moved anything, it should initially look like only # one cube... - self.assertSnapshotEqual("instances_1.png", self.imageVersion) + self.assertSnapshotClose( + "instances_1.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) cmds.setAttr('{}.tz'.format(self.grp1), 5) # Now that we moved one, it should look like 2 cubes - self.assertSnapshotEqual("instances_12.png", self.imageVersion) + self.assertSnapshotClose( + "instances_12.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) -class TestUndo(mtohUtils.MayaHydraBaseTestCase): +class TestUndo(DagChangesBaseTestCase): _file = __file__ def test_node_creation_undo(self): undoWasEnabled = cmds.undoInfo(q=1, state=1) - self.imageVersion = None - if maya.mel.eval("defaultShaderName") != "standardSurface1": - self.imageVersion = 'lambertDefaultMaterial' + self.imageVersion = maya.mel.eval("defaultShaderName").rstrip(digits) cmds.undoInfo(state=0) try: mayaUtils.openNewScene() - self.setBasicCam() + self.setBasicCam(dist=10) self.setHdStormRenderer() + if maya.mel.eval("defaultShaderName") == "standardSurface1": + color = (0.8, 0.8, 0.8) + cmds.setAttr("standardSurface1.baseColor", type='float3', *color) + cmds.setAttr("standardSurface1.specularRoughness", 0.4) + cmds.undoInfo(state=1) cmds.undoInfo(openChunk=1) try: cubeTrans = cmds.polyCube() cubeShape = cmds.listRelatives(cubeTrans)[0] - cubeRprim = self.rprimPath(cubeShape) + cubeRprim = self.rprimPath(fullPath(cubeShape)) cmds.select(clear=1) cmds.refresh() - self.assertEqual([cubeRprim], self.getIndex()) - self.assertSnapshotEqual("instances_1.png", self.imageVersion) + self.assertIn(cubeRprim, self.getIndex()[0]) + self.assertSnapshotClose( + "instances_1.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) finally: cmds.undoInfo(closeChunk=1) @@ -298,7 +347,9 @@ def test_node_creation_undo(self): try: cmds.refresh() self.assertEqual([], self.getIndex()) - self.assertSnapshotEqual("instances_0.png", self.imageVersion) + self.assertSnapshotClose( + "instances_0.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) finally: cmds.undoInfo(stateWithoutFlush=1) @@ -307,8 +358,10 @@ def test_node_creation_undo(self): cmds.undoInfo(stateWithoutFlush=0) try: cmds.refresh() - self.assertEqual([cubeRprim], self.getIndex()) - self.assertSnapshotEqual("instances_1.png", self.imageVersion) + self.assertIn(cubeRprim, self.getIndex()[0]) + self.assertSnapshotClose( + "instances_1.png", self.IMAGE_DIFF_FAIL_THRESHOLD, + self.IMAGE_DIFF_FAIL_PERCENT, self.imageVersion) finally: cmds.undoInfo(stateWithoutFlush=1) diff --git a/test/lib/mayaUsd/render/mayaToHydra/testStageVariants.py b/test/lib/mayaUsd/render/mayaToHydra/testStageVariants.py index 92bbecc299..afec074e63 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/testStageVariants.py +++ b/test/lib/mayaUsd/render/mayaToHydra/testStageVariants.py @@ -100,17 +100,20 @@ def test_UsdStageVariants(self): self.assertSnapshotClose("oneCubeInstanceable.png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) ufeGlobalSel.clear() - #Enable the following tests when HYDRA-820 is fixed - #modVariant.SetVariantSelection('TwoCubes') - #self.assertEqual(modVariant.GetVariantSelection(), 'TwoCubes') - #ufeGlobalSel.append(cubesItems) - #self.assertSnapshotClose("twoCubesInstanceable.png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) - #ufeGlobalSel.clear() + # At time of writing selection highlighting of native instanced prims + # does not work (HYDRA-1161). Enable the following tests when + # HYDRA-1161 is fixed. + return + modVariant.SetVariantSelection('TwoCubes') + self.assertEqual(modVariant.GetVariantSelection(), 'TwoCubes') + ufeGlobalSel.append(cubesItems) + self.assertSnapshotClose("twoCubesInstanceable.png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) + ufeGlobalSel.clear() - #modVariant.SetVariantSelection('ThreeCubes') - #self.assertEqual(modVariant.GetVariantSelection(), 'ThreeCubes') - #ufeGlobalSel.append(cubesItems) - #self.assertSnapshotClose("threeCubesInstanceable.png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) + modVariant.SetVariantSelection('ThreeCubes') + self.assertEqual(modVariant.GetVariantSelection(), 'ThreeCubes') + ufeGlobalSel.append(cubesItems) + self.assertSnapshotClose("threeCubesInstanceable.png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT) if __name__ == '__main__': fixturesUtils.runTests(globals()) diff --git a/test/testUtils/mtohUtils.py b/test/testUtils/mtohUtils.py index 79d19d630e..6310a8d45b 100644 --- a/test/testUtils/mtohUtils.py +++ b/test/testUtils/mtohUtils.py @@ -165,8 +165,14 @@ def assertInIndex(self, rprim): def assertNodeNameInIndex(self, nodeName): for rprim in self.getIndex(): if nodeName in rprim: - return True - return False + return + raise AssertionError(nodeName + ' not in index') + + def assertNodeNameNotInIndex(self, nodeName): + for rprim in self.getIndex(): + if nodeName in rprim: + raise AssertionError(nodeName + ' in index') + return def trace(self, msg): sys.__stdout__.write(msg)