Răsfoiți Sursa

Clarified the variables in test to be less confusing, material_graph is a graph object, material_graph_id is the ID of the graph object, material_graph_document_id is the ID of the document file that was opened (doesn't have to be a graph), the material_graph and material_graph_id derive their values from the material_graph_document_id or any document_id then the calls to create/add/remove nodes is done using the material_graph_id but NOT the document_id or material_graph_document_id. This should make the test read more clearly than before and it also fixes the issue with the connection test not passing. All tests pass now without issue.

Signed-off-by: NULL <[email protected]>
NULL 2 ani în urmă
părinte
comite
b379fc2811

+ 23 - 23
AutomatedTesting/Gem/PythonTests/Atom/atom_utils/material_canvas_utils.py

@@ -14,31 +14,31 @@ from Atom.atom_utils.atom_constants import (
     DynamicNodeManagerRequestBusEvents, GraphControllerRequestBusEvents, GraphDocumentRequestBusEvents)
     DynamicNodeManagerRequestBusEvents, GraphControllerRequestBusEvents, GraphDocumentRequestBusEvents)
 
 
 
 
-def get_graph_name(graph_document_id: math.Uuid) -> str:
+def get_graph_name(document_id: math.Uuid) -> str:
     """
     """
-    Gets the graph name of the given graph_document_id and returns it as a string.
-    :param graph_document_id: The UUID of a given graph document file.
-    :return: str representing the graph name of graph_document_id
+    Gets the graph name of the given document_id and returns it as a string.
+    :param document_id: The UUID of a given graph document file.
+    :return: str representing the graph name contained in document_id
     """
     """
-    return atomtools.GraphDocumentRequestBus(bus.Event, GraphDocumentRequestBusEvents.GET_GRAPH_NAME, graph_document_id)
+    return atomtools.GraphDocumentRequestBus(bus.Event, GraphDocumentRequestBusEvents.GET_GRAPH_NAME, document_id)
 
 
 
 
-def get_graph_id(graph_document_id: math.Uuid) -> int:
+def get_graph_id(document_id: math.Uuid) -> int:
     """
     """
-    Gets the graph ID of the given graph_document_id and returns it as an int.
-    :param graph_document_id: The UUID of a given graph document file.
-    :return: int representing the graph ID of graph_document_id
+    Gets the graph ID of the given document_id and returns it as an int.
+    :param document_id: The UUID of a given graph document file.
+    :return: int representing the graph ID of the graph contained in document_id
     """
     """
-    return atomtools.GraphDocumentRequestBus(bus.Event, GraphDocumentRequestBusEvents.GET_GRAPH_ID, graph_document_id)
+    return atomtools.GraphDocumentRequestBus(bus.Event, GraphDocumentRequestBusEvents.GET_GRAPH_ID, document_id)
 
 
 
 
-def get_graph(graph_document_id: math.Uuid) -> object:
+def get_graph(document_id: math.Uuid) -> object:
     """
     """
-    Gets the graph object of the given graph_document_id and returns it.
-    :param graph_document_id: The UUID of a given graph document file.
+    Gets the graph object of the given document_id and returns it.
+    :param document_id: The UUID of a given graph document file.
     :return: An AZStd::shared_ptr<Graph> object.
     :return: An AZStd::shared_ptr<Graph> object.
     """
     """
-    return atomtools.GraphDocumentRequestBus(bus.Event, GraphDocumentRequestBusEvents.GET_GRAPH, graph_document_id)
+    return atomtools.GraphDocumentRequestBus(bus.Event, GraphDocumentRequestBusEvents.GET_GRAPH, document_id)
 
 
 
 
 def create_node_by_name(graph: object, node_name: str) -> object:
 def create_node_by_name(graph: object, node_name: str) -> object:
