TestSuite_Main_GPU.py 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 logging
  7. import os
  8. import pytest
  9. import editor_python_test_tools.hydra_test_utils as hydra
  10. import ly_test_tools.environment.file_system as file_system
  11. from ly_test_tools.o3de.editor_test import EditorSingleTest, EditorTestSuite, EditorBatchedTest
  12. from Atom.atom_utils.atom_component_helper import compare_screenshot_to_golden_image, golden_images_directory
  13. DEFAULT_SUBFOLDER_PATH = 'user/PythonTests/Automated/Screenshots'
  14. logger = logging.getLogger(__name__)
  15. @pytest.mark.parametrize("project", ["AutomatedTesting"])
  16. @pytest.mark.parametrize("launcher_platform", ['windows_editor'])
  17. class TestAutomation(EditorTestSuite):
  18. # Remove -BatchMode from global_extra_cmdline_args since we need rendering for these tests.
  19. global_extra_cmdline_args = ["-autotest_mode"] # Default is ["-BatchMode", "-autotest_mode"]
  20. use_null_renderer = False # Default is True
  21. @staticmethod
  22. def screenshot_setup(screenshot_directory, screenshot_names):
  23. """
  24. :param screenshot_names: list of screenshot file names with extensions
  25. :return: tuple test_screenshots, golden_images each a list of full file paths
  26. """
  27. test_screenshots = []
  28. golden_images = []
  29. for screenshot in screenshot_names:
  30. screenshot_path = os.path.join(screenshot_directory, screenshot)
  31. test_screenshots.append(screenshot_path)
  32. file_system.delete(test_screenshots, True, True)
  33. for golden_image in screenshot_names:
  34. golden_image_path = os.path.join(golden_images_directory(), golden_image)
  35. golden_images.append(golden_image_path)
  36. return test_screenshots, golden_images
  37. @pytest.mark.test_case_id("C34525095")
  38. class AtomGPU_LightComponent_AreaLightScreenshotsMatchGoldenImages_DX12(EditorSingleTest):
  39. from Atom.tests import hydra_AtomGPU_AreaLightScreenshotTest as test_module
  40. extra_cmdline_args = ["-rhi=dx12"]
  41. # Custom setup/teardown to remove old screenshots and establish paths to golden images
  42. def setup(self, request, workspace, editor, editor_test_results, launcher_platform):
  43. self.screenshot_directory = os.path.join(workspace.paths.project(), DEFAULT_SUBFOLDER_PATH)
  44. self.screenshot_names = [
  45. "AreaLight_1.ppm",
  46. "AreaLight_2.ppm",
  47. "AreaLight_3.ppm",
  48. "AreaLight_4.ppm",
  49. "AreaLight_5.ppm",
  50. ]
  51. self.test_screenshots, self.golden_images = TestAutomation.screenshot_setup(
  52. screenshot_directory=self.screenshot_directory,
  53. screenshot_names=self.screenshot_names)
  54. def wrap_run(self, request, workspace, editor, editor_test_results, launcher_platform):
  55. yield
  56. assert compare_screenshot_to_golden_image(self.screenshot_directory,
  57. self.test_screenshots,
  58. self.golden_images,
  59. similarity_threshold=0.96) is True
  60. @pytest.mark.test_case_id("C34525095")
  61. class AtomGPU_LightComponent_AreaLightScreenshotsMatchGoldenImages_Vulkan(EditorSingleTest):
  62. from Atom.tests import hydra_AtomGPU_AreaLightScreenshotTest as test_module
  63. extra_cmdline_args = ["-rhi=vulkan"]
  64. # Custom setup/teardown to remove old screenshots and establish paths to golden images
  65. def setup(self, request, workspace, editor, editor_test_results, launcher_platform):
  66. self.screenshot_directory = os.path.join(workspace.paths.project(), DEFAULT_SUBFOLDER_PATH)
  67. self.screenshot_names = [
  68. "AreaLight_1.ppm",
  69. "AreaLight_2.ppm",
  70. "AreaLight_3.ppm",
  71. "AreaLight_4.ppm",
  72. "AreaLight_5.ppm",
  73. ]
  74. self.test_screenshots, self.golden_images = TestAutomation.screenshot_setup(
  75. screenshot_directory=self.screenshot_directory,
  76. screenshot_names=self.screenshot_names)
  77. def wrap_run(self, request, workspace, editor, editor_test_results, launcher_platform):
  78. yield
  79. assert compare_screenshot_to_golden_image(self.screenshot_directory,
  80. self.test_screenshots,
  81. self.golden_images,
  82. similarity_threshold=0.96) is True
  83. @pytest.mark.test_case_id("C34525110")
  84. class AtomGPU_LightComponent_SpotLightScreenshotsMatchGoldenImages_DX12(EditorSingleTest):
  85. from Atom.tests import hydra_AtomGPU_SpotLightScreenshotTest as test_module
  86. extra_cmdline_args = ["-rhi=dx12"]
  87. # Custom setup/teardown to remove old screenshots and establish paths to golden images
  88. def setup(self, request, workspace, editor, editor_test_results, launcher_platform):
  89. self.screenshot_directory = os.path.join(workspace.paths.project(), DEFAULT_SUBFOLDER_PATH)
  90. self.screenshot_names = [
  91. "SpotLight_1.ppm",
  92. "SpotLight_2.ppm",
  93. "SpotLight_3.ppm",
  94. "SpotLight_4.ppm",
  95. "SpotLight_5.ppm",
  96. "SpotLight_6.ppm",
  97. ]
  98. self.test_screenshots, self.golden_images = TestAutomation.screenshot_setup(
  99. screenshot_directory=self.screenshot_directory,
  100. screenshot_names=self.screenshot_names)
  101. def wrap_run(self, request, workspace, editor, editor_test_results, launcher_platform):
  102. yield
  103. assert compare_screenshot_to_golden_image(self.screenshot_directory,
  104. self.test_screenshots,
  105. self.golden_images,
  106. similarity_threshold=0.96) is True
  107. @pytest.mark.test_case_id("C34525110")
  108. class AtomGPU_LightComponent_SpotLightScreenshotsMatchGoldenImages_Vulkan(EditorSingleTest):
  109. from Atom.tests import hydra_AtomGPU_SpotLightScreenshotTest as test_module
  110. extra_cmdline_args = ["-rhi=vulkan"]
  111. # Custom setup/teardown to remove old screenshots and establish paths to golden images
  112. def setup(self, request, workspace, editor, editor_test_results, launcher_platform):
  113. self.screenshot_directory = os.path.join(workspace.paths.project(), DEFAULT_SUBFOLDER_PATH)
  114. self.screenshot_names = [
  115. "SpotLight_1.ppm",
  116. "SpotLight_2.ppm",
  117. "SpotLight_3.ppm",
  118. "SpotLight_4.ppm",
  119. "SpotLight_5.ppm",
  120. "SpotLight_6.ppm",
  121. ]
  122. self.test_screenshots, self.golden_images = TestAutomation.screenshot_setup(
  123. screenshot_directory=self.screenshot_directory,
  124. screenshot_names=self.screenshot_names)
  125. def wrap_run(self, request, workspace, editor, editor_test_results, launcher_platform):
  126. yield
  127. assert compare_screenshot_to_golden_image(self.screenshot_directory,
  128. self.test_screenshots,
  129. self.golden_images,
  130. similarity_threshold=0.96) is True
  131. class AtomEditorComponents_HDRColorGrading_Generate_Activate_LUT(EditorBatchedTest):
  132. from Atom.tests import periodic_AtomEditorComponents_HDRColorGradingAdded as test_module
  133. @pytest.mark.parametrize("project", ["AutomatedTesting"])
  134. @pytest.mark.parametrize("launcher_platform", ['windows_generic'])
  135. class TestMaterialEditor(object):
  136. @pytest.mark.parametrize("cfg_args,expected_lines", [
  137. pytest.param("-rhi=dx12", ["Registering dx12 RHI"]),
  138. pytest.param("-rhi=Vulkan", ["Registering vulkan RHI"])
  139. ])
  140. @pytest.mark.parametrize("exe_file_name", ["MaterialEditor"])
  141. @pytest.mark.test_case_id("C30973986") # Material Editor Launching in Dx12
  142. @pytest.mark.test_case_id("C30973987") # Material Editor Launching in Vulkan
  143. def test_MaterialEditorLaunch_AllRHIOptionsSucceed(
  144. self, request, workspace, project, launcher_platform, generic_launcher, exe_file_name, cfg_args,
  145. expected_lines):
  146. """
  147. Tests each valid RHI option (Null RHI excluded) can be launched with the MaterialEditor.
  148. Checks for the specific expected_lines messaging for each RHI type.
  149. """
  150. hydra.launch_and_validate_results(
  151. request,
  152. os.path.join(os.path.dirname(__file__), "tests"),
  153. generic_launcher,
  154. editor_script="",
  155. run_python="--runpython",
  156. timeout=60,
  157. expected_lines=expected_lines,
  158. unexpected_lines=[],
  159. halt_on_unexpected=False,
  160. null_renderer=False,
  161. cfg_args=[cfg_args],
  162. log_file_name="MaterialEditor.log",
  163. )