TestSuite_Sandbox.py 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. import pytest
  7. import os
  8. import sys
  9. from ly_test_tools import LAUNCHERS
  10. sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../automatedtesting_shared')
  11. from base import TestAutomationBase
  12. import ly_test_tools.environment.file_system as file_system
  13. import hydra_test_utils as hydra
  14. TEST_DIRECTORY = os.path.dirname(__file__)
  15. @pytest.mark.SUITE_sandbox
  16. @pytest.mark.parametrize("launcher_platform", ['windows_editor'])
  17. @pytest.mark.parametrize("project", ["AutomatedTesting"])
  18. class TestAutomation(TestAutomationBase):
  19. def test_Opening_Closing_Pane(self, request, workspace, editor, launcher_platform):
  20. from . import Opening_Closing_Pane as test_module
  21. self._run_test(request, workspace, editor, test_module)
  22. @pytest.mark.REQUIRES_gpu
  23. @pytest.mark.SUITE_sandbox
  24. @pytest.mark.parametrize("launcher_platform", ['windows_editor'])
  25. @pytest.mark.parametrize("project", ["AutomatedTesting"])
  26. class TestAutomationQtPyTests(TestAutomationBase):
  27. def test_VariableManager_ExposeVarsToComponent(self, request, workspace, editor, launcher_platform):
  28. from . import VariableManager_ExposeVarsToComponent as test_module
  29. self._run_test(request, workspace, editor, test_module)
  30. @pytest.mark.REQUIRES_gpu
  31. @pytest.mark.SUITE_sandbox
  32. @pytest.mark.parametrize("launcher_platform", ['windows_editor'])
  33. @pytest.mark.parametrize("project", ["AutomatedTesting"])
  34. class TestAutomation(TestAutomationBase):
  35. def test_ScriptEvent_HappyPath_CreatedWithoutError(self, request, workspace, editor, launcher_platform, project):
  36. def teardown():
  37. file_system.delete(
  38. [os.path.join(workspace.paths.project(), "ScriptCanvas", "test_file.scriptevent")], True, True
  39. )
  40. request.addfinalizer(teardown)
  41. file_system.delete(
  42. [os.path.join(workspace.paths.project(), "ScriptCanvas", "test_file.scriptevent")], True, True
  43. )
  44. from . import ScriptEvent_HappyPath_CreatedWithoutError as test_module
  45. self._run_test(request, workspace, editor, test_module)
  46. @pytest.mark.SUITE_sandbox
  47. @pytest.mark.parametrize("launcher_platform", ["windows_editor"])
  48. @pytest.mark.parametrize("project", ["AutomatedTesting"])
  49. class TestScriptCanvasTests(object):
  50. """
  51. The following tests use hydra_test_utils.py to launch the editor and validate the results.
  52. """
  53. def test_ScriptEvent_AddRemoveMethod_UpdatesInSC(self, request, workspace, editor, launcher_platform):
  54. expected_lines = [
  55. "Node found in Node Palette",
  56. "Method removed from scriptevent file",
  57. ]
  58. hydra.launch_and_validate_results(
  59. request,
  60. TEST_DIRECTORY,
  61. editor,
  62. "ScriptEvent_AddRemoveMethod_UpdatesInSC.py",
  63. expected_lines,
  64. auto_test_mode=False,
  65. timeout=60,
  66. )
  67. def test_NodeCategory_ExpandOnClick(self, request, editor, launcher_platform):
  68. expected_lines = [
  69. "Script Canvas pane successfully opened",
  70. "Category expanded on left click",
  71. "Category collapsed on left click",
  72. "Category expanded on double click",
  73. "Category collapsed on double click",
  74. ]
  75. hydra.launch_and_validate_results(
  76. request,
  77. TEST_DIRECTORY,
  78. editor,
  79. "NodeCategory_ExpandOnClick.py",
  80. expected_lines,
  81. auto_test_mode=False,
  82. timeout=60,
  83. )
  84. def test_Node_HappyPath_DuplicateNode(self, request, editor, launcher_platform):
  85. expected_lines = [
  86. "Successfully duplicated node",
  87. ]
  88. hydra.launch_and_validate_results(
  89. request,
  90. TEST_DIRECTORY,
  91. editor,
  92. "Node_HappyPath_DuplicateNode.py",
  93. expected_lines,
  94. auto_test_mode=False,
  95. timeout=60,
  96. )
  97. def test_ScriptEvent_AddRemoveParameter_ActionsSuccessful(self, request, editor, launcher_platform):
  98. expected_lines = [
  99. "Success: New Script Event created",
  100. "Success: Child Event created",
  101. "Success: Successfully saved event asset",
  102. "Success: Successfully added parameter",
  103. "Success: Successfully removed parameter",
  104. ]
  105. hydra.launch_and_validate_results(
  106. request,
  107. TEST_DIRECTORY,
  108. editor,
  109. "ScriptEvent_AddRemoveParameter_ActionsSuccessful.py",
  110. expected_lines,
  111. auto_test_mode=False,
  112. timeout=60,
  113. )
  114. def test_ScriptEvents_AllParamDatatypes_CreationSuccess(self, request, workspace, editor, launcher_platform):
  115. def teardown():
  116. file_system.delete(
  117. [os.path.join(workspace.paths.project(), "TestAssets", "test_file.scriptevents")], True, True
  118. )
  119. request.addfinalizer(teardown)
  120. file_system.delete(
  121. [os.path.join(workspace.paths.project(), "TestAssets", "test_file.scriptevents")], True, True
  122. )
  123. expected_lines = [
  124. "Success: New Script Event created",
  125. "Success: Child Event created",
  126. "Success: New parameters added",
  127. "Success: Script event file saved",
  128. "Success: Node found in Script Canvas",
  129. ]
  130. hydra.launch_and_validate_results(
  131. request,
  132. TEST_DIRECTORY,
  133. editor,
  134. "ScriptEvents_AllParamDatatypes_CreationSuccess.py",
  135. expected_lines,
  136. auto_test_mode=False,
  137. timeout=60,
  138. )
  139. def test_FileMenu_Default_NewAndOpen(self, request, editor, launcher_platform):
  140. expected_lines = [
  141. "Verified no tabs open: True",
  142. "New tab opened successfully: True",
  143. "Open file window triggered successfully: True"
  144. ]
  145. hydra.launch_and_validate_results(
  146. request,
  147. TEST_DIRECTORY,
  148. editor,
  149. "FileMenu_Default_NewAndOpen.py",
  150. expected_lines,
  151. auto_test_mode=False,
  152. timeout=60,
  153. )
  154. def test_NewScriptEventButton_HappyPath_ContainsSCCategory(self, request, editor, launcher_platform):
  155. expected_lines = [
  156. "New Script event action found: True",
  157. "Asset Editor opened: True",
  158. "Asset Editor created with new asset: True",
  159. "New Script event created in Asset Editor: True",
  160. ]
  161. hydra.launch_and_validate_results(
  162. request,
  163. TEST_DIRECTORY,
  164. editor,
  165. "NewScriptEventButton_HappyPath_ContainsSCCategory.py",
  166. expected_lines,
  167. auto_test_mode=False,
  168. timeout=60,
  169. )
  170. def test_GraphClose_Default_SavePrompt(self, request, editor, launcher_platform):
  171. expected_lines = [
  172. "New graph created: True",
  173. "Save prompt opened as expected: True",
  174. "Close button worked as expected: True",
  175. ]
  176. hydra.launch_and_validate_results(
  177. request,
  178. TEST_DIRECTORY,
  179. editor,
  180. "GraphClose_Default_SavePrompt.py",
  181. expected_lines,
  182. auto_test_mode=False,
  183. timeout=160,
  184. )
  185. def test_VariableManager_Default_CreateDeleteVars(self, request, editor, launcher_platform):
  186. var_types = ["Boolean", "Color", "EntityId", "Number", "String", "Transform", "Vector2", "Vector3", "Vector4"]
  187. expected_lines = [f"{var_type} variable is created: True" for var_type in var_types]
  188. expected_lines.extend([f"{var_type} variable is deleted: True" for var_type in var_types])
  189. hydra.launch_and_validate_results(
  190. request,
  191. TEST_DIRECTORY,
  192. editor,
  193. "VariableManager_Default_CreateDeleteVars.py",
  194. expected_lines,
  195. auto_test_mode=False,
  196. timeout=60,
  197. )
  198. @pytest.mark.parametrize(
  199. "config",
  200. [
  201. {
  202. "cfg_args": "before_restart",
  203. "expected_lines": [
  204. "All the test panes are opened: True",
  205. "Test pane 1 is closed: True",
  206. "Location of test pane 2 changed successfully: True",
  207. "Test pane 3 resized successfully: True",
  208. ],
  209. },
  210. {
  211. "cfg_args": "after_restart",
  212. "expected_lines": [
  213. "Test pane retained its visiblity on Editor restart: True",
  214. "Test pane retained its location on Editor restart: True",
  215. "Test pane retained its size on Editor restart: True",
  216. ],
  217. },
  218. ],
  219. )
  220. def test_Pane_PropertiesChanged_RetainsOnRestart(self, request, editor, config, project, launcher_platform):
  221. hydra.launch_and_validate_results(
  222. request,
  223. TEST_DIRECTORY,
  224. editor,
  225. "Pane_PropertiesChanged_RetainsOnRestart.py",
  226. config.get('expected_lines'),
  227. cfg_args=[config.get('cfg_args')],
  228. auto_test_mode=False,
  229. timeout=60,
  230. )