@@ -53,16 +53,16 @@ def create_node_by_name(graph: object, node_name: str) -> object:
         bus.Broadcast, DynamicNodeManagerRequestBusEvents.CREATE_NODE_BY_NAME, graph, node_name)
         bus.Broadcast, DynamicNodeManagerRequestBusEvents.CREATE_NODE_BY_NAME, graph, node_name)
 
 
 
 
-def add_node(graph_document_id: math.Uuid, node: object, position: math.Vector2) -> int:
+def add_node(graph_id: math.Uuid, node: object, position: math.Vector2) -> int:
     """
     """
     Adds a node saved in memory to the current graph document at a specific position on the graph grid.
     Adds a node saved in memory to the current graph document at a specific position on the graph grid.
-    :param graph_document_id: The UUID of a given graph document file.
+    :param graph_id: int representing the ID value of a given graph AZStd::shared_ptr<Graph> object.
     :param node: An AZStd::shared_ptr<Node> object.
     :param node: An AZStd::shared_ptr<Node> object.
     :param position: math.Vector2(x,y) value that determines where to place the node on the graph grid.
     :param position: math.Vector2(x,y) value that determines where to place the node on the graph grid.
     :return: int representing the node ID of the newly placed node.
     :return: int representing the node ID of the newly placed node.
     """
     """
     return graph.GraphControllerRequestBus(
     return graph.GraphControllerRequestBus(
-        bus.Event, GraphControllerRequestBusEvents.ADD_NODE, graph_document_id, node, position)
+        bus.Event, GraphControllerRequestBusEvents.ADD_NODE, graph_id, node, position)
 
 
 
 
 def get_graph_model_slot_id(slot_name: str) -> object:
 def get_graph_model_slot_id(slot_name: str) -> object:
@@ -75,12 +75,12 @@ def get_graph_model_slot_id(slot_name: str) -> object:
 
 
 
 
 def add_connection_by_slot_id(
 def add_connection_by_slot_id(
-        graph_document_id: math.Uuid,
+        graph_id: math.Uuid,
         source_node: object, source_slot: object,
         source_node: object, source_slot: object,
         target_node: object, target_slot: object) -> object:
         target_node: object, target_slot: object) -> object:
     """
     """
     Adds a new connection between a source node slot and a target node slot.
     Adds a new connection between a source node slot and a target node slot.
-    :param graph_document_id: The UUID of a given graph document file.
+    :param graph_id: int representing the ID value of a given graph AZStd::shared_ptr<Graph> object.
     :param source_node: An AZStd::shared_ptr<Node> object representing the source node to start the connection from.
     :param source_node: An AZStd::shared_ptr<Node> object representing the source node to start the connection from.
     :param source_slot: An GraphModelSlotId object representing the slot on the source node to use for the connection.
     :param source_slot: An GraphModelSlotId object representing the slot on the source node to use for the connection.
     :param target_node: An AZStd::shared_ptr<Node> object representing the target node to end the connection to.
     :param target_node: An AZStd::shared_ptr<Node> object representing the target node to end the connection to.
