EditMenu_Default_UndoRedo.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. VARIABLE_COUNT_BEFORE = 1
  7. VARIABLE_COUNT_AFTER = 0
  8. VARIABLE_NAME = "Test Boolean"
  9. def EditMenu_Default_UndoRedo():
  10. """
  11. Summary:
  12. Edit > Undo undoes the last action
  13. Edit > Redo redoes the last undone action
  14. We create a new variable in variable manager, undo and verify if variable is removed,
  15. redo it and verify if the variable is created again.
  16. Expected Behavior:
  17. The last action is undone upon selecting Undo.
  18. The last undone action is redone upon selecting Redo.
  19. Test Steps:
  20. 1) Open Script Canvas window
  21. 2) Create Graph
  22. 3) Create and verify the new variable exists in variable manager
  23. 4) Delete the variable and verify it's removed in Variable Manager
  24. 5) Trigger undo action and verify if variable is re-added in Variable Manager
  25. 6) Close SC window
  26. Note:
  27. - This test file must be called from the Open 3D Engine Editor command terminal
  28. - Any passed and failed tests are written to the Editor.log file.
  29. Parsing the file or running a log_monitor are required to observe the test results.
  30. :return: None
  31. """
  32. # Preconditions
  33. import azlmbr.legacy.general as general
  34. from editor_python_test_tools.QtPy.QtPyO3DEEditor import QtPyO3DEEditor
  35. general.idle_enable(True)
  36. # 1) Open Script Canvas window
  37. qtpy_o3de_editor = QtPyO3DEEditor()
  38. sc_editor = qtpy_o3de_editor.open_script_canvas()
  39. # 2) Create Graph
  40. sc_editor.create_new_script_canvas_graph()
  41. # 3) Create and verify the new variable exists in variable manager
  42. variable_manager = sc_editor.variable_manager
  43. variable_manager.create_new_variable(VARIABLE_NAME, variable_manager.variable_types.Boolean)
  44. variable_manager.validate_variable_count(VARIABLE_COUNT_BEFORE)
  45. # 4) Delete the variable and verify it's removed in Variable Manager
  46. variable_manager.delete_variable(VARIABLE_NAME)
  47. variable_manager.validate_variable_count(VARIABLE_COUNT_AFTER)
  48. # 5) Trigger undo action and verify if variable is re-added in Variable Manager
  49. sc_editor.trigger_undo_action()
  50. variable_manager.validate_variable_count(VARIABLE_COUNT_BEFORE)
  51. # 6) Close SC window
  52. qtpy_o3de_editor.close_script_canvas()
  53. if __name__ == "__main__":
  54. from editor_python_test_tools.utils import Report
  55. Report.start_test(EditMenu_Default_UndoRedo)