UtilTest_Tracer_PicksErrorsAndWarnings.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. # fmt: off
  7. class Tests():
  8. enter_game_mode = ("Entered game mode", "Failed to enter game mode")
  9. warning_found = ("ScriptCanvas Warning found when running level containing warning entity", "ScriptCanvas Warning NOT found when running level containing warning entity")
  10. error_found = ("PhysX Error found after openning level containing error entity", "PhysX Error NOT found after openning level containing error entity")
  11. exit_game_mode = ("Exited game mode", "Failed to exit game mode")
  12. # fmt: on
  13. def run():
  14. """
  15. Summary:
  16. Checks that Tracer and the Trace notification EBus works propoerly.
  17. Level Tracer_WarningEntity:
  18. Contains an Entity with a Script Canvas component with non-connected nodes.
  19. When entering into gamemode, Script Canvas should raise a Warning.
  20. Level Tracer_ErrorEntity:
  21. Contains an Entity with a PhysX Collider Box with invalid extent (0, 1, 1).
  22. When opening the level, the collider should raise an Error.
  23. """
  24. import os
  25. import sys
  26. import azlmbr.legacy.general as general
  27. from editor_python_test_tools.utils import Report
  28. from editor_python_test_tools.utils import TestHelper as helper
  29. from editor_python_test_tools.utils import Tracer
  30. helper.init_idle()
  31. with Tracer() as entity_warning_tracer:
  32. def has_scriptcanvas_warning():
  33. return entity_warning_tracer.has_warnings and any('Script Canvas' in warningInfo.window for warningInfo in entity_warning_tracer.warnings)
  34. helper.open_level("Utils", "Tracer_WarningEntity")
  35. helper.enter_game_mode(Tests.enter_game_mode)
  36. helper.wait_for_condition(has_scriptcanvas_warning, 1.0)
  37. helper.exit_game_mode(Tests.exit_game_mode)
  38. Report.result(Tests.warning_found, has_scriptcanvas_warning())
  39. with Tracer() as entity_error_tracer:
  40. def has_physx_error():
  41. return entity_error_tracer.has_errors and any('PhysX' in errorInfo.window for errorInfo in entity_error_tracer.errors)
  42. helper.open_level("Utils", "Tracer_ErrorEntity")
  43. helper.wait_for_condition(has_physx_error, 1.0)
  44. Report.result(Tests.error_found, has_physx_error())
  45. if __name__ == "__main__":
  46. run()