@@ -88,17 +88,17 @@ def add_connection_by_slot_id(
     :return: An AZStd::shared_ptr<Connection> object.
     :return: An AZStd::shared_ptr<Connection> object.
     """
     """
     return graph.GraphControllerRequestBus(
     return graph.GraphControllerRequestBus(
-        bus.Event, GraphControllerRequestBusEvents.ADD_CONNECTION_BY_SLOT_ID, graph_document_id,
+        bus.Event, GraphControllerRequestBusEvents.ADD_CONNECTION_BY_SLOT_ID, graph_id,
         source_node, source_slot, target_node, target_slot)
         source_node, source_slot, target_node, target_slot)
 
 
 
 
 def are_slots_connected(
 def are_slots_connected(
-        graph_document_id: math.Uuid,
+        graph_id: math.Uuid,
         source_node: object, source_slot: object,
         source_node: object, source_slot: object,
         target_node: object, target_slot: object) -> bool:
         target_node: object, target_slot: object) -> bool:
     """
     """
     Determines if 2 nodes have a connection formed between them and returns a boolean for success/failure.
     Determines if 2 nodes have a connection formed between them and returns a boolean for success/failure.
-    :param graph_document_id: The UUID of a given graph document file.
+    :param graph_id: int representing the ID value of a given graph AZStd::shared_ptr<Graph> object.
     :param source_node: An AZStd::shared_ptr<Node> object representing the source node for the connection.
     :param source_node: An AZStd::shared_ptr<Node> object representing the source node for the connection.
     :param source_slot: An GraphModelSlotId object representing the slot on the source node the connection uses.
     :param source_slot: An GraphModelSlotId object representing the slot on the source node the connection uses.
     :param target_node: An AZStd::shared_ptr<Node> object representing the target node for the connection.
     :param target_node: An AZStd::shared_ptr<Node> object representing the target node for the connection.
@@ -106,5 +106,5 @@ def are_slots_connected(
     :return: bool representing success (True) or failure (False).
     :return: bool representing success (True) or failure (False).
     """
     """
     return graph.GraphControllerRequestBus(
     return graph.GraphControllerRequestBus(
-        bus.Event, GraphControllerRequestBusEvents.ARE_SLOTS_CONNECTED, graph_document_id,
+        bus.Event, GraphControllerRequestBusEvents.ARE_SLOTS_CONNECTED, graph_id,
         source_node, source_slot, target_node, target_slot)
         source_node, source_slot, target_node, target_slot)

+ 13 - 13
AutomatedTesting/Gem/PythonTests/Atom/tests/MaterialCanvas_Atom_BasicTests.py

@@ -58,11 +58,11 @@ def MaterialCanvas_BasicFunctionalityChecks_AllChecksPass():
     5) Use the CloseAllDocumentsExcept bus call to close all but one.
     5) Use the CloseAllDocumentsExcept bus call to close all but one.
     6) Verify Node Palette pane visibility.
     6) Verify Node Palette pane visibility.
     7) Verify material graph name is 'test1'.
     7) Verify material graph name is 'test1'.
-    8) Create a new material_graph from material_graph_document_id.
+    8) Create a new material_graph from material_graph_document_ids[0].
     9) Create a new world_position_node in memory.
     9) Create a new world_position_node in memory.
-    10) Add the world_position_node to the material_document_graph.
+    10) Add the world_position_node to the material_graph.
     11) Create a new standard_pbr_node in memory.
     11) Create a new standard_pbr_node in memory.
-    12) Add the standard_pbr_node to the material_document_graph.
+    12) Add the standard_pbr_node to the material_graph
     13) Create outbound_slot for our world_position_node and inbound_slot for our standard_pbr_node.
     13) Create outbound_slot for our world_position_node and inbound_slot for our standard_pbr_node.
     14) Create a node connection between world_position_node and standard_pbr_node successfully.
     14) Create a node connection between world_position_node and standard_pbr_node successfully.
     15) Look for errors and asserts.
     15) Look for errors and asserts.
@@ -141,9 +141,9 @@ def MaterialCanvas_BasicFunctionalityChecks_AllChecksPass():
             Tests.material_graph_name_is_test1,
             Tests.material_graph_name_is_test1,
             material_graph_name == "test1")
             material_graph_name == "test1")
 
 
-        # 8. Create a new material_graph from material_graph_document_id.
-        material_graph_document_id = material_graph_document_ids[0]
-        material_graph = material_canvas_utils.get_graph(material_graph_document_id)
+        # 8. Create a new material_graph from material_graph_document_ids[0].
+        material_graph = material_canvas_utils.get_graph(material_graph_document_ids[0])
+        material_graph_id = material_canvas_utils.get_graph_id(material_graph_document_ids[0])
         Report.result(
         Report.result(
             Tests.material_graph_created,
             Tests.material_graph_created,
             material_graph.typename == "AZStd::shared_ptr<Graph>" and material_graph is not None)
             material_graph.typename == "AZStd::shared_ptr<Graph>" and material_graph is not None)
