Skip to content

Commit

Permalink
Add test for renaming parent-compound connection
Browse files Browse the repository at this point in the history
  • Loading branch information
alicedegirolamo committed Nov 24, 2022
1 parent 7e1f565 commit dd63181
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
42 changes: 42 additions & 0 deletions test/lib/ufe/testAttributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,48 @@ def testRenamingAttribute(self):
self.assertEqual(ufe.PathString.string(dstAttr.path),
'|stage|stageShape,/pCube2/Looks/standardSurface2SG/standardSurface2')
self.assertEqual(dstAttr.name, 'inputs:base_color')

# Create the SceneItem for a compound with out connection to the parent.
ufeCompoundItem = ufeUtils.createUfeSceneItem(shapeNode,
'/pCube2/Looks/standardSurface2SG/NodeGraph1')
self.assertIsNotNone(ufeCompoundItem)

# Then create the attributes interface for that item.
compoundAttrs = ufe.Attributes.attributes(ufeCompoundItem)
self.assertIsNotNone(compoundAttrs)

# Rename the attribute.
cmd = compoundAttrs.renameAttributeCmd("outputs:out","outputs:out1")
self.assertIsNotNone(cmd)

ufeCmd.execute(cmd)

self.assertNotIn("outputs:out", compoundAttrs.attributeNames)
self.assertIn("outputs:out1", compoundAttrs.attributeNames)

# Test the connection.

ufeParentItem = ufeUtils.createUfeSceneItem(shapeNode,
'/pCube2/Looks/standardSurface2SG')
self.assertIsNotNone(ufeParentItem)

connectionHandler = ufe.RunTimeMgr.instance().connectionHandler(ufeParentItem.runTimeId())
self.assertIsNotNone(connectionHandler)
connections = connectionHandler.sourceConnections(ufeParentItem)
self.assertIsNotNone(connectionHandler)
conns = connections.allConnections()
self.assertEqual(len(conns), 2)

srcAttr = conns[1].src
dstAttr = conns[1].dst

self.assertEqual(ufe.PathString.string(srcAttr.path),
'|stage|stageShape,/pCube2/Looks/standardSurface2SG/NodeGraph1')
self.assertEqual(srcAttr.name, 'outputs:out1')

self.assertEqual(ufe.PathString.string(dstAttr.path),
'|stage|stageShape,/pCube2/Looks/standardSurface2SG')
self.assertEqual(dstAttr.name, 'outputs:out')

if __name__ == '__main__':
unittest.main(verbosity=2)
33 changes: 30 additions & 3 deletions test/testSamples/MaterialX/MayaSurfaces.usda
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,35 @@ def Mesh "pCube2" (

def Scope "Looks"
{
def Material "standardSurface2SG"
def Material "standardSurface2SG" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
string inputs:file2:varnameStr = "st"
token outputs:mtlx:surface.connect = </pCube2/Looks/standardSurface2SG/standardSurface2.outputs:surface>
token outputs:out.connect = </pCube2/Looks/standardSurface2SG/NodeGraph1.outputs:out>
uniform float2 ui:nodegraph:node:pos = (0.055555556, 0.055555556)

def Shader "standardSurface2"
def Shader "standardSurface2" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:id = "ND_standard_surface_surfaceshader"
float inputs:base = 1
color3f inputs:base_color.connect = </pCube2/Looks/standardSurface2SG/MayaNG_standardSurface2SG.outputs:baseColor>
float inputs:specular = 1
float inputs:specular_roughness = 0.4
token outputs:surface
uniform float2 ui:nodegraph:node:pos = (1.1166667, -0.33888888)
}

def NodeGraph "MayaNG_standardSurface2SG"
def NodeGraph "MayaNG_standardSurface2SG" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
string inputs:file2:varnameStr.connect = </pCube2/Looks/standardSurface2SG.inputs:file2:varnameStr>
color3f outputs:baseColor.connect = </pCube2/Looks/standardSurface2SG/MayaNG_standardSurface2SG/MayaSwizzle_file2_rgb.outputs:out>
uniform float2 ui:nodegraph:node:pos = (-0.5777778, -0.33888888)

def Shader "file2"
{
Expand Down Expand Up @@ -157,6 +167,23 @@ def Mesh "pCube2" (
color3f outputs:out
}
}

def NodeGraph "NodeGraph1" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
token outputs:out.connect = </pCube2/Looks/standardSurface2SG/NodeGraph1/surface1.outputs:out>
uniform float2 ui:nodegraph:node:pos = (1.0759555, -1.774011)

def Shader "surface1" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:id = "ND_surface"
token outputs:out
uniform float2 ui:nodegraph:node:pos = (1.0496833, -1.7418168)
}
}
}
}
}
Expand Down

0 comments on commit dd63181

Please sign in to comment.