2
0

NodePalette_SearchText_Deletion.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. set_search_string = ("Search string is set", "Search string is not set")
  9. search_string_deleted = ("Search string deleted as expected", "Search string not deleted")
  10. # fmt: on
  11. def NodePalette_SearchText_Deletion():
  12. """
  13. Summary:
  14. We enter some string in the Node Palette Search box, select that text and delete it.
  15. Expected Behavior:
  16. After RightClick->Delete the text in the Searchbox should be deleted.
  17. Test Steps:
  18. 1) Open Script Canvas window (Tools > Script Canvas)
  19. 2) Get the SC window object
  20. 3) Open Node Manager if not opened already
  21. 4) Set some string in the Search box
  22. 5) Verify if the test string is set
  23. 6) Delete search string using right click and verify if it is cleared
  24. Note:
  25. - This test file must be called from the Open 3D Engine Editor command terminal
  26. - Any passed and failed tests are written to the Editor.log file.
  27. Parsing the file or running a log_monitor are required to observe the test results.
  28. :return: None
  29. """
  30. from PySide2 import QtWidgets, QtTest, QtCore
  31. from utils import TestHelper as helper
  32. import azlmbr.legacy.general as general
  33. import pyside_utils
  34. TEST_STRING = "TestString"
  35. # 1) Open Script Canvas window (Tools > Script Canvas)
  36. general.idle_enable(True)
  37. general.open_pane("Script Canvas")
  38. helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 3.0)
  39. # 2) Get the SC window object
  40. editor_window = pyside_utils.get_editor_main_window()
  41. sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas")
  42. # 3) Open Node Manager if not opened already
  43. if sc.findChild(QtWidgets.QDockWidget, "NodePalette") is None:
  44. action = pyside_utils.find_child_by_pattern(sc, {"text": "Node Palette", "type": QtWidgets.QAction})
  45. action.trigger()
  46. node_palette = sc.findChild(QtWidgets.QDockWidget, "NodePalette")
  47. search_frame = node_palette.findChild(QtWidgets.QFrame, "searchFrame")
  48. # 4) Set some string in the Search box
  49. search_box = search_frame.findChild(QtWidgets.QLineEdit, "searchFilter")
  50. search_box.setText(TEST_STRING)
  51. # 5) Verify if the test string is set
  52. result = helper.wait_for_condition(lambda: search_box.text() == TEST_STRING, 1.0)
  53. Report.result(Tests.set_search_string, result)
  54. # 6) Delete search string using right click and verify if it is cleared
  55. QtTest.QTest.keyClick(search_box, QtCore.Qt.Key_A, QtCore.Qt.ControlModifier)
  56. pyside_utils.trigger_context_menu_entry(search_box, "Delete")
  57. result = helper.wait_for_condition(lambda: search_box.text() == "", 2.0)
  58. Report.result(Tests.search_string_deleted, result)
  59. if __name__ == "__main__":
  60. import ImportPathHelper as imports
  61. imports.init()
  62. from utils import Report
  63. Report.start_test(NodePalette_SearchText_Deletion)