Files
o3de/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EditorUtilityCommands_test_case.py
T
Steve Pham b4a2edec6a Final update copyright headers to reference license files at the repo root (#1693)
* Final update copyright headers to reference license files at the repo root

Signed-off-by: spham <spham@amazon.com>

* Fix copyright validator unit tests to support the stale O3DE header scenario

Signed-off-by: spham <spham@amazon.com>
2021-06-30 19:51:55 -07:00

61 lines
2.0 KiB
Python
Executable File

"""
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
"""
# Tests the Python API from PythonEditorFuncs.cpp while the Editor is running
import azlmbr.bus as bus
import azlmbr.editor as editor
import azlmbr.python_editor_funcs as python_editor_funcs
import azlmbr.globals
import math
def testing_cvar(setMethod, methodName, label, value, compare):
try:
python_editor_funcs.PythonEditorBus(bus.Broadcast, setMethod, label, value)
test_value = python_editor_funcs.PythonEditorBus(bus.Broadcast, 'GetCVar', label)
if compare(test_value, value):
print('{} worked'.format(methodName))
except:
print('{} failed'.format(methodName))
def testing_axis_constraints(constraint):
python_editor_funcs.PythonEditorBus(bus.Broadcast, 'SetAxisConstraint', constraint)
if constraint == python_editor_funcs.PythonEditorBus(bus.Broadcast, 'GetAxisConstraint'):
return True
return False
# ----- Test cvar
compare = lambda lhs, rhs: rhs == float(lhs)
testing_cvar('SetCVarFromFloat', 'SetCVarFromFloat', 'sys_LocalMemoryOuterViewDistance', 501.0, compare)
compare = lambda lhs, rhs: rhs == lhs
testing_cvar('SetCVarFromString', 'SetCVarFromString', 'e_ScreenShotFileFormat', 'jpg', compare)
compare = lambda lhs, rhs: rhs == int(lhs)
testing_cvar('SetCVarFromInteger', 'SetCVarFromInteger', 'sys_LocalMemoryGeometryLimit', 33, compare)
# ----- Test Axis Constraints
if (testing_axis_constraints("X") and testing_axis_constraints("Y") and
testing_axis_constraints("Z") and testing_axis_constraints("XY") and
testing_axis_constraints("XZ") and testing_axis_constraints("YZ") and
testing_axis_constraints("XYZ") and testing_axis_constraints("TERRAIN") and
testing_axis_constraints("TERRAINSNAP")):
print("axis constraint works")
# ----- End
print("end of editor utility tests")
editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'ExitNoPrompt')