@@ -154,19 +154,19 @@ def MaterialCanvas_BasicFunctionalityChecks_AllChecksPass():
             Tests.world_position_node_created,
             Tests.world_position_node_created,
             world_position_node.typename == "AZStd::shared_ptr<Node>" and world_position_node is not None)
             world_position_node.typename == "AZStd::shared_ptr<Node>" and world_position_node is not None)
 
 
-        # 10. Add the world_position_node to the material_document_graph.
+        # 10. Add the world_position_node to the material_graph.
         # This test will be verified when the nodes are connected as if it doesn't exist the connection won't be made.
         # This test will be verified when the nodes are connected as if it doesn't exist the connection won't be made.
-        material_canvas_utils.add_node(material_graph_document, world_position_node, math.Vector2(-200.0, 10.0))
+        material_canvas_utils.add_node(material_graph_id, world_position_node, math.Vector2(-200.0, 10.0))
 
 
         # 11. Create a new standard_pbr_node in memory.
         # 11. Create a new standard_pbr_node in memory.
-        standard_pbr_node = material_canvas_utils.create_node_by_name(material_graph_document, "Standard PBR")
+        standard_pbr_node = material_canvas_utils.create_node_by_name(material_graph, "Standard PBR")
         Report.result(
         Report.result(
             Tests.standard_pbr_node_created,
             Tests.standard_pbr_node_created,
             standard_pbr_node.typename == "AZStd::shared_ptr<Node>" and standard_pbr_node is not None)
             standard_pbr_node.typename == "AZStd::shared_ptr<Node>" and standard_pbr_node is not None)
 
 
-        # 12. Add the standard_pbr_node to the material_document_graph.
+        # 12. Add the standard_pbr_node to the material_graph.
         # This test will be verified when the nodes are connected as if it doesn't exist the connection won't be made.
         # This test will be verified when the nodes are connected as if it doesn't exist the connection won't be made.
-        material_canvas_utils.add_node(material_graph_document, standard_pbr_node, math.Vector2(10.0, 220.0))
+        material_canvas_utils.add_node(material_graph_id, standard_pbr_node, math.Vector2(10.0, 220.0))
 
 
         # 13. Create outbound_slot for our world_position_node and inbound_slot for our standard_pbr_node.
         # 13. Create outbound_slot for our world_position_node and inbound_slot for our standard_pbr_node.
         # This test will be verified when the nodes are connected as if it doesn't exist the connection won't be made.
         # This test will be verified when the nodes are connected as if it doesn't exist the connection won't be made.
@@ -175,9 +175,9 @@ def MaterialCanvas_BasicFunctionalityChecks_AllChecksPass():
 
 
         # 14. Create a node connection between world_position_node and standard_pbr_node successfully.
         # 14. Create a node connection between world_position_node and standard_pbr_node successfully.
         material_canvas_utils.add_connection_by_slot_id(
         material_canvas_utils.add_connection_by_slot_id(
-            material_graph_document_id, world_position_node, outbound_slot, standard_pbr_node, inbound_slot)
+            material_graph_id, world_position_node, outbound_slot, standard_pbr_node, inbound_slot)
         are_slots_connected = material_canvas_utils.are_slots_connected(
         are_slots_connected = material_canvas_utils.are_slots_connected(
-                material_graph_document_id, world_position_node, outbound_slot, standard_pbr_node, inbound_slot)
+                material_graph_id, world_position_node, outbound_slot, standard_pbr_node, inbound_slot)
         Report.result(Tests.nodes_connected, are_slots_connected is True)
         Report.result(Tests.nodes_connected, are_slots_connected is True)
 
 
         # 15. Look for errors and asserts.
         # 15. Look for errors and asserts.