Skip to content

Commit

Permalink
Merge pull request #868 from marsupial/PR/cmake-subproject-tests
Browse files Browse the repository at this point in the history
[CMake] Add mayaUtils.openTestScene and mayaUtils.getTestScene
  • Loading branch information
Krystian Ligenza authored Oct 27, 2020
2 parents 10834d8 + eea17d9 commit 0ded116
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
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

0 comments on commit 0ded116

Please sign in to comment.