Files
o3de/AutomatedTesting/Gem/PythonTests/WhiteBox/tests/WhiteBox_SetDefaultShape.py
T
lumberyard-employee-dm 669caca9cc Updated Launching of Lua Editor to supply the project-path (#7706)
* Updated Launching of Lua Editor to supply the project-path

The Lua Launch logic also uses the AzFramework ProcessLauncher instead
of Qt. This has the benefit of being able to pass arguments as an array
instead of in a single string. Therefore paths with spaces in them also
work.

Tweak the Settings Registry logic to locate the
project-path/engine-path by scanning upwards for a
project.json/engine.json respectively to inject the found paths to the
front of the command line parameters instead of the back.
This has the effect of making sure that command line parameters for the
project-path/engine-path always takes precedence over scanning upwards
for a project.json/engine.json.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Removed prepend of EngineRoot in CheckProjectPathProvided

The Editor would attempt to validate that the project path supplied via
the command line contained a valid project.json file before contining
the Editor startup flow.

This was taking the engine root path and appending the project path to
it, which works when the project path is absolute

But when the project path is relative it is treated as relative to the
current working directory by the SettingsRegistry, but the logic in the
CheckProjectPathProvided was treating it has relative to the engine
root. Therefore supplying a relative path as part of the Editor.exe
launch command would fail.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed resolving of relative paths to absolute paths in the Editor

The Editor was changing the current working directory to the nearest
ancestor directory containing an `engine.json` file.
This resulted in the ConvertToAbsolutePath function resolving relative
paths to that directory instead of the launch directory of the Editor.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
2022-02-18 10:11:16 -06:00

105 lines
3.9 KiB
Python

"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
# Test case ID : C29279329
# Test Case Title : White Box mesh shape can be changed with the Default Shape dropdown on the Component
# fmt:off
class Tests():
default_shape_cube = ("Default shape set to cube", "Default shape is not set to cube")
default_shape_tetrahedron = ("Default shape changed to tetrahedron", "Failed to change default shape to tetrahedron")
default_shape_icosahedron = ("Default shape changed to icosahedron", "Failed to change default shape to icosahedron")
default_shape_cylinder = ("Default shape changed to cylinder", "Failed to change default shape to cylinder")
default_shape_sphere = ("Default shape changed to sphere", "Failed to change default shape to sphere")
# fmt:on
critical_shape_check = ("Default shape has more than 0 sides", "default shape has 0 sides")
def C29279329_WhiteBox_SetDefaultShape():
import os
import sys
import WhiteBoxInit as init
import azlmbr.whitebox.api as api
import azlmbr.bus as bus
import azlmbr.legacy.general as general
from editor_python_test_tools.utils import Report
from editor_python_test_tools.utils import TestHelper as helper
def check_shape_result(success_fail_tuple, condition):
result = Report.result(success_fail_tuple, condition)
if not result:
face_count = white_box_handle.MeshFaceCount()
Report.critical_result(critical_shape_check, face_count > 0)
Report.info(f"Face count = {face_count}")
shape_types = azlmbr.globals.property
# expected results
expected_results = {
shape_types.CUBE: 12,
shape_types.TETRAHEDRON: 4,
shape_types.ICOSAHEDRON: 20,
shape_types.CYLINDER: 64,
shape_types.SPHERE: 320
}
# open level
helper.init_idle()
helper.open_level("WhiteBox", "EmptyLevel", no_prompt=False)
# create white box entity and attach component
white_box_entity = init.create_white_box_entity()
white_box_mesh_component = init.create_white_box_component(white_box_entity)
white_box_handle = init.create_white_box_handle(white_box_mesh_component)
# verify results
# cube
check_shape_result(
Tests.default_shape_cube,
white_box_handle.MeshFaceCount() == expected_results.get(shape_types.CUBE))
# tetrahedron
azlmbr.whitebox.request.bus.EditorWhiteBoxComponentRequestBus(
bus.Event, 'SetDefaultShape', white_box_mesh_component, shape_types.TETRAHEDRON)
check_shape_result(
Tests.default_shape_tetrahedron,
white_box_handle.MeshFaceCount() == expected_results.get(shape_types.TETRAHEDRON))
# icosahedron
azlmbr.whitebox.request.bus.EditorWhiteBoxComponentRequestBus(
bus.Event, 'SetDefaultShape', white_box_mesh_component, shape_types.ICOSAHEDRON)
check_shape_result(
Tests.default_shape_icosahedron,
white_box_handle.MeshFaceCount() == expected_results.get(shape_types.ICOSAHEDRON))
# cylinder
azlmbr.whitebox.request.bus.EditorWhiteBoxComponentRequestBus(
bus.Event, 'SetDefaultShape', white_box_mesh_component, shape_types.CYLINDER)
check_shape_result(
Tests.default_shape_cylinder,
white_box_handle.MeshFaceCount() == expected_results.get(shape_types.CYLINDER))
# sphere
azlmbr.whitebox.request.bus.EditorWhiteBoxComponentRequestBus(
bus.Event, 'SetDefaultShape', white_box_mesh_component, shape_types.SPHERE)
check_shape_result(
Tests.default_shape_sphere,
white_box_handle.MeshFaceCount() == expected_results.get(shape_types.SPHERE))
# close editor
helper.close_editor()
if __name__ == "__main__":
from editor_python_test_tools.utils import Report
Report.start_test(C29279329_WhiteBox_SetDefaultShape)