-
Notifications
You must be signed in to change notification settings - Fork 202
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
Add tests for sets command and for isolate select in Vp2RenderDelegate. #1678
Merged
kxl-adsk
merged 4 commits into
dev
from
krickw/MAYA-113057/isolate_select_regression_tests
Sep 22, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+7.2 KB
...p2RenderDelegate/VP2RenderDelegateIsolateSelectTest/baseline/capsuleAndCube.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.68 KB
...rDelegate/VP2RenderDelegateIsolateSelectTest/baseline/capsuleAndCubeAndCone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.18 KB
...d/render/vp2RenderDelegate/VP2RenderDelegateIsolateSelectTest/baseline/cube.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.5 KB
...nder/vp2RenderDelegate/VP2RenderDelegateIsolateSelectTest/baseline/cylinder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.35 KB
...gate/VP2RenderDelegateIsolateSelectTest/baseline/cylinderAfterCapsuleRemove.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.34 KB
...nderDelegate/VP2RenderDelegateIsolateSelectTest/baseline/cylinderAndCapsule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.5 KB
...RenderDelegate/VP2RenderDelegateIsolateSelectTest/baseline/isolateSelectOff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.35 KB
...enderDelegate/VP2RenderDelegateIsolateSelectTest/baseline/redoCapsuleRemove.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.42 KB
...p2RenderDelegate/VP2RenderDelegateIsolateSelectTest/baseline/reparentedCube.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.39 KB
...nderDelegate/VP2RenderDelegateIsolateSelectTest/baseline/reparentedCubeBack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.71 KB
...erDelegate/VP2RenderDelegateIsolateSelectTest/baseline/reparentedProxyShape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.35 KB
...p2RenderDelegate/VP2RenderDelegateIsolateSelectTest/baseline/undoCapsuleAdd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.34 KB
...enderDelegate/VP2RenderDelegateIsolateSelectTest/baseline/undoCapsuleRemove.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.8 KB
...er/vp2RenderDelegate/VP2RenderDelegateIsolateSelectTest/baseline/unselected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
160 changes: 160 additions & 0 deletions
160
test/lib/mayaUsd/render/vp2RenderDelegate/testVP2RenderDelegateIsolateSelect.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
#!/usr/bin/env mayapy | ||
# | ||
# Copyright 2021 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 fixturesUtils | ||
import imageUtils | ||
import mayaUtils | ||
import unittest | ||
import usdUtils | ||
import testUtils | ||
|
||
from mayaUsd import lib as mayaUsdLib | ||
from mayaUsd import ufe as mayaUsdUfe | ||
|
||
from maya import cmds | ||
import maya.api.OpenMayaRender as omr | ||
|
||
from pxr import Usd | ||
|
||
import ufe | ||
|
||
import os | ||
|
||
|
||
class testVP2RenderDelegateIsolateSelect(imageUtils.ImageDiffingTestCase): | ||
""" | ||
Tests imaging using the Viewport 2.0 render delegate when using per-instance | ||
inherited data on instances. | ||
""" | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
inputPath = fixturesUtils.setUpClass(__file__, | ||
initializeStandalone=False, loadPlugin=False) | ||
|
||
cls._baselineDir = os.path.join(inputPath, | ||
'VP2RenderDelegateIsolateSelectTest', 'baseline') | ||
|
||
cls._testDir = os.path.abspath('.') | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
panel = mayaUtils.activeModelPanel() | ||
cmds.modelEditor(panel, edit=True, useDefaultMaterial=False) | ||
|
||
def assertSnapshotClose(self, imageName): | ||
cmds.undoInfo(stateWithoutFlush=False) # disable the undo queue during the snapshot | ||
baselineImage = os.path.join(self._baselineDir, imageName) | ||
snapshotImage = os.path.join(self._testDir, imageName) | ||
imageUtils.snapshot(snapshotImage, width=960, height=540) | ||
retVal = self.assertImagesClose(baselineImage, snapshotImage) | ||
cmds.undoInfo(stateWithoutFlush=True) | ||
return retVal | ||
|
||
def testIsolateSelect(self): | ||
cmds.file(force=True, new=True) | ||
mayaUtils.loadPlugin("mayaUsdPlugin") | ||
panel = mayaUtils.activeModelPanel() | ||
usdaFile = testUtils.getTestScene("setsCmd", "5prims.usda") | ||
proxyDagPath, sphereStage = mayaUtils.createProxyFromFile(usdaFile) | ||
usdCube = proxyDagPath + ",/Cube1" | ||
usdCylinder = proxyDagPath + ",/Cylinder1" | ||
usdCapsule = proxyDagPath + ",/Capsule1" | ||
usdCone = proxyDagPath + ",/Cone1" | ||
usdXform = proxyDagPath + ",/Xform1" | ||
|
||
cmds.move(-4, -24, 0, "persp") | ||
cmds.rotate(90, 0, 0, "persp") | ||
|
||
globalSelection = ufe.GlobalSelection.get() | ||
globalSelection.clear() | ||
self.assertSnapshotClose('unselected.png') | ||
|
||
# Turn on isolate select for cube | ||
cmds.select(usdCube) | ||
cmds.isolateSelect("modelPanel4", state=1) | ||
self.assertSnapshotClose('cube.png') | ||
|
||
# Replace isolate select cube with cylinder | ||
cmds.select(usdCylinder) | ||
cmds.isolateSelect("modelPanel4", loadSelected=True) | ||
self.assertSnapshotClose('cylinder.png') | ||
|
||
# Add capsule to isolate select | ||
cmds.select(usdCapsule) | ||
cmds.isolateSelect("modelPanel4", addSelected=True) | ||
self.assertSnapshotClose('cylinderAndCapsule.png') | ||
|
||
# Remove capsule from isolate select | ||
cmds.isolateSelect("modelPanel4", removeSelected=True) | ||
self.assertSnapshotClose('cylinderAfterCapsuleRemove.png') | ||
|
||
# Undo, Redo | ||
cmds.undo() # Undo remove capsule from isolate select | ||
self.assertSnapshotClose('undoCapsuleRemove.png') | ||
cmds.redo() # Redo remove capsule from isolate select | ||
self.assertSnapshotClose('redoCapsuleRemove.png') | ||
cmds.undo() # Undo remove capsule from isolate select | ||
cmds.undo() # Undo add capsule to isolate select | ||
self.assertSnapshotClose('undoCapsuleAdd.png') | ||
|
||
# Turn off isolate select | ||
cmds.isolateSelect("modelPanel4", state=0) | ||
self.assertSnapshotClose('isolateSelectOff.png') | ||
|
||
# Create an isolate select set, then add something directly to it | ||
cmds.isolateSelect("modelPanel4", state=1) | ||
isolateSelectSet = "modelPanel4ViewSelectedSet" | ||
cmds.sets(usdCube, add=isolateSelectSet) | ||
cmds.isolateSelect("modelPanel4", update=True) | ||
self.assertSnapshotClose('capsuleAndCube.png') | ||
|
||
# The flags addDagObject and removeDagObject don't | ||
# work with USD items. | ||
|
||
# Add the cone to the isolate select | ||
# different from addSelected because it filters out components | ||
cmds.select(usdCone) | ||
cmds.isolateSelect("modelPanel4", addSelectedObjects=True) | ||
self.assertSnapshotClose('capsuleAndCubeAndCone.png') | ||
|
||
# Translate Xform1 and reparent Cube1 under Xform1 | ||
cmds.select(usdXform) | ||
cmds.move( 0, 0, 1, relative=True) | ||
cmds.select(clear=True) | ||
cmds.parent(usdCube, usdXform, relative=True) | ||
cmds.isolateSelect("modelPanel4", update=True) | ||
usdCube = usdXform + "/Cube1" | ||
self.assertSnapshotClose('reparentedCube.png') | ||
|
||
# Reparent Cube1 back | ||
cmds.parent(usdCube, proxyDagPath, relative=True) | ||
cmds.isolateSelect("modelPanel4", update=True) | ||
usdCube = proxyDagPath + ",/Cube1" | ||
self.assertSnapshotClose('reparentedCubeBack.png') | ||
|
||
#reparent the proxy shape | ||
locatorShape = cmds.createNode("locator") | ||
locator = "|" + cmds.listRelatives(locatorShape, parent=True)[0] | ||
cmds.move( 0, 0, 5, locator) | ||
cmds.parent("|stage", locator, relative=True) | ||
usdCube = locator + usdCube | ||
self.assertSnapshotClose('reparentedProxyShape.png') | ||
|
||
|
||
if __name__ == '__main__': | ||
fixturesUtils.runTests(globals()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#!/usr/bin/env python | ||
|
||
# | ||
# Copyright 2021 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 fixturesUtils | ||
import mayaUtils | ||
import testUtils | ||
|
||
from maya import cmds | ||
from maya import standalone | ||
|
||
import unittest | ||
|
||
|
||
class SetsCmdTestCase(unittest.TestCase): | ||
'''Verify the Maya sets command | ||
''' | ||
|
||
pluginsLoaded = False | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
fixturesUtils.readOnlySetUpClass(__file__, loadPlugin=False) | ||
|
||
if not cls.pluginsLoaded: | ||
cls.pluginsLoaded = mayaUtils.isMayaUsdPluginLoaded() | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
standalone.uninitialize() | ||
|
||
def setUp(self): | ||
''' Called initially to set up the Maya test environment ''' | ||
# Load plugins | ||
self.assertTrue(self.pluginsLoaded) | ||
|
||
# Clear selection to start off | ||
cmds.select(clear=True) | ||
|
||
def testSetsCmd(self): | ||
usdaFile = testUtils.getTestScene("setsCmd", "5prims.usda") | ||
proxyDagPath, sphereStage = mayaUtils.createProxyFromFile(usdaFile) | ||
usdCube = proxyDagPath + ",/Cube1" | ||
usdCylinder = proxyDagPath + ",/Cylinder1" | ||
usdXform = proxyDagPath + ",/Xform1" | ||
|
||
cmds.select(usdCube) | ||
set1 = cmds.sets() | ||
cmds.select(usdCylinder) | ||
set2 = cmds.sets() | ||
|
||
# set contents | ||
self.assertEqual(usdCube, *cmds.sets( set1, q=True )) | ||
|
||
# select set | ||
cmds.select( set1 ) | ||
self.assertEqual(usdCube, *cmds.ls( selection=True, ufe=True )) | ||
|
||
# set of sets | ||
setOfSets = cmds.sets( set1, set2, n="setOfSets") | ||
cmds.select( setOfSets ) | ||
self.assertEqual([usdCube, usdCylinder], sorted(cmds.ls( selection=True, ufe=True))) | ||
|
||
# union of the sets | ||
self.assertEqual([usdCube, usdCylinder], sorted(cmds.sets( set2, un=set1 ))) | ||
self.assertFalse(cmds.sets( set2, ii=set1 )) # do the sets have common members | ||
|
||
# query set contents, remove from set, add to set | ||
self.assertTrue(cmds.sets( usdCube, im=set1 )) # Test if Cube1 is in set1 | ||
self.assertFalse(cmds.sets( usdCube, im=set2 )) # Test if Cube1 is in set2 | ||
cmds.sets( usdCube, rm=set1 ) # Remove Cube1 from set1 | ||
self.assertFalse(cmds.sets( usdCube, im=set1 )) # Test if Cube1 is in set1 | ||
cmds.sets( usdCube, add=set1 ) # Add Cube1 to set1 | ||
self.assertTrue(cmds.sets( usdCube, im=set1 )) # Test if Cube1 is in set1 | ||
|
||
# Undo, Redo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like redo() never actually made it into the file :) |
||
cmds.undo() # Undo Add Cube1 to set1 | ||
self.assertFalse(cmds.sets( usdCube, im=set1 )) | ||
cmds.redo() # Redo Add Cube1 to set1 | ||
self.assertTrue(cmds.sets( usdCube, im=set1 )) | ||
cmds.undo() # Undo Add Cube1 to set1 | ||
self.assertFalse(cmds.sets( usdCube, im=set1 )) | ||
cmds.undo() # Undo Remove Cube1 from set1 | ||
self.assertTrue(cmds.sets( usdCube, im=set1 )) | ||
|
||
#reparent Cube1 under Xform1 | ||
cmds.parent(usdCube, usdXform, relative=True) | ||
usdCube = usdXform + "/Cube1" | ||
self.assertTrue(cmds.sets( usdCube, im=set1 )) # Test if Cube1 is in set1 | ||
cmds.parent(usdCube, proxyDagPath, relative=True) | ||
usdCube = proxyDagPath + ",/Cube1" | ||
self.assertTrue(cmds.sets( usdCube, im=set1 )) # Test if Cube1 is in set1 | ||
|
||
#reparent the proxy shape | ||
locatorShape = cmds.createNode("locator") | ||
locator = "|" + cmds.listRelatives(locatorShape, parent=True)[0] | ||
cmds.parent("|stage", locator, relative=True) | ||
usdCube = locator + usdCube | ||
self.assertTrue(cmds.sets( usdCube, im=set1 )) # Test if Cube1 is in set1 | ||
|
||
if __name__ == '__main__': | ||
unittest.main(verbosity=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#usda 1.0 | ||
|
||
reorder rootPrims = ["Capsule1", "Cone1", "Cube1", "Cylinder1", "Sphere1", "Xform1"] | ||
|
||
def Capsule "Capsule1" | ||
{ | ||
double3 xformOp:translate = (-13.855604588157764, 0, 0) | ||
uniform token[] xformOpOrder = ["xformOp:translate"] | ||
} | ||
|
||
def Cone "Cone1" | ||
{ | ||
double3 xformOp:translate = (-8.725335979971176, 0, 0) | ||
uniform token[] xformOpOrder = ["xformOp:translate"] | ||
} | ||
|
||
def Cylinder "Cylinder1" | ||
{ | ||
double3 xformOp:translate = (1.7859601980783193, 0, 0) | ||
uniform token[] xformOpOrder = ["xformOp:translate"] | ||
} | ||
|
||
def Sphere "Sphere1" | ||
{ | ||
double3 xformOp:translate = (6.180355031854263, 0, 0) | ||
uniform token[] xformOpOrder = ["xformOp:translate"] | ||
} | ||
|
||
def Xform "Xform1" | ||
{ | ||
} | ||
|
||
def Cube "Cube1" | ||
{ | ||
float3 xformOp:rotateXYZ = (0, -0, 0) | ||
float3 xformOp:scale = (1, 1, 1) | ||
double3 xformOp:translate = (-2.1084769730574147, 0, 0) | ||
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this function use the result of
mayaUtils.activeModelPanel()
as first parameter? Would it make the test more robust?