3
0

levelLoad_Atom_ShadowTest.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. class Tests:
  7. shadowtest_level_load = (
  8. "Shadowtest level loaded",
  9. "P0: Shadowtest level failed to load")
  10. shadowtest_level_enter_game_mode = (
  11. "Shadowtest entered gameplay successfully",
  12. "P0: Shadowtest failed to enter gameplay")
  13. shadowtest_level_exit_game_mode = (
  14. "Shadowtest exited gameplay successfully",
  15. "P0: Shadowtest failed to exit gameplay")
  16. empty_level_load = (
  17. "Empty level loaded successfully, Editor remains stable",
  18. "P0: Empty level fails to load, editor is either hung or crashed")
  19. def Atom_Editor_LevelLoad_ShadowTest():
  20. """
  21. Summary:
  22. Loads the "Shadowtest" level within an instance of Editor.exe using the null renderer. Test verifies that
  23. the level loads, can enter/exit gameplay, and that Editor.exe remains stable throughout this process.
  24. Test setup:
  25. - Launch Editor.exe
  26. Expected Behavior:
  27. Test verifies that level loads, enters/exits game mode, and editor remains stable.
  28. Test Steps:
  29. 1) Load level, confirm that correct level is loaded, and report results
  30. 2) Validate that editor can enter gameplay successfully
  31. 3) Validate that editor can exit gameplay successfully
  32. 4) Open an empty level to verify editor remains stable
  33. 5) Look for errors or asserts.
  34. :return: None
  35. """
  36. import azlmbr.legacy.general as general
  37. from editor_python_test_tools.utils import Report, Tracer, TestHelper
  38. with Tracer() as error_tracer:
  39. # 1. Load level ShadowTest, confirm that correct level is loaded, and report results
  40. TestHelper.init_idle()
  41. TestHelper.open_level("Graphics", "ShadowTest")
  42. Report.result(Tests.shadowtest_level_load, "ShadowTest" == general.get_current_level_name())
  43. # 2. Validate that editor can enter gameplay successfully.
  44. TestHelper.enter_game_mode(Tests.shadowtest_level_enter_game_mode)
  45. general.idle_wait_frames(1)
  46. # 3. Validate that editor can exit gameplay successfully.
  47. TestHelper.exit_game_mode(Tests.shadowtest_level_exit_game_mode)
  48. general.idle_wait_frames(1)
  49. # 4. Open an empty level to verify editor remains stable.
  50. TestHelper.open_level("Graphics", "base_empty")
  51. Report.result(Tests.empty_level_load, "base_empty" == general.get_current_level_name())
  52. # 5. Look for errors or asserts.
  53. TestHelper.wait_for_condition(lambda: error_tracer.has_errors or error_tracer.has_asserts, 1.0)
  54. for error_info in error_tracer.errors:
  55. Report.info(f"Error: {error_info.filename} {error_info.function} | {error_info.message}")
  56. for assert_info in error_tracer.asserts:
  57. Report.info(f"Assert: {assert_info.filename} {assert_info.function} | {assert_info.message}")
  58. if __name__ == "__main__":
  59. from editor_python_test_tools.utils import Report
  60. Report.start_test(Atom_Editor_LevelLoad_ShadowTest)