Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,63 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
#
# This is a pytest module to test the basic integration of PySide2 (aka Qt for Python)
#
import pytest
import time
import logging
import os
import shutil
from test_tools import WINDOWS_LAUNCHER
import test_tools.shared.log_monitor
import test_tools.launchers.phase
import test_tools.builtin.fixtures as fixtures
# Use the built-in workspace and editor fixtures.
# These will configure the requested project and run the editor.
workspace = fixtures.use_fixture(fixtures.builtin_workspace_fixture, scope='function')
editor = fixtures.use_fixture(fixtures.editor, scope='function')
logger = logging.getLogger(__name__)
@pytest.mark.parametrize("platform,configuration,project,spec", [
pytest.param("win_x64_vs2017", "profile", "AutomatedTesting", "all", marks=pytest.mark.skipif(not WINDOWS_LAUNCHER, reason="Only supported on Windows hosts")),
])
class TestEditorMenuBarAutomation(object):
def test_MenuBar(self, request, editor, project):
logger.debug("Running automated test")
request.addfinalizer(editor.ensure_stopped)
editor.deploy()
editor.launch(["--runpython", "@engroot@/Gems/QtForPython/Code/Tests/pyside_auto_menubar_test_case.py"])
editorlog_file = os.path.join(editor.workspace.release.paths.project_log(), 'Editor.log')
expected_lines = [
"QtForPython Is Ready",
"Value allWindows greater than zero",
"GetMainWindowId",
"Get QtWidgets.QMainWindow",
"Value menuBar is valid",
"Found File action",
"Found Edit action",
"Found Game action",
"Found Tools action"
]
test_tools.shared.log_monitor.monitor_for_expected_lines(editor, editorlog_file, expected_lines)
# Rely on the test script to quit after running
editor.run(test_tools.launchers.phase.WaitForLauncherToQuit(editor, 10))
@@ -0,0 +1,61 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
# Import the Editor API to test the PySide2 & Qt 5.12.x integration
import azlmbr.bus
import azlmbr.editor as editor
import azlmbr.legacy.general as general
def printOrExcept(expression, message):
if(expression):
print (message)
return
failed = 'FAILED - '.format(message)
print (failed)
general.exit_no_prompt()
raise Exception(failed)
printOrExcept(azlmbr.qt.QtForPythonRequestBus(azlmbr.bus.Broadcast, 'IsActive'), 'QtForPython Is Ready')
# the PySide2 and shiboken2 libraries should import cleanly
try:
from shiboken2 import wrapInstance, getCppPointer
from PySide2 import QtWidgets
from PySide2 import QtGui
except:
printOrExcept(False, 'Importing PySide2 and Shiboken2')
allWindows = QtGui.QGuiApplication.allWindows()
printOrExcept(len(allWindows) > 0, 'Value allWindows greater than zero')
azMainWidgetId = azlmbr.qt.QtForPythonRequestBus(azlmbr.bus.Broadcast, 'GetMainWindowId')
printOrExcept(azMainWidgetId is not 0, 'GetMainWindowId')
mainWidgetWindow = QtWidgets.QWidget.find(azMainWidgetId)
mainWindow = wrapInstance(int(getCppPointer(mainWidgetWindow)[0]), QtWidgets.QMainWindow)
printOrExcept(mainWindow is not None, 'Get QtWidgets.QMainWindow')
menuBar = mainWindow.menuBar()
printOrExcept(menuBar is not None, 'Value menuBar is valid')
for action in menuBar.actions():
if("File" in action.text()):
print('Found File action')
elif("Edit" in action.text()):
print('Found Edit action')
elif("Game" in action.text()):
print('Found Game action')
elif("Tools" in action.text()):
print('Found Tools action')
general.exit_no_prompt()