More Editor automation conversions to TestAutomationBase
Signed-off-by: jckand-amzn <jckand@amazon.com>
This commit is contained in:
@@ -7,27 +7,32 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
C6376081: Basic Function: Docked/Undocked Tools
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from PySide2 import QtWidgets, QtTest, QtCore
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
class Tests:
|
||||
all_tools_docked = (
|
||||
"The tools are all docked together in a tabbed widget",
|
||||
"Failed to dock all tools together"
|
||||
)
|
||||
docked_outliner_works = (
|
||||
"Entity Outliner works when docked, can select an Entity",
|
||||
"Failed to select an Entity in the Outliner while docked"
|
||||
)
|
||||
docked_inspector_works = (
|
||||
"Entity Inspector works when docked, Entity name changed",
|
||||
"Failed to change Entity name in the Inspector while docked"
|
||||
)
|
||||
docked_console_works = (
|
||||
"Console works when docked, sent a Console Command",
|
||||
"Failed to send Console Command in the Console while docked"
|
||||
)
|
||||
|
||||
|
||||
class TestDockingBasicDockedTools(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="Docking_BasicDockedTools", args=["level"])
|
||||
def Docking_BasicDockedTools():
|
||||
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
|
||||
@pyside_utils.wrap_async
|
||||
async def run_test(self):
|
||||
async def run_test():
|
||||
"""
|
||||
Summary:
|
||||
Test that tools still work as expected when docked together.
|
||||
@@ -50,14 +55,19 @@ class TestDockingBasicDockedTools(EditorTestHelper):
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# Create a level since we are going to be dealing with an Entity.
|
||||
self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
from PySide2 import QtWidgets, QtTest, QtCore
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Make sure the Entity Outliner, Entity Inspector and Console tools are open
|
||||
general.open_pane("Entity Outliner (PREVIEW)")
|
||||
@@ -101,12 +111,14 @@ class TestDockingBasicDockedTools(EditorTestHelper):
|
||||
entity_inspector_parent = entity_inspector.parentWidget()
|
||||
entity_outliner_parent = entity_outliner.parentWidget()
|
||||
console_parent = console.parentWidget()
|
||||
print(f"Entity Inspector parent = {entity_inspector_parent}, Entity Outliner parent = {entity_outliner_parent}, Console parent = {console_parent}")
|
||||
return isinstance(entity_inspector_parent, QtWidgets.QStackedWidget) and (entity_inspector_parent == entity_outliner_parent) and (entity_outliner_parent == console_parent)
|
||||
Report.info(f"Entity Inspector parent = {entity_inspector_parent}, Entity Outliner parent = "
|
||||
f"{entity_outliner_parent}, Console parent = {console_parent}")
|
||||
return isinstance(entity_inspector_parent, QtWidgets.QStackedWidget) and \
|
||||
(entity_inspector_parent == entity_outliner_parent) and \
|
||||
(entity_outliner_parent == console_parent)
|
||||
|
||||
success = await pyside_utils.wait_for(check_all_panes_tabbed, timeout=3.0)
|
||||
if success:
|
||||
print("The tools are all docked together in a tabbed widget")
|
||||
Report.result(Tests.all_tools_docked, success)
|
||||
|
||||
# 2.1,2) Select an Entity in the Entity Outliner.
|
||||
entity_inspector = editor_window.findChild(QtWidgets.QDockWidget, "Entity Inspector")
|
||||
@@ -116,8 +128,7 @@ class TestDockingBasicDockedTools(EditorTestHelper):
|
||||
test_entity_index = pyside_utils.find_child_by_pattern(object_tree, entity_original_name)
|
||||
object_tree.clearSelection()
|
||||
object_tree.setCurrentIndex(test_entity_index)
|
||||
if object_tree.currentIndex():
|
||||
print("Entity Outliner works when docked, can select an Entity")
|
||||
Report.result(Tests.docked_outliner_works, object_tree.currentIndex() == test_entity_index)
|
||||
|
||||
# 2.3,4) Change the name of the selected Entity via the Entity Inspector.
|
||||
entity_inspector_name_field = entity_inspector.findChild(QtWidgets.QLineEdit, "m_entityNameEditor")
|
||||
@@ -125,14 +136,23 @@ class TestDockingBasicDockedTools(EditorTestHelper):
|
||||
entity_inspector_name_field.setText(expected_new_name)
|
||||
QtTest.QTest.keyClick(entity_inspector_name_field, QtCore.Qt.Key_Enter)
|
||||
entity_new_name = editor.EditorEntityInfoRequestBus(bus.Event, "GetName", entity_id)
|
||||
if entity_new_name == expected_new_name:
|
||||
print(f"Entity Inspector works when docked, Entity name changed to {entity_new_name}")
|
||||
Report.result(Tests.docked_inspector_works, entity_new_name == expected_new_name)
|
||||
|
||||
# 2.5,6) Send a console command.
|
||||
console_line_edit = console.findChild(QtWidgets.QLineEdit, "lineEdit")
|
||||
console_line_edit.setText("Hello, world!")
|
||||
console_line_edit.setText("t_Scale 2")
|
||||
QtTest.QTest.keyClick(console_line_edit, QtCore.Qt.Key_Enter)
|
||||
general.get_cvar("t_Scale")
|
||||
Report.result(Tests.docked_console_works, general.get_cvar("t_Scale") == "2")
|
||||
|
||||
# Reset the altered cvar
|
||||
console_line_edit.setText("t_Scale 1")
|
||||
QtTest.QTest.keyClick(console_line_edit, QtCore.Qt.Key_Enter)
|
||||
|
||||
run_test()
|
||||
|
||||
test = TestDockingBasicDockedTools()
|
||||
test.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(Docking_BasicDockedTools)
|
||||
|
||||
Reference in New Issue
Block a user