Skip to content

Commit

Permalink
Merge pull request #2057 from Autodesk/kxl-adsk/testing_coverage_for_…
Browse files Browse the repository at this point in the history
…auto_edit_and_custom_schema_updater

Add auto edit testing coverage to custom rig codeless schema test
  • Loading branch information
Krystian Ligenza authored Feb 2, 2022
2 parents e433519 + 74338a4 commit 68948d6
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 10 deletions.
7 changes: 3 additions & 4 deletions lib/mayaUsd/fileio/primUpdaterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,11 +1143,10 @@ void PrimUpdaterManager::onProxyContentChanged(
UsdMayaPrimUpdaterContext context(UsdTimeCode::Default(), stage, userArgs);

for (const auto& changedPath : notice.GetResyncedPaths()) {
if (changedPath == SdfPath::AbsoluteRootPath()) {
continue;
}
UsdPrim resyncPrim = (changedPath != SdfPath::AbsoluteRootPath())
? stage->GetPrimAtPath(changedPath)
: stage->GetPseudoRoot();

UsdPrim resyncPrim = stage->GetPrimAtPath(changedPath);
UsdPrimRange range(resyncPrim, predicate);

for (auto it = range.begin(); it != range.end(); it++) {
Expand Down
91 changes: 85 additions & 6 deletions test/lib/mayaUsd/fileio/testCustomRig.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ class customRigPrimUpdater(mayaUsdLib.PrimUpdater):
def __init__(self, *args, **kwargs):
super(customRigPrimUpdater, self).__init__(*args, **kwargs)

def shouldAutoEdit(self):
autoEditAttr = self.getUsdPrim().GetAttribute("autoEdit")
if autoEditAttr == None:
return False

return autoEditAttr.Get()

def editAsMaya(self):
return super(customRigPrimUpdater, self).editAsMaya()

Expand All @@ -74,6 +81,12 @@ class testCustomRig(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.inputPath = fixturesUtils.setUpClass(__file__)

typeName = Usd.SchemaRegistry.GetTypeFromSchemaTypeName("CustomRig").typeName

mayaUsdLib.PrimReader.Register(customRigPrimReader, typeName)
mayaUsdLib.PrimUpdater.Register(customRigPrimUpdater, typeName, "transform", customRigPrimUpdater.Supports.All.value + customRigPrimUpdater.Supports.AutoPull.value)


@classmethod
def tearDownClass(cls):
Expand Down Expand Up @@ -111,9 +124,6 @@ def testCustomRigSchema(self):
def testCustomRigReader(self):
"Validate prim reader for CustomRig codeless schema"

typeName = Usd.SchemaRegistry.GetTypeFromSchemaTypeName("CustomRig").typeName
mayaUsdLib.PrimReader.Register(customRigPrimReader, typeName)

layer = Sdf.Layer.CreateAnonymous(".usd")
layer.ImportFromString(
''' #usda 1.0
Expand All @@ -140,9 +150,6 @@ def CustomRig "bob" {
def testCustomRigUpdater(self):
"Validate prim updater for CustomRig codeless schema"

typeName = Usd.SchemaRegistry.GetTypeFromSchemaTypeName("CustomRig").typeName
mayaUsdLib.PrimUpdater.Register(customRigPrimUpdater, typeName, "transform", customRigPrimUpdater.Supports.All.value)

import mayaUsd_createStageWithNewLayer
proxyShape = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()

Expand Down Expand Up @@ -203,5 +210,77 @@ def CustomRig "bob" {
self.assertEqual(attr.GetNumTimeSamples(), 11)
self.assertEqual(attr.GetTimeSamples(), [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0])

def testCustomRigUpdaterAutoEditLoad(self):
"Validate auto edit on stage load for CustomRig codeless schema"

import mayaUsd_createStageWithNewLayer
proxyShape = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()

stage = mayaUsdUfe.getStage(proxyShape)
self.assertTrue(stage)

layer = stage.GetRootLayer()
layer.ImportFromString(
''' #sdf 1
(
defaultPrim = "world"
)
def Xform "world" {
def Xform "anim" {
def CustomRig "bob" {
int cubes = 2
bool autoEdit = 1
}
}
}
'''
)

self.assertTrue(self._GetMFnDagNode("bob|pCube1"))
self.assertTrue(self._GetMFnDagNode("bob|pCube2"))

bobPrim = stage.GetPrimAtPath("/world/anim/bob")
autoEditAttr = bobPrim.GetAttribute("autoEdit")
self.assertTrue(autoEditAttr.Get())

def testCustomRigUpdaterAutoEditChange(self):
"Validate auto edit on attr change for CustomRig codeless schema"

import mayaUsd_createStageWithNewLayer
proxyShape = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()

stage = mayaUsdUfe.getStage(proxyShape)
self.assertTrue(stage)

layer = stage.GetRootLayer()
layer.ImportFromString(
''' #sdf 1
(
defaultPrim = "world"
)
def Xform "world" {
def Xform "anim" {
def CustomRig "bob" {
int cubes = 2
bool autoEdit = 0
}
}
}
'''
)

self.assertFalse(self._GetMFnDagNode("bob|pCube1"))
self.assertFalse(self._GetMFnDagNode("bob|pCube2"))

bobPrim = stage.GetPrimAtPath("/world/anim/bob")
autoEditAttr = bobPrim.GetAttribute("autoEdit")
self.assertFalse(autoEditAttr.Get())

autoEditAttr.Set(True)
self.assertTrue(autoEditAttr.Get())

self.assertTrue(self._GetMFnDagNode("bob|pCube1"))
self.assertTrue(self._GetMFnDagNode("bob|pCube2"))

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

0 comments on commit 68948d6

Please sign in to comment.