Skip to content

Commit

Permalink
Merge pull request #3558 from Autodesk/bailp/EMSUSD-134/parent-select…
Browse files Browse the repository at this point in the history
…ion-test

EMSUSD-134 unit test for parent to selection
  • Loading branch information
seando-adsk authored Jan 18, 2024
2 parents e86bf80 + 216dc40 commit 6cca972
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/lib/ufe/testParentCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,51 @@ def checkParentDone():

checkParentDone()

@unittest.skipUnless(mayaUtils.ufeSupportFixLevel() >= 8, 'Requires parent command fix in Maya.')
def testParentToSelection(self):
'''
Test that the parent command with a single argument will parent to the selection.
'''
# Create scene items for the cube and the cylinder.
shapeSegment = mayaUtils.createUfePathSegment(
"|mayaUsdProxy1|mayaUsdProxyShape1")

cylinderPath = ufe.Path(
[shapeSegment, usdUtils.createUfePathSegment("/cylinderXform")])
cylinderItem = ufe.Hierarchy.createItem(cylinderPath)

def verifyInitialSetup():
'''Verify that the cube is not a child of the cylinder.'''
cylHier = ufe.Hierarchy.hierarchy(cylinderItem)
cylChildren = cylHier.children()
self.assertEqual(len(cylChildren), 1)
self.assertNotIn("cubeXform", childrenNames(cylChildren))

verifyInitialSetup()

# Parent cube to cylinder by passing the cube but not the cylinder
# while the cylinder is selected.
cmds.select("|mayaUsdProxy1|mayaUsdProxyShape1,/cylinderXform")
cmds.parent("|mayaUsdProxy1|mayaUsdProxyShape1,/cubeXform")

def verifyCubeUnderCylinder():
'''Verify that the cube is under the cylinder.'''
cylHier = ufe.Hierarchy.hierarchy(cylinderItem)
cylChildren = cylHier.children()
self.assertEqual(len(cylChildren), 2)
self.assertIn("cubeXform", childrenNames(cylChildren))

# Confirm that the cube is now a child of the cylinder.
verifyCubeUnderCylinder()

# Undo: the cube is no longer a child of the cylinder.
cmds.undo()
verifyInitialSetup()

# Redo: the cube is again a child of the cylinder.
cmds.redo()
verifyCubeUnderCylinder()

def testParentToProxyShape(self):

# Load a file with a USD hierarchy at least 2-levels deep.
Expand Down

0 comments on commit 6cca972

Please sign in to comment.