Skip to content
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

[CMake] Add mayaUtils.openTestScene and mayaUtils.getTestScene #868

Merged
merged 1 commit into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions test/lib/ufe/testParentCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def __init__(self, fileName):
self._fileName = fileName

def __enter__(self):
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../..", "testSamples", "parentCmd", self._fileName)
cmds.file(filePath, force=True, open=True)
mayaUtils.openTestScene("parentCmd", self._fileName)

def __exit__(self, type, value, traceback):
# Close the file.
Expand All @@ -69,8 +68,7 @@ def setUp(self):

# Load a file that has the same scene in both the Maya Dag
# hierarchy and the USD hierarchy.
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../..", "testSamples", "parentCmd", "simpleSceneMayaPlusUSD_TRS.ma" )
cmds.file(filePath, force=True, open=True)
mayaUtils.openTestScene("parentCmd", "simpleSceneMayaPlusUSD_TRS.ma" )

# Clear selection to start off
cmds.select(clear=True)
Expand Down Expand Up @@ -426,7 +424,7 @@ def testUnparentMultiStage(self):
# opened file. Layers are then shared between the stages, because
# they come from the same USD file, causing changes done below one
# proxy shape to be seen in the other. Import from another file.
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../..", "testSamples", "parentCmd", "simpleSceneUSD_TRS.ma")
filePath = mayaUtils.getTestScene("parentCmd", "simpleSceneUSD_TRS.ma")
cmds.file(filePath, i=True)

# Unparent a USD node in each stage. Unparenting Lambert node is
Expand Down
3 changes: 1 addition & 2 deletions test/lib/ufe/testSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def setUp(self):

# Load a file that has the same scene in both the Maya Dag
# hierarchy and the USD hierarchy.
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../..", "testSamples", "parentCmd", "simpleSceneMayaPlusUSD_TRS.ma" )
cmds.file(filePath, force=True, open=True)
mayaUtils.openTestScene("parentCmd", "simpleSceneMayaPlusUSD_TRS.ma")

# Clear selection to start off
cmds.select(clear=True)
Expand Down
31 changes: 15 additions & 16 deletions test/testUtils/mayaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ def getMayaSelectionList():
else:
return [x for x in cmds.ls(sl=True)]

def getTestScene(*args):
return os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "testSamples", *args)

def openTestScene(*args):
filePath = getTestScene(*args)
cmds.file(filePath, force=True, open=True)

def openTopLayerScene():
'''
The test scene hierarchy is represented as :
Expand All @@ -133,36 +140,28 @@ def openTopLayerScene():
/Ball_35
'''
# Open top_layer file which contains the USD scene
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "testSamples", "ballset", "StandaloneScene", "top_layer.ma" )
cmds.file(filePath, force=True, open=True)
return openTestScene("ballset", "StandaloneScene", "top_layer.ma" )

def openCylinderScene():
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "testSamples", "cylinder", "usdCylinder.ma" )
cmds.file(filePath, force=True, open=True)
return openTestScene("cylinder", "usdCylinder.ma" )

def openTwoSpheresScene():
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "testSamples", "twoSpheres", "twoSpheres.ma" )
cmds.file(filePath, force=True, open=True)
return openTestScene("twoSpheres", "twoSpheres.ma" )

def openSphereAnimatedRadiusScene():
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "testSamples", "sphereAnimatedRadius", "sphereAnimatedRadiusProxyShape.ma" )
cmds.file(filePath, force=True, open=True)
return openTestScene("sphereAnimatedRadius", "sphereAnimatedRadiusProxyShape.ma" )

def openTreeScene():
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "testSamples", "tree", "tree.ma" )
cmds.file(filePath, force=True, open=True)
return openTestScene("tree", "tree.ma" )

def openTreeRefScene():
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "testSamples", "tree", "treeRef.ma" )
cmds.file(filePath, force=True, open=True)
return openTestScene("tree", "treeRef.ma" )

def openAppleBiteScene():
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "testSamples", "appleBite", "appleBite.ma" )
cmds.file(filePath, force=True, open=True)
return openTestScene("appleBite", "appleBite.ma" )

def openGroupBallsScene():
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "testSamples", "groupBalls", "ballset.ma" )
cmds.file(filePath, force=True, open=True)
return openTestScene("groupBalls", "ballset.ma" )

def createProxyAndStage():
"""
Expand Down