Skip to content

Commit

Permalink
MAYA-129059 - Add a test for the createStageWithNewLayer binding.
Browse files Browse the repository at this point in the history
  • Loading branch information
frohnej-adsk committed May 4, 2023
1 parent defb109 commit 0f221dc
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/lib/ufe/testPythonWrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def setUp(self):
def testWrappers(self):

''' Verify the python wrappers.'''
cmds.file(new=True, force=True)

# Create empty stage and add a prim.
import mayaUsd_createStageWithNewLayer
Expand Down Expand Up @@ -121,6 +122,7 @@ def testWrappers(self):
# investigated as needed.
@unittest.skipUnless((mayaUtils.mayaMajorVersion() == 2023) or mayaUtils.previewReleaseVersion() >= 139, 'Only supported in Maya 2023 or greater.')
def testGetAllStages(self):
cmds.file(new=True, force=True)

# Create two stages.
import mayaUsd_createStageWithNewLayer
Expand All @@ -143,5 +145,40 @@ def testGetAllStages(self):

self.assertEqual(len(mayaUsd.ufe.getAllStages()), 1)

@unittest.skipUnless(ufeUtils.ufeFeatureSetVersion() >= 4, 'Test for UFE v4 or later')
def testCreateStageWithNewLayerBinding(self):
cmds.file(new=True, force=True)

def verifyProxyShape(proxyShapePathString):
# Verify that we got a proxy shape object.
nodeType = cmds.nodeType(proxyShapePathString)
self.assertEqual('mayaUsdProxyShape', nodeType)

# Verify that the shape node is connected to time.
self.assertTrue(cmds.isConnected('time1.outTime', proxyShapePathString+'.time'))

# Create a proxy shape under the world node.
proxy1PathString = mayaUsd.ufe.createStageWithNewLayer('|world')
verifyProxyShape(proxy1PathString)
self.assertEqual(len(mayaUsd.ufe.getAllStages()), 1)
cmds.undo()
self.assertEqual(len(mayaUsd.ufe.getAllStages()), 0)
cmds.redo()
self.assertEqual(len(mayaUsd.ufe.getAllStages()), 1)

# Create a proxy shape under a transform.
cmds.createNode('transform', skipSelect=True, name='transform1')
transformPathString = '|transform1'
transformPath = ufe.PathString.path(transformPathString)
proxy2PathString = mayaUsd.ufe.createStageWithNewLayer(transformPathString)
proxy2Path = ufe.PathString.path(proxy2PathString)
self.assertTrue(proxy2Path.startsWith(transformPath))
verifyProxyShape(proxy2PathString)
self.assertEqual(len(mayaUsd.ufe.getAllStages()), 2)
cmds.undo()
self.assertEqual(len(mayaUsd.ufe.getAllStages()), 1)
cmds.redo()
self.assertEqual(len(mayaUsd.ufe.getAllStages()), 2)

if __name__ == '__main__':
unittest.main(verbosity=2)

0 comments on commit 0f221dc

Please sign in to comment.