From 3a3d897db76c6f876af282c3de5ab8ecaa91424a Mon Sep 17 00:00:00 2001 From: anugshya Date: Thu, 6 May 2021 15:07:35 +0530 Subject: [PATCH 1/5] test_ScriptEvents_ReturnSetTypeSuccessfully --- .../ScriptEvents_ReturnSetTypeSuccessfully.py | 110 + .../PythonTests/scripting/TestSuite_Active.py | 12 + .../T92569006_ScriptCanvas.scriptcanvas | 1952 +++++++++++++++++ .../TestAssets/T92569006.scriptevents | 126 ++ 4 files changed, 2200 insertions(+) create mode 100644 AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py create mode 100644 AutomatedTesting/ScriptCanvas/T92569006_ScriptCanvas.scriptcanvas create mode 100644 AutomatedTesting/TestAssets/T92569006.scriptevents diff --git a/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py new file mode 100644 index 0000000000..63f4223872 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py @@ -0,0 +1,110 @@ +""" +All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +its licensors. + +For complete copyright and license terms please see the LICENSE at the root of this +distribution (the "License"). All use of this software is governed by the License, +or, if provided, by the license below or the license accompanying this file. Do not +remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +Test case ID: T92569006 +Test Case Title: Event can return a value of set type successfully +URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92569006 +""" + + +# fmt: off +class Tests(): + level_created = ("Successfully created temporary level", "Failed to create temporary level") + entity_created = ("Successfully created test entity", "Failed to create test entity") + enter_game_mode = ("Successfully entered game mode", "Failed to enter game mode") + lines_found = ("Successfully found expected message", "Failed to find expected message") + exit_game_mode = ("Successfully exited game mode", "Failed to exit game mode") +# fmt: on + + +def ScriptEvents_ReturnSetTypeSuccessfully(): + """ + Summary: + An entity exists in the level that contains a Script Canvas component. In the graph is both a Send Event + and a Receive Event. + + Expected Behavior: + After entering game mode the graph on the entity should print an expected message to the console + + Test Steps: + 1) Create test level + 2) Create test entity + 3) Start Tracer + 4) Enter Game Mode + 5) Read for line + 6) Exit Game Mode + + Note: + - This test file must be called from the Open 3D Engine Editor command terminal + - Any passed and failed tests are written to the Editor.log file. + Parsing the file or running a log_monitor are required to observe the test results. + + :return: None + """ + import os + from editor_entity_utils import EditorEntity as Entity + from utils import Report + from utils import TestHelper as helper + from utils import Tracer + + import azlmbr.legacy.general as general + import azlmbr.asset as asset + import azlmbr.math as math + import azlmbr.bus as bus + + LEVEL_NAME = "tmp_level" + WAIT_TIME = 3.0 # SECONDS + EXPECTED_LINES = ["T92569006_ScriptEvent_Sent", "T92569006_ScriptEvent_Sent"] + SC_ASSET_PATH = os.path.join("ScriptCanvas", "T92569006_ScriptCanvas.scriptcanvas") + + def create_editor_entity(name, sc_asset): + entity = Entity.create_editor_entity(name) + sc_comp = entity.add_component("Script Canvas") + asset_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", sc_asset, math.Uuid(), False) + sc_comp.set_component_property_value("Script Canvas Asset|Script Canvas Asset", asset_id) + Report.critical_result(Tests.entity_created, entity.id.isValid()) + + def locate_expected_lines(line_list: list): + found_lines = [printInfo.message.strip() for printInfo in section_tracer.prints] + + return all(line in found_lines for line in line_list) + + # 1) Create temp level + general.idle_enable(True) + result = general.create_level_no_prompt(LEVEL_NAME, 128, 1, 512, True) + Report.critical_result(Tests.level_created, result == 0) + helper.wait_for_condition(lambda: general.get_current_level_name() == LEVEL_NAME, WAIT_TIME) + general.close_pane("Error Report") + + # 2) Create test entity + create_editor_entity("TestEntity", SC_ASSET_PATH) + + # 3) Start Tracer + with Tracer() as section_tracer: + + # 4) Enter Game Mode + helper.enter_game_mode(Tests.enter_game_mode) + + # 5) Read for line + lines_located = helper.wait_for_condition(lambda: locate_expected_lines(EXPECTED_LINES), WAIT_TIME) + Report.result(Tests.lines_found, lines_located) + + # 6) Exit Game Mode + helper.exit_game_mode(Tests.exit_game_mode) + + +if __name__ == "__main__": + import ImportPathHelper as imports + + imports.init() + + from utils import Report + + Report.start_test(ScriptEvents_ReturnSetTypeSuccessfully) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py index d87f2986bf..9cc906bec9 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py @@ -21,6 +21,7 @@ import hydra_test_utils as hydra import ly_test_tools.environment.file_system as file_system from ly_test_tools import LAUNCHERS from base import TestAutomationBase +import ly_test_tools.environment.process_utils as process_utils TEST_DIRECTORY = os.path.dirname(__file__) @@ -183,6 +184,17 @@ class TestAutomation(TestAutomationBase): from . import ScriptEvents_SendReceiveSuccessfully as test_module self._run_test(request, workspace, editor, test_module) + @pytest.mark.test_case_id("T92569006") + @pytest.mark.parametrize("level", ["tmp_level"]) + def test_ScriptEvents_ReturnSetTypeSuccessfully(self, request, workspace, editor, launcher_platform, project, level): + def teardown(): + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + request.addfinalizer(teardown) + file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) + from . import ScriptEvents_ReturnSetTypeSuccessfully as test_module + self._run_test(request, workspace, editor, test_module) + + # NOTE: We had to use hydra_test_utils.py, as TestAutomationBase run_test method # fails because of pyside_utils import @pytest.mark.SUITE_periodic diff --git a/AutomatedTesting/ScriptCanvas/T92569006_ScriptCanvas.scriptcanvas b/AutomatedTesting/ScriptCanvas/T92569006_ScriptCanvas.scriptcanvas new file mode 100644 index 0000000000..626ee29d96 --- /dev/null +++ b/AutomatedTesting/ScriptCanvas/T92569006_ScriptCanvas.scriptcanvas @@ -0,0 +1,1952 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutomatedTesting/TestAssets/T92569006.scriptevents b/AutomatedTesting/TestAssets/T92569006.scriptevents new file mode 100644 index 0000000000..518b1b5733 --- /dev/null +++ b/AutomatedTesting/TestAssets/T92569006.scriptevents @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c9c2aa73676d3140e112d9d7f6719e96529f2bba Mon Sep 17 00:00:00 2001 From: anugshya Date: Thu, 6 May 2021 15:51:58 +0530 Subject: [PATCH 2/5] Fixed expected lines --- .../scripting/ScriptEvents_ReturnSetTypeSuccessfully.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py index 63f4223872..a60dfec962 100644 --- a/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py @@ -44,7 +44,7 @@ def ScriptEvents_ReturnSetTypeSuccessfully(): Note: - This test file must be called from the Open 3D Engine Editor command terminal - Any passed and failed tests are written to the Editor.log file. - Parsing the file or running a log_monitor are required to observe the test results. + Parsing the file or running a log_monitor are required to observe the test results. :return: None """ @@ -61,7 +61,7 @@ def ScriptEvents_ReturnSetTypeSuccessfully(): LEVEL_NAME = "tmp_level" WAIT_TIME = 3.0 # SECONDS - EXPECTED_LINES = ["T92569006_ScriptEvent_Sent", "T92569006_ScriptEvent_Sent"] + EXPECTED_LINES = ["T92569006_ScriptEvent_Sent", "T92569006_ScriptEvent_Received"] SC_ASSET_PATH = os.path.join("ScriptCanvas", "T92569006_ScriptCanvas.scriptcanvas") def create_editor_entity(name, sc_asset): From 8704383f0e8c381cf6049065f475e8a67d6e1f24 Mon Sep 17 00:00:00 2001 From: anugshya Date: Thu, 6 May 2021 21:00:57 +0530 Subject: [PATCH 3/5] fixed review comments --- .../scripting/ScriptEvents_ReturnSetTypeSuccessfully.py | 6 +++--- .../Gem/PythonTests/scripting/TestSuite_Active.py | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py index a60dfec962..b131d3beb5 100644 --- a/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py @@ -27,11 +27,11 @@ class Tests(): def ScriptEvents_ReturnSetTypeSuccessfully(): """ Summary: - An entity exists in the level that contains a Script Canvas component. In the graph is both a Send Event - and a Receive Event. + An entity exists in the level that contains a Script Canvas component. And verify that Script Event's send and + receive nodes return the set value succesfully. Expected Behavior: - After entering game mode the graph on the entity should print an expected message to the console + After entering game mode, the graph on the entity should print an expected message to the console Test Steps: 1) Create test level diff --git a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py index 9cc906bec9..ccf5e6b9a9 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py @@ -21,7 +21,6 @@ import hydra_test_utils as hydra import ly_test_tools.environment.file_system as file_system from ly_test_tools import LAUNCHERS from base import TestAutomationBase -import ly_test_tools.environment.process_utils as process_utils TEST_DIRECTORY = os.path.dirname(__file__) From 63728dbc6eab70ceb1731f14d862f817e427ac44 Mon Sep 17 00:00:00 2001 From: anugshya Date: Fri, 7 May 2021 19:12:19 +0530 Subject: [PATCH 4/5] Updated code as per standards --- ... ScriptEvents_ReturnSetType_Successfully.py} | 17 ++++++++++------- .../PythonTests/scripting/TestSuite_Active.py | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) rename AutomatedTesting/Gem/PythonTests/scripting/{ScriptEvents_ReturnSetTypeSuccessfully.py => ScriptEvents_ReturnSetType_Successfully.py} (83%) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetType_Successfully.py similarity index 83% rename from AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py rename to AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetType_Successfully.py index b131d3beb5..ab1d05b4c4 100644 --- a/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetTypeSuccessfully.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetType_Successfully.py @@ -9,8 +9,7 @@ remove or modify any license notices. This file is distributed on an "AS IS" BAS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Test case ID: T92569006 -Test Case Title: Event can return a value of set type successfully -URL of the test case: https://testrail.agscollab.com/index.php?/tests/view/92569006 +Test Case Title: Event can return a value of set type successfully """ @@ -24,11 +23,15 @@ class Tests(): # fmt: on -def ScriptEvents_ReturnSetTypeSuccessfully(): +def ScriptEvents_ReturnSetType_Successfully(): """ - Summary: - An entity exists in the level that contains a Script Canvas component. And verify that Script Event's send and - receive nodes return the set value succesfully. + Summary: A temporary level is created with an Entity having ScriptCanvas component. + ScriptEvent(T92569006_ScriptEvent.scriptevents) is created with one Method that has a return value. + ScriptCanvas(T92569006_ScriptCanvas.scriptcanvas) is attached to Entity. Graph has Send node that sends the Method + of the ScriptEvent and prints the returned result ( On Entity Activated -> Send node -> Print) and Receive node is + set to return custom value ( Receive node -> Print). + Verify that the entity containing T92569006_ScriptCanvas.scriptcanvas should print the custom value set in both + Send and Receive nodes. Expected Behavior: After entering game mode, the graph on the entity should print an expected message to the console @@ -107,4 +110,4 @@ if __name__ == "__main__": from utils import Report - Report.start_test(ScriptEvents_ReturnSetTypeSuccessfully) + Report.start_test(ScriptEvents_ReturnSetType_Successfully) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py index ccf5e6b9a9..aadd80980a 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py @@ -185,12 +185,12 @@ class TestAutomation(TestAutomationBase): @pytest.mark.test_case_id("T92569006") @pytest.mark.parametrize("level", ["tmp_level"]) - def test_ScriptEvents_ReturnSetTypeSuccessfully(self, request, workspace, editor, launcher_platform, project, level): + def test_ScriptEvents_ReturnSetType_Successfully(self, request, workspace, editor, launcher_platform, project, level): def teardown(): file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) request.addfinalizer(teardown) file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) - from . import ScriptEvents_ReturnSetTypeSuccessfully as test_module + from . import ScriptEvents_ReturnSetType_Successfully as test_module self._run_test(request, workspace, editor, test_module) From 570f7a65ca91dd3f97a41dff7488e85125efc795 Mon Sep 17 00:00:00 2001 From: anugshya Date: Fri, 7 May 2021 20:04:06 +0530 Subject: [PATCH 5/5] Fixed review comments --- .../scripting/ScriptEvents_ReturnSetType_Successfully.py | 1 - AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py | 1 - 2 files changed, 2 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetType_Successfully.py b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetType_Successfully.py index ab1d05b4c4..aa9abd110b 100644 --- a/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetType_Successfully.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/ScriptEvents_ReturnSetType_Successfully.py @@ -8,7 +8,6 @@ or, if provided, by the license below or the license accompanying this file. Do remove or modify any license notices. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -Test case ID: T92569006 Test Case Title: Event can return a value of set type successfully """ diff --git a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py index aadd80980a..152dea93cd 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Active.py @@ -183,7 +183,6 @@ class TestAutomation(TestAutomationBase): from . import ScriptEvents_SendReceiveSuccessfully as test_module self._run_test(request, workspace, editor, test_module) - @pytest.mark.test_case_id("T92569006") @pytest.mark.parametrize("level", ["tmp_level"]) def test_ScriptEvents_ReturnSetType_Successfully(self, request, workspace, editor, launcher_platform, project, level): def teardown():