git mv Code\Sandbox\Editor Code/Editor
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <IEditor.h>
|
||||
#include <SFunctor.h>
|
||||
#include <RenderHelpers/AxisHelper.h>
|
||||
|
||||
class CEditorMock
|
||||
: public IEditor
|
||||
{
|
||||
public:
|
||||
// GMock does not work with a variadic function
|
||||
void ExecuteCommand(const char* sCommand, ...) override
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, sCommand);
|
||||
ExecuteCommand(QString::asprintf(sCommand, args));
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
public:
|
||||
MOCK_METHOD0(DeleteThis, void());
|
||||
MOCK_METHOD0(GetSystem, ISystem*());
|
||||
MOCK_METHOD0(GetClassFactory, IEditorClassFactory* ());
|
||||
MOCK_METHOD0(GetCommandManager, CEditorCommandManager*());
|
||||
MOCK_METHOD0(GetICommandManager, ICommandManager* ());
|
||||
MOCK_METHOD1(ExecuteCommand, void(const QString& sCommand));
|
||||
MOCK_METHOD1(SetDocument, void(CCryEditDoc* pDoc));
|
||||
MOCK_CONST_METHOD0(GetDocument, CCryEditDoc* ());
|
||||
MOCK_CONST_METHOD0(IsLevelLoaded, bool());
|
||||
MOCK_METHOD1(SetModifiedFlag, void(bool));
|
||||
MOCK_METHOD2(SetModifiedModule, void(EModifiedModule, bool));
|
||||
MOCK_CONST_METHOD0(IsLevelExported, bool());
|
||||
MOCK_METHOD1(SetLevelExported, bool(bool));
|
||||
MOCK_METHOD0(IsModified, bool());
|
||||
MOCK_METHOD0(SaveDocument, bool());
|
||||
MOCK_METHOD1(WriteToConsole, void(const char* ));
|
||||
MOCK_METHOD1(WriteToConsole, void(const QString& ));
|
||||
MOCK_METHOD2(SetConsoleVar, void(const char* var, float ));
|
||||
MOCK_METHOD1(GetConsoleVar, float(const char* var));
|
||||
MOCK_METHOD1(ShowConsole, bool(bool show));
|
||||
MOCK_METHOD0(GetMainStatusBar, IMainStatusBar*());
|
||||
MOCK_METHOD1(SetStatusText, void(const QString& ));
|
||||
MOCK_CONST_METHOD0(GetEditorMainWindow, QMainWindow* ());
|
||||
MOCK_METHOD0(GetPrimaryCDFolder, QString());
|
||||
MOCK_METHOD0(GetLevelName, QString());
|
||||
MOCK_METHOD0(GetLevelFolder, QString());
|
||||
MOCK_METHOD0(GetLevelDataFolder, QString());
|
||||
MOCK_METHOD1(GetPrimaryCDFolder, QString(EEditorPathName));
|
||||
MOCK_METHOD0(GetResolvedUserFolder, QString());
|
||||
MOCK_METHOD4(ExecuteConsoleApp, bool(const QString&,QString&,bool,bool));
|
||||
MOCK_METHOD0(SetDataModified, void());
|
||||
MOCK_CONST_METHOD0(IsInitialized, bool());
|
||||
MOCK_METHOD0(IsInGameMode, bool());
|
||||
MOCK_METHOD0(IsInSimulationMode, bool());
|
||||
MOCK_METHOD1(SetInGameMode, void(bool));
|
||||
MOCK_METHOD0(IsInTestMode, bool());
|
||||
MOCK_METHOD0(IsInPreviewMode, bool());
|
||||
MOCK_METHOD0(IsInConsolewMode, bool());
|
||||
MOCK_METHOD0(IsInLevelLoadTestMode, bool());
|
||||
MOCK_METHOD0(IsInMatEditMode, bool());
|
||||
MOCK_METHOD1(EnableUpdate, void(bool));
|
||||
MOCK_METHOD1(EnableAcceleratos, void(bool));
|
||||
MOCK_METHOD0(GetFileVersion, SFileVersion());
|
||||
MOCK_METHOD0(GetProductVersion, SFileVersion());
|
||||
MOCK_METHOD0(GetGameEngine , CGameEngine* ());
|
||||
MOCK_METHOD0(GetDisplaySettings, CDisplaySettings*());
|
||||
MOCK_METHOD0(GetGlobalGizmoParameters, const SGizmoParameters& ());
|
||||
MOCK_METHOD7(NewObject, CBaseObject* (const char*, const char*, const char*, float, float, float, bool));
|
||||
MOCK_METHOD1(DeleteObject, void(CBaseObject* obj));
|
||||
MOCK_METHOD1(CloneObject, CBaseObject* (CBaseObject* ));
|
||||
MOCK_METHOD0(GetSelection, CSelectionGroup* ());
|
||||
MOCK_METHOD0(GetSelectedObject, CBaseObject* ());
|
||||
MOCK_METHOD0(ClearSelection, int());
|
||||
MOCK_METHOD1(SelectObject, void(CBaseObject*));
|
||||
MOCK_METHOD1(LockSelection, void(bool));
|
||||
MOCK_METHOD0(IsSelectionLocked, bool());
|
||||
MOCK_METHOD0(GetObjectManager, struct IObjectManager* ());
|
||||
MOCK_METHOD0(GetSettingsManager, CSettingsManager* ());
|
||||
MOCK_METHOD1(GetDBItemManager, IDataBaseManager* (EDataBaseItemType));
|
||||
MOCK_METHOD0(GetMaterialManagerLibrary, IBaseLibraryManager* ());
|
||||
MOCK_METHOD0(GetIEditorMaterialManager, IEditorMaterialManager* ());
|
||||
MOCK_METHOD0(GetIconManager, IIconManager* ());
|
||||
MOCK_METHOD0(GetMusicManager, CMusicManager* ());
|
||||
MOCK_METHOD2(GetTerrainElevation, float(float , float ));
|
||||
MOCK_METHOD0(GetVegetationMap, class CVegetationMap* ());
|
||||
MOCK_METHOD0(GetEditorQtApplication, Editor::EditorQtApplication* ());
|
||||
MOCK_METHOD1(GetColorByName, const QColor& (const QString&));
|
||||
MOCK_METHOD0(GetMovieSystem, struct IMovieSystem* ());
|
||||
MOCK_METHOD0(GetPluginManager, class CPluginManager*());
|
||||
MOCK_METHOD0(GetViewManager, class CViewManager* ());
|
||||
MOCK_METHOD0(GetActiveView, class CViewport* ());
|
||||
MOCK_METHOD1(SetActiveView, void(CViewport*));
|
||||
MOCK_METHOD0(GetFileMonitor, struct IEditorFileMonitor* ());
|
||||
MOCK_METHOD1(RegisterEventLoopHook, void(IEventLoopHook* ));
|
||||
MOCK_METHOD1(UnregisterEventLoopHook, void(IEventLoopHook* ));
|
||||
MOCK_CONST_METHOD0(CreateQMimeData, QMimeData* ());
|
||||
MOCK_CONST_METHOD1(DestroyQMimeData, void(QMimeData*));
|
||||
MOCK_METHOD0(GetLevelIndependentFileMan, class CLevelIndependentFileMan* ());
|
||||
MOCK_METHOD2(UpdateViews, void(int , const AABB* ));
|
||||
MOCK_METHOD0(ResetViews, void());
|
||||
MOCK_METHOD0(ReloadTrackView, void());
|
||||
MOCK_METHOD0(GetMarkerPosition, Vec3());
|
||||
MOCK_METHOD1(SetMarkerPosition, void(const Vec3&));
|
||||
MOCK_METHOD1(SetSelectedRegion, void(const AABB& box));
|
||||
MOCK_METHOD1(GetSelectedRegion, void(AABB& box));
|
||||
MOCK_METHOD1(SetOperationMode, void(EOperationMode ));
|
||||
MOCK_METHOD0(GetOperationMode, EOperationMode());
|
||||
MOCK_METHOD1(ShowTransformManipulator, ITransformManipulator* (bool));
|
||||
MOCK_METHOD0(GetTransformManipulator, ITransformManipulator* ());
|
||||
MOCK_METHOD1(SetAxisConstraints, void(AxisConstrains ));
|
||||
MOCK_METHOD0(GetAxisConstrains, AxisConstrains());
|
||||
MOCK_METHOD1(SetAxisVectorLock, void(bool));
|
||||
MOCK_METHOD0(IsAxisVectorLocked, bool());
|
||||
MOCK_METHOD1(SetTerrainAxisIgnoreObjects, void(bool));
|
||||
MOCK_METHOD0(IsTerrainAxisIgnoreObjects, bool());
|
||||
MOCK_METHOD1(SetReferenceCoordSys, void(RefCoordSys ));
|
||||
MOCK_METHOD0(GetReferenceCoordSys, RefCoordSys());
|
||||
MOCK_METHOD1(FindTemplate, XmlNodeRef(const QString& ));
|
||||
MOCK_METHOD2(AddTemplate, void(const QString& , XmlNodeRef& ));
|
||||
MOCK_METHOD2(OpenView, const QtViewPane* (QString , bool ));
|
||||
MOCK_METHOD1(FindView, QWidget* (QString ));
|
||||
MOCK_METHOD1(CloseView, bool(const char* ));
|
||||
MOCK_METHOD1(SetViewFocus, bool(const char* ));
|
||||
MOCK_METHOD1(CloseView, void(const GUID& ));
|
||||
MOCK_METHOD1(OpenWinWidget, QWidget* (WinWidgetId ));
|
||||
MOCK_CONST_METHOD0(GetWinWidgetManager, WinWidget::WinWidgetManager* ());
|
||||
MOCK_METHOD2(SelectColor, bool(QColor &, QWidget *));
|
||||
MOCK_METHOD0(GetUndoManager, class CUndoManager* ());
|
||||
MOCK_METHOD0(BeginUndo, void());
|
||||
MOCK_METHOD1(RestoreUndo, void(bool));
|
||||
MOCK_METHOD1(AcceptUndo, void(const QString& ));
|
||||
MOCK_METHOD0(CancelUndo, void());
|
||||
MOCK_METHOD0(SuperBeginUndo, void());
|
||||
MOCK_METHOD1(SuperAcceptUndo, void(const QString&));
|
||||
MOCK_METHOD0(SuperCancelUndo, void());
|
||||
MOCK_METHOD0(SuspendUndo, void());
|
||||
MOCK_METHOD0(ResumeUndo, void());
|
||||
MOCK_METHOD0(Undo, void());
|
||||
MOCK_METHOD0(Redo, void());
|
||||
MOCK_METHOD0(IsUndoRecording, bool());
|
||||
MOCK_METHOD0(IsUndoSuspended, bool());
|
||||
MOCK_METHOD1(RecordUndo, void(struct IUndoObject* ));
|
||||
MOCK_METHOD1(FlushUndo, bool(bool isShowMessage));
|
||||
MOCK_METHOD1(ClearLastUndoSteps, bool(int ));
|
||||
MOCK_METHOD0(ClearRedoStack, bool());
|
||||
MOCK_METHOD0(GetAnimation, CAnimationContext* ());
|
||||
MOCK_METHOD0(GetSequenceManager, CTrackViewSequenceManager* ());
|
||||
MOCK_METHOD0(GetSequenceManagerInterface, ITrackViewSequenceManager* ());
|
||||
MOCK_METHOD0(GetToolBoxManager, CToolBoxManager* ());
|
||||
MOCK_METHOD0(GetErrorReport, IErrorReport* ());
|
||||
MOCK_METHOD0(GetLastLoadedLevelErrorReport, IErrorReport* ());
|
||||
MOCK_METHOD0(StartLevelErrorReportRecording, void());
|
||||
MOCK_METHOD0(CommitLevelErrorReport, void());
|
||||
MOCK_METHOD0(GetFileUtil, IFileUtil* ());
|
||||
MOCK_METHOD1(Notify, void(EEditorNotifyEvent));
|
||||
MOCK_METHOD2(NotifyExcept, void(EEditorNotifyEvent , IEditorNotifyListener* ));
|
||||
MOCK_METHOD1(RegisterNotifyListener, void(IEditorNotifyListener* ));
|
||||
MOCK_METHOD1(UnregisterNotifyListener, void(IEditorNotifyListener* ));
|
||||
MOCK_METHOD1(RegisterDocListener, void(IDocListener* ));
|
||||
MOCK_METHOD1(UnregisterDocListener, void(IDocListener* ));
|
||||
MOCK_METHOD0(GetSourceControl, ISourceControl* ());
|
||||
MOCK_METHOD0(IsSourceControlAvailable, bool());
|
||||
MOCK_METHOD0(IsSourceControlConnected, bool());
|
||||
MOCK_METHOD0(GetUIEnumsDatabase, CUIEnumsDatabase* ());
|
||||
MOCK_METHOD0(AddUIEnums, void());
|
||||
MOCK_METHOD1(GetMemoryUsage, void(ICrySizer* ));
|
||||
MOCK_METHOD0(ReduceMemory, void());
|
||||
MOCK_METHOD0(GetExportManager, IExportManager* ());
|
||||
MOCK_METHOD2(SetEditorConfigSpec, void(ESystemConfigSpec , ESystemConfigPlatform ));
|
||||
MOCK_CONST_METHOD0(GetEditorConfigSpec, ESystemConfigSpec());
|
||||
MOCK_CONST_METHOD0(GetEditorConfigPlatform, ESystemConfigPlatform());
|
||||
MOCK_METHOD0(ReloadTemplates, void());
|
||||
MOCK_METHOD0(GetResourceSelectorHost, IResourceSelectorHost* ());
|
||||
MOCK_METHOD1(ShowStatusText, void(bool ));
|
||||
MOCK_METHOD1(RegisterObjectContextMenuExtension, void(TContextMenuExtensionFunc ));
|
||||
MOCK_METHOD0(GetEnv, SSystemGlobalEnvironment* ());
|
||||
MOCK_METHOD0(GetImageUtil, IImageUtil* ());
|
||||
MOCK_METHOD0(GetEditorSettings, SEditorSettings* ());
|
||||
MOCK_METHOD0(GetLogFile, ILogFile* ());
|
||||
MOCK_METHOD0(UnloadPlugins, void());
|
||||
MOCK_METHOD0(LoadPlugins, void());
|
||||
MOCK_METHOD1(GetSearchPath, QString(EEditorPathName));
|
||||
MOCK_METHOD0(GetEditorPanelUtils, IEditorPanelUtils* ());
|
||||
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <QtUI/ClickableLabel.h>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
using namespace AZ;
|
||||
using namespace ::testing;
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class TestingClickableLabel
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
ClickableLabel m_clickableLabel;
|
||||
};
|
||||
|
||||
TEST_F(TestingClickableLabel, CursorDoesNotUpdateWhileDisabled)
|
||||
{
|
||||
m_clickableLabel.setEnabled(false);
|
||||
|
||||
QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
|
||||
QEnterEvent enterEvent{ QPointF(), QPointF(), QPointF() };
|
||||
QApplication::sendEvent(&m_clickableLabel, &enterEvent);
|
||||
|
||||
const Qt::CursorShape cursorShape = QApplication::overrideCursor()->shape();
|
||||
EXPECT_THAT(cursorShape, Ne(Qt::PointingHandCursor));
|
||||
EXPECT_THAT(cursorShape, Eq(Qt::BlankCursor));
|
||||
}
|
||||
|
||||
TEST_F(TestingClickableLabel, DoesNotRespondToDblClickWhileDisabled)
|
||||
{
|
||||
m_clickableLabel.setEnabled(false);
|
||||
|
||||
bool linkActivated = false;
|
||||
QObject::connect(&m_clickableLabel, &QLabel::linkActivated, [&linkActivated]()
|
||||
{
|
||||
linkActivated = true;
|
||||
});
|
||||
|
||||
QMouseEvent mouseEvent {
|
||||
QEvent::MouseButtonDblClick, QPointF(),
|
||||
Qt::LeftButton, Qt::LeftButton, Qt::NoModifier };
|
||||
QApplication::sendEvent(&m_clickableLabel, &mouseEvent);
|
||||
|
||||
EXPECT_THAT(linkActivated, Eq(false));
|
||||
}
|
||||
} // namespace UnitTest
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <CryEditDoc.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
namespace CryEditDocPythonBindingsUnitTests
|
||||
{
|
||||
|
||||
class CryEditDocPythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::CryEditDocFuncsHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(CryEditDocPythonBindingsFixture, CryEditDocEditorCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("save_level") != behaviorContext->m_methods.end());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <MainWindow.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
#include "CryEdit.h"
|
||||
|
||||
namespace CryEditPythonBindingsUnitTests
|
||||
{
|
||||
|
||||
class CryEditPythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::CryEditPythonHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(CryEditPythonBindingsFixture, CryEditCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("open_level") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("open_level_no_prompt") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("create_level") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("create_level_no_prompt") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_game_folder") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_current_level_name") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_current_level_path") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("load_all_plugins") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_current_view_position") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_current_view_rotation") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_current_view_position") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_current_view_rotation") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("export_to_engine") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_config_spec") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_config_platform") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_config_spec") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_result_to_success") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_result_to_failure") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("idle_enable") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("is_idle_enabled") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("idle_is_enabled") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("idle_wait") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("idle_wait_frames") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("start_process_detached") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("launch_lua_editor") != behaviorContext->m_methods.end());
|
||||
}
|
||||
|
||||
TEST_F(CryEditPythonBindingsFixture, CryEditCheckoutDialogCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("enable_for_all") != behaviorContext->m_methods.end());
|
||||
}
|
||||
|
||||
TEST_F(CryEditPythonBindingsFixture, CryEditPython_IdleWaitFramesWorks)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = nullptr;
|
||||
AZ::ComponentApplicationBus::BroadcastResult(behaviorContext, &AZ::ComponentApplicationBus::Events::GetBehaviorContext);
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
unsigned int numTicks = 0;
|
||||
QEventLoop loop;
|
||||
QTimer timer;
|
||||
loop.connect(&timer, &QTimer::timeout, [&numTicks]()
|
||||
{
|
||||
AZ::TickBus::Broadcast(&AZ::TickEvents::OnTick, 0.01f, AZ::ScriptTimePoint(AZStd::chrono::system_clock().now()));
|
||||
++numTicks;
|
||||
});
|
||||
timer.start(100);
|
||||
|
||||
const unsigned int framesToWait = 5;
|
||||
AZStd::array<AZ::BehaviorValueParameter, 1> args;
|
||||
args[0].Set(&framesToWait);
|
||||
behaviorContext->m_methods.find("idle_wait_frames")->second->Call(args.begin(), static_cast<unsigned int>(args.size()));
|
||||
loop.disconnect(&timer);
|
||||
timer.stop();
|
||||
EXPECT_EQ(numTicks, framesToWait);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <DisplaySettings.h>
|
||||
#include <DisplaySettingsPythonFuncs.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace DisplaySettingsPythonBindingsUnitTests
|
||||
{
|
||||
|
||||
class DisplaySettingsPythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::DisplaySettingsPythonFuncsHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(DisplaySettingsPythonBindingsFixture, DisplaySettingsEditorCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_misc_editor_settings") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_misc_editor_settings") != behaviorContext->m_methods.end());
|
||||
}
|
||||
|
||||
class DisplaySettingsComponentFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::DisplaySettingsComponent::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(DisplaySettingsComponentFixture, DisplaySettingsComponent_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
auto itDisplaySettingsBus = behaviorContext->m_ebuses.find("DisplaySettingsBus");
|
||||
if (itDisplaySettingsBus != behaviorContext->m_ebuses.end())
|
||||
{
|
||||
AZ::BehaviorEBus* behaviorBus = itDisplaySettingsBus->second;
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("GetSettingsState") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetSettingsState") != behaviorBus->m_events.end());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DisplaySettingsComponentFixture, DisplaySettingsComponent_ConvertToFlagsAllUnset)
|
||||
{
|
||||
AzToolsFramework::DisplaySettingsState state;
|
||||
state.m_noCollision = false;
|
||||
state.m_noLabels = false;
|
||||
state.m_simulate = false;
|
||||
state.m_hideTracks = false;
|
||||
state.m_hideLinks = false;
|
||||
state.m_hideHelpers = false;
|
||||
state.m_showDimensionFigures = false;
|
||||
|
||||
AzToolsFramework::DisplaySettingsComponent component;
|
||||
int result = component.ConvertToFlags(state);
|
||||
int expected = 0x0;
|
||||
EXPECT_EQ(result, expected);
|
||||
}
|
||||
|
||||
TEST_F(DisplaySettingsComponentFixture, DisplaySettingsComponent_ConvertToFlagsAllSet)
|
||||
{
|
||||
AzToolsFramework::DisplaySettingsState state;
|
||||
state.m_noCollision = true;
|
||||
state.m_noLabels = true;
|
||||
state.m_simulate = true;
|
||||
state.m_hideTracks = true;
|
||||
state.m_hideLinks = true;
|
||||
state.m_hideHelpers = true;
|
||||
state.m_showDimensionFigures = true;
|
||||
|
||||
AzToolsFramework::DisplaySettingsComponent component;
|
||||
int result = component.ConvertToFlags(state);
|
||||
int expected = SETTINGS_NOCOLLISION |
|
||||
SETTINGS_NOLABELS |
|
||||
SETTINGS_PHYSICS |
|
||||
SETTINGS_HIDE_TRACKS |
|
||||
SETTINGS_HIDE_LINKS |
|
||||
SETTINGS_HIDE_HELPERS |
|
||||
SETTINGS_SHOW_DIMENSIONFIGURES;
|
||||
EXPECT_EQ(result, expected);
|
||||
}
|
||||
|
||||
TEST_F(DisplaySettingsComponentFixture, DisplaySettingsComponent_ConvertToSettingsAllSet)
|
||||
{
|
||||
int flags = SETTINGS_NOCOLLISION |
|
||||
SETTINGS_NOLABELS |
|
||||
SETTINGS_PHYSICS |
|
||||
SETTINGS_HIDE_TRACKS |
|
||||
SETTINGS_HIDE_LINKS |
|
||||
SETTINGS_HIDE_HELPERS |
|
||||
SETTINGS_SHOW_DIMENSIONFIGURES;
|
||||
|
||||
AzToolsFramework::DisplaySettingsState expected;
|
||||
expected.m_noCollision = true;
|
||||
expected.m_noLabels = true;
|
||||
expected.m_simulate = true;
|
||||
expected.m_hideTracks = true;
|
||||
expected.m_hideLinks = true;
|
||||
expected.m_hideHelpers = true;
|
||||
expected.m_showDimensionFigures = true;
|
||||
|
||||
AzToolsFramework::DisplaySettingsComponent component;
|
||||
AzToolsFramework::DisplaySettingsState result = component.ConvertToSettings(flags);
|
||||
EXPECT_EQ(result, expected);
|
||||
}
|
||||
|
||||
TEST_F(DisplaySettingsComponentFixture, DisplaySettingsComponent_ConvertToSettingsAllUnset)
|
||||
{
|
||||
int flags = 0x0;
|
||||
|
||||
AzToolsFramework::DisplaySettingsState expected;
|
||||
expected.m_noCollision = false;
|
||||
expected.m_noLabels = false;
|
||||
expected.m_simulate = false;
|
||||
expected.m_hideTracks = false;
|
||||
expected.m_hideLinks = false;
|
||||
expected.m_hideHelpers = false;
|
||||
expected.m_showDimensionFigures = false;
|
||||
|
||||
AzToolsFramework::DisplaySettingsComponent component;
|
||||
AzToolsFramework::DisplaySettingsState result = component.ConvertToSettings(flags);
|
||||
EXPECT_EQ(result, expected);
|
||||
}
|
||||
|
||||
TEST_F(DisplaySettingsComponentFixture, DisplaySettingsState_ToString)
|
||||
{
|
||||
AzToolsFramework::DisplaySettingsState state;
|
||||
state.m_noCollision = false;
|
||||
state.m_noLabels = true;
|
||||
state.m_simulate = false;
|
||||
state.m_hideTracks = true;
|
||||
state.m_hideLinks = false;
|
||||
state.m_hideHelpers = true;
|
||||
state.m_showDimensionFigures = false;
|
||||
|
||||
AZStd::string result = state.ToString();
|
||||
|
||||
EXPECT_EQ(result, "(no_collision=False, no_labels=True, simulate=False, hide_tracks=True, hide_links=False, hide_helpers=True, show_dimension_figures=False)");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <AzQtComponents/Utilities/QtPluginPaths.h>
|
||||
#include <PythonEditorFuncs.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzCore/std/containers/array.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include <Mocks/ICVarMock.h>
|
||||
#include <Mocks/ISystemMock.h>
|
||||
#include <Mocks/IConsoleMock.h>
|
||||
#include <Mocks/ILogMock.h>
|
||||
#include <Mocks/ITimerMock.h>
|
||||
#include <Mocks/IConsoleMock.h>
|
||||
#include "IEditorMock.h"
|
||||
|
||||
namespace EditorPythonBindingsUnitTests
|
||||
{
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::Return;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::A;
|
||||
using ::testing::_;
|
||||
|
||||
struct MockEditor final
|
||||
{
|
||||
~MockEditor()
|
||||
{
|
||||
SetIEditor(nullptr);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void PrepareSetCVar(int cvarType, AZStd::function<void(const T)> func)
|
||||
{
|
||||
m_cvarType = cvarType;
|
||||
ON_CALL(m_cvarMock, GetType()).WillByDefault(Return(m_cvarType));
|
||||
ON_CALL(m_cvarMock, Set(A<T>())).WillByDefault(Invoke(func));
|
||||
ON_CALL(m_console, GetCVar(_)).WillByDefault(Return(&m_cvarMock));
|
||||
ON_CALL(m_system, GetIConsole()).WillByDefault(Return(&m_console));
|
||||
ON_CALL(m_editorMock, GetSystem()).WillByDefault(Return(&m_system));
|
||||
SetIEditor(&m_editorMock);
|
||||
}
|
||||
|
||||
void PrepareGetCVarString(const char* value)
|
||||
{
|
||||
ON_CALL(m_cvarMock, GetString()).WillByDefault(Return(value));
|
||||
ON_CALL(m_console, GetCVar(_)).WillByDefault(Return(&m_cvarMock));
|
||||
ON_CALL(m_system, GetIConsole()).WillByDefault(Return(&m_console));
|
||||
ON_CALL(m_editorMock, GetSystem()).WillByDefault(Return(&m_system));
|
||||
SetIEditor(&m_editorMock);
|
||||
}
|
||||
|
||||
void PrepareGetIConsole()
|
||||
{
|
||||
ON_CALL(m_system, GetIConsole()).WillByDefault(Return(&m_console));
|
||||
ON_CALL(m_editorMock, GetSystem()).WillByDefault(Return(&m_system));
|
||||
SetIEditor(&m_editorMock);
|
||||
}
|
||||
|
||||
int m_cvarType = CVAR_INT;
|
||||
::testing::NiceMock<CEditorMock> m_editorMock;
|
||||
::testing::NiceMock<ConsoleMock> m_console;
|
||||
::testing::NiceMock<SystemMock> m_system;
|
||||
::testing::NiceMock<CVarMock> m_cvarMock;
|
||||
};
|
||||
|
||||
class EditorPythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::PythonEditorFuncsHandler::CreateDescriptor());
|
||||
// Disable saving global user settings to prevent failure due to detecting file updates
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
|
||||
using TestEditorUtilityCommandFunc = AZStd::function<void(AZ::BehaviorContext* context)>;
|
||||
void RunEditorUtilityCommandTest(TestEditorUtilityCommandFunc func)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = nullptr;
|
||||
AZ::ComponentApplicationBus::BroadcastResult(behaviorContext, &AZ::ComponentApplicationBus::Events::GetBehaviorContext);
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
func(behaviorContext);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(EditorPythonBindingsFixture, EditorUtilityCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_cvar") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_cvar_string") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_cvar_integer") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_cvar_float") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("run_console") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("enter_game_mode") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("is_in_game_mode") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("exit_game_mode") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("run_file") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("run_file_parameters") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("execute_command") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("message_box") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("message_box_yes_no") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("message_box_ok") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("edit_box") != behaviorContext->m_methods.end());
|
||||
|
||||
// Blocked by LY-101816
|
||||
//EXPECT_TRUE(behaviorContext->m_methods.find("edit_box_check_data_type") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("open_file_box") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_axis_constraint") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_axis_constraint") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_pak_from_file") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("log") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("undo") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("redo") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("draw_label") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("combo_box") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("crash") != behaviorContext->m_methods.end());
|
||||
}
|
||||
|
||||
TEST_F(EditorPythonBindingsFixture, EditorPythonBindingsComponent_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
auto itPythonEditorBus = behaviorContext->m_ebuses.find("PythonEditorBus");
|
||||
if (itPythonEditorBus != behaviorContext->m_ebuses.end())
|
||||
{
|
||||
AZ::BehaviorEBus* behaviorBus = itPythonEditorBus->second;
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("GetCVar") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetCVar") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetCVarFromString") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetCVarFromInteger") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetCVarFromFloat") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("PyRunConsole") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("EnterGameMode") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("IsInGameMode") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("ExitGameMode") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("EnterSimulationMode") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("IsInSimulationMode") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("ExitSimulationMode") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("RunLua") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("RunFile") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("RunFileParameters") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("ExecuteCommand") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("MessageBoxOkCancel") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("MessageBoxYesNo") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("MessageBoxOk") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("EditBox") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("EditBoxCheckDataType") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("OpenFileBox") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("GetAxisConstraint") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetAxisConstraint") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("GetPakFromFile") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("Log") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("Undo") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("Redo") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("DrawLabel") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("ComboBox") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetHidemaskAll") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetHidemaskNone") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetHidemaskInvert") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetHidemask") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("GetHidemask") != behaviorBus->m_events.end());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(EditorPythonBindingsFixture, EditorUtilityCommands_set_cvar_integer)
|
||||
{
|
||||
RunEditorUtilityCommandTest([](AZ::BehaviorContext* context)
|
||||
{
|
||||
int testInt = -1;
|
||||
MockEditor mockEditor;
|
||||
mockEditor.PrepareSetCVar<int>(CVAR_INT, [&testInt](const int value) { testInt = value; });
|
||||
|
||||
const char* testCvar = "test.cvar.int";
|
||||
int intArg = 1;
|
||||
AZStd::array<AZ::BehaviorValueParameter, 2> args;
|
||||
args[0].Set(&testCvar);
|
||||
args[1].Set(&intArg);
|
||||
|
||||
context->m_methods.find("set_cvar_integer")->second->Call(args.begin(), static_cast<unsigned int>(args.size()));
|
||||
EXPECT_EQ(1, testInt);
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(EditorPythonBindingsFixture, EditorUtilityCommands_set_cvar_float)
|
||||
{
|
||||
RunEditorUtilityCommandTest([](AZ::BehaviorContext* context)
|
||||
{
|
||||
float testFloat = 0.0f;
|
||||
MockEditor mockEditor;
|
||||
mockEditor.PrepareSetCVar<float>(CVAR_FLOAT, [&testFloat](const float value) { testFloat = value; });
|
||||
|
||||
const char* testCvar = "test.cvar.float";
|
||||
float input = 1.234f;
|
||||
AZStd::array<AZ::BehaviorValueParameter, 2> args;
|
||||
args[0].Set(&testCvar);
|
||||
args[1].Set(&input);
|
||||
|
||||
context->m_methods.find("set_cvar_float")->second->Call(args.begin(), static_cast<unsigned int>(args.size()));
|
||||
EXPECT_FLOAT_EQ(1.234f, testFloat);
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(EditorPythonBindingsFixture, EditorUtilityCommands_set_cvar_string)
|
||||
{
|
||||
RunEditorUtilityCommandTest([](AZ::BehaviorContext* context)
|
||||
{
|
||||
AZStd::string testString;
|
||||
MockEditor mockEditor;
|
||||
mockEditor.PrepareSetCVar<const char*>(CVAR_STRING, [&testString](const char* value) { testString = value; });
|
||||
|
||||
const char* testCvar = "test.cvar.string";
|
||||
const char* input = "testvalue";
|
||||
AZStd::array<AZ::BehaviorValueParameter, 2> args;
|
||||
args[0].Set(&testCvar);
|
||||
args[1].Set(&input);
|
||||
|
||||
context->m_methods.find("set_cvar_string")->second->Call(args.begin(), static_cast<unsigned int>(args.size()));
|
||||
EXPECT_STREQ("testvalue", testString.c_str());
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(EditorPythonBindingsFixture, EditorUtilityCommands_get_cvar)
|
||||
{
|
||||
RunEditorUtilityCommandTest([](AZ::BehaviorContext* context)
|
||||
{
|
||||
MockEditor mockEditor;
|
||||
mockEditor.PrepareGetCVarString("atestvalue");
|
||||
|
||||
const char* testCvar = "test.cvar.string";
|
||||
AZStd::array<AZ::BehaviorValueParameter, 1> args;
|
||||
args[0].Set(&testCvar);
|
||||
|
||||
const char* data;
|
||||
AZ::BehaviorObject obj;
|
||||
obj.m_typeId = azrtti_typeid<const char*>();
|
||||
obj.m_address = &data;
|
||||
|
||||
AZ::BehaviorValueParameter result;
|
||||
result.Set(&obj);
|
||||
|
||||
context->m_methods.find("get_cvar")->second->Call(args.begin(), static_cast<unsigned int>(args.size()), &result);
|
||||
EXPECT_STREQ("atestvalue", reinterpret_cast<const char*>(obj.m_address));
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(EditorPythonBindingsFixture, EditorUtilityCommands_run_console)
|
||||
{
|
||||
RunEditorUtilityCommandTest([](AZ::BehaviorContext* context)
|
||||
{
|
||||
AZStd::string data;
|
||||
MockEditor mockEditor;
|
||||
mockEditor.PrepareGetIConsole();
|
||||
ON_CALL(mockEditor.m_console, ExecuteString(_,_,_)).WillByDefault(Invoke([&data](const char* command, const bool, const bool) { data = command; }));
|
||||
|
||||
const char* testCvar = "enable_feature game.sim";
|
||||
AZStd::array<AZ::BehaviorValueParameter, 1> args;
|
||||
args[0].Set(&testCvar);
|
||||
|
||||
context->m_methods.find("run_console")->second->Call(args.begin(), static_cast<unsigned int>(args.size()));
|
||||
EXPECT_STREQ(testCvar, data.c_str());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
|
||||
namespace EditorUtilsTest
|
||||
{
|
||||
class WarningDetector
|
||||
: public AZ::Debug::TraceMessageBus::Handler
|
||||
{
|
||||
public:
|
||||
WarningDetector()
|
||||
{
|
||||
BusConnect();
|
||||
}
|
||||
|
||||
~WarningDetector()
|
||||
{
|
||||
BusDisconnect();
|
||||
}
|
||||
|
||||
virtual bool OnWarning(const char* /*window*/, const char* /*message*/) override
|
||||
{
|
||||
m_gotWarning = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool m_gotWarning = false;
|
||||
};
|
||||
|
||||
|
||||
class TestWarningAbsorber
|
||||
: public testing::Test
|
||||
{
|
||||
};
|
||||
|
||||
TEST_F(TestWarningAbsorber, Test)
|
||||
{
|
||||
WarningDetector detector;
|
||||
EditorUtils::AzWarningAbsorber absorber("ignore this");
|
||||
|
||||
AZ_Warning("ignore this", false, "This warning should occur but be absorbed by the absorber");
|
||||
ASSERT_FALSE(detector.m_gotWarning);
|
||||
|
||||
AZ_Warning("different window", false, "This warning should occur but be left alone by the absorber");
|
||||
ASSERT_TRUE(detector.m_gotWarning);
|
||||
}
|
||||
|
||||
TEST_F(TestWarningAbsorber, NullWindow)
|
||||
{
|
||||
WarningDetector detector;
|
||||
EditorUtils::AzWarningAbsorber absorber("ignore this");
|
||||
|
||||
AZ_Warning(nullptr, false, "This warning should occur and not be absorbed by the absorber since the window name is nullptr");
|
||||
ASSERT_TRUE(detector.m_gotWarning);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <EditorEnvironment.h>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
class EditorLibTestEnvironment
|
||||
: public AZ::Test::ITestEnvironment
|
||||
{
|
||||
public:
|
||||
virtual ~EditorLibTestEnvironment() {}
|
||||
|
||||
protected:
|
||||
void SetupEnvironment() override
|
||||
{
|
||||
AZ::Environment::Create(nullptr);
|
||||
AttachEditorAZEnvironment(AZ::Environment::GetInstance());
|
||||
AZ::AllocatorInstance<AZ::SystemAllocator>::Create();
|
||||
}
|
||||
|
||||
void TeardownEnvironment() override
|
||||
{
|
||||
AZ::AllocatorInstance<AZ::SystemAllocator>::Destroy();
|
||||
DetachEditorAZEnvironment();
|
||||
AZ::Environment::Destroy();
|
||||
}
|
||||
};
|
||||
|
||||
AZTEST_EXPORT int AZ_UNIT_TEST_HOOK_NAME(int argc, char** argv)
|
||||
{
|
||||
::testing::InitGoogleMock(&argc, argv);
|
||||
// NOTE - this line makes this code different from AZ_UNIT_TEST_HOOK()
|
||||
QApplication app(argc, argv);
|
||||
// end
|
||||
AZ::Test::ApplyGlobalParameters(&argc, argv);
|
||||
AZ::Test::printUnusedParametersWarning(argc, argv);
|
||||
AZ::Test::addTestEnvironments({new EditorLibTestEnvironment});
|
||||
int result = RUN_ALL_TESTS();
|
||||
return result;
|
||||
}
|
||||
|
||||
IMPLEMENT_TEST_EXECUTABLE_MAIN()
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <MainWindow.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace MainWindowPythonBindingsUnitTests
|
||||
{
|
||||
|
||||
class MainWindowPythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::MainWindowEditorFuncsHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(MainWindowPythonBindingsFixture, MainWindowEditorCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("open_pane") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("close_pane") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("is_pane_visible") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_pane_class_names") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("exit") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("exit_no_prompt") != behaviorContext->m_methods.end());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <Objects/ObjectManager.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace ObjectManagerPythonBindingsUnitTests
|
||||
{
|
||||
|
||||
class ObjectManagerPythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::ObjectManagerFuncsHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ObjectManagerPythonBindingsFixture, ObjectManagerEditorCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_all_objects") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_names_of_selected_objects") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("select_object") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("unselect_objects") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("select_objects") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_num_selected") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("clear_selection") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_selection_center") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_selection_aabb") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("hide_object") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("is_object_hidden") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("unhide_object") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("hide_all_objects") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("unhide_all_objects") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("freeze_object") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("is_object_frozen") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("unfreeze_object") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("delete_object") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("delete_selected") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_position") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_position") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_rotation") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_rotation") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_scale") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_scale") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("rename_object") != behaviorContext->m_methods.end());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <TerrainHoleTool.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace TerrainFuncsUnitTests
|
||||
{
|
||||
|
||||
class TerrainHoleToolPythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::TerrainHoleToolPythonFuncsHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(TerrainHoleToolPythonBindingsFixture, TerrainCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_brush_radius") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_brush_radius") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_make_hole") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_make_hole") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("paint_hole") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("paint_hole_direct") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("is_hole_at") != behaviorContext->m_methods.end());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <Terrain/PythonTerrainLayerFuncs.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace TerrainFuncsUnitTests
|
||||
{
|
||||
|
||||
class TerrainLayerPythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::TerrainLayerPythonFuncsHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(TerrainLayerPythonBindingsFixture, TerrainCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_tile_count_x") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_tile_count_y") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_tile_resolution") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_tile_resolution") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_tile_count") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_color_at") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("import_megaterrain") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("export_megaterrain") != behaviorContext->m_methods.end());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <TerrainModifyTool.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace TerrainModifyPythonBindingsUnitTests
|
||||
{
|
||||
|
||||
class TerrainModifyPythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::TerrainModifyPythonFuncsHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(TerrainModifyPythonBindingsFixture, TerrainModifyEditorCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_tool_flatten") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_tool_smooth") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_tool_riselower") != behaviorContext->m_methods.end());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <TerrainTexturePainter.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace TerrainFuncsUnitTests
|
||||
{
|
||||
|
||||
class TerrainPainterPythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::TerrainPainterPythonFuncsHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(TerrainPainterPythonBindingsFixture, TerrainCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_layer_painter_brush_radius") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_painter_brush_radius") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_layer_painter_brush_color_opacity") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_painter_brush_color_opacity") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_layer_painter_brush_detail_intensity") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_painter_brush_detail_intensity") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_layer_painter_brush_mask_by_layer_settings") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_painter_brush_mask_by_layer_settings") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_layer_painter_brush_mask_layer_name") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_painter_brush_mask_layer_name") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_layer_brush_color") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_brush_color") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_layer_brush_color_brightness") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_brush_color_brightness") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("paint_layer") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_layer_min_altitude") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_layer_max_altitude") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_min_altitude") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_max_altitude") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_layer_min_slope") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_layer_max_slope") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_min_slope") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_max_slope") != behaviorContext->m_methods.end());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <Terrain/PythonTerrainFuncs.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace TerrainFuncsUnitTests
|
||||
{
|
||||
|
||||
class TerrainPythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::TerrainPythonFuncsHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(TerrainPythonBindingsFixture, TerrainCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_max_height") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_max_height") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("import_heightmap") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("export_heightmap") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_elevation") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_heightmap_elevation") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_elevation") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("flatten") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("reduce_range") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("smooth") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("slope_smooth") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("erase") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("resize") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("make_isle") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("normalize") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("invert") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("fetch") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("hold") != behaviorContext->m_methods.end());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <TerrainTexture.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace TerrainFuncsUnitTests
|
||||
{
|
||||
|
||||
class TerrainTexturePythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::TerrainTexturePythonFuncsHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(TerrainTexturePythonBindingsFixture, TerrainCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("open_layers") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("create_layer") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("delete_layer") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("move_layer") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_layer_index") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_material") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_splatmap") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("import_layer_splatmaps") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("export_layer_splatmap") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_layer_name") != behaviorContext->m_methods.end());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <TrackView/TrackViewPythonFuncs.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace TrackViewPythonBindingsUnitTests
|
||||
{
|
||||
|
||||
class TrackViewPythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::TrackViewFuncsHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(TrackViewPythonBindingsFixture, TrackViewEditorCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_recording") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("new_sequence") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("delete_sequence") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_current_sequence") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_num_sequences") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_sequence_name") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_sequence_time_range") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_sequence_time_range") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("play_sequence") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("stop_sequence") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_time") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("add_node") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("add_selected_entities") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("add_layer_node") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("delete_node") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("add_track") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("delete_track") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_num_nodes") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_node_name") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_num_track_keys") != behaviorContext->m_methods.end());
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_key_value") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_interpolated_value") != behaviorContext->m_methods.end());
|
||||
}
|
||||
|
||||
class TrackViewComponentFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::TrackViewComponent::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(TrackViewComponentFixture, TrackViewComponent_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
auto itTrackViewBus = behaviorContext->m_ebuses.find("TrackViewBus");
|
||||
if (itTrackViewBus != behaviorContext->m_ebuses.end())
|
||||
{
|
||||
AZ::BehaviorEBus* behaviorBus = itTrackViewBus->second;
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("AddNode") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("AddTrack") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("AddLayerNode") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("AddSelectedEntities") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("AddNode") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("AddTrack") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("AddLayerNode") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("AddSelectedEntities") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("DeleteNode") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("DeleteTrack") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("DeleteSequence") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("GetInterpolatedValue") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("GetKeyValue") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("GetNodeName") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("GetNumNodes") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("GetNumSequences") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("GetNumTrackKeys") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("GetSequenceName") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("GetSequenceTimeRange") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("NewSequence") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("PlaySequence") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetCurrentSequence") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetRecording") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetSequenceTimeRange") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("SetTime") != behaviorBus->m_events.end());
|
||||
EXPECT_TRUE(behaviorBus->m_events.find("StopSequence") != behaviorBus->m_events.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <ViewPane.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace ViewPaneFuncsUnitTests
|
||||
{
|
||||
|
||||
class ViewPanePythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::ViewPanePythonFuncsHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ViewPanePythonBindingsFixture, ViewPaneCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_viewport_size") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_viewport_size") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("update_viewport") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("resize_viewport") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("bind_viewport") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_viewport_expansion_policy") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_viewport_expansion_policy") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_viewport_count") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_active_viewport") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_active_viewport") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("get_view_pane_layout") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("set_view_pane_layout") != behaviorContext->m_methods.end());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#include "EditorDefs.h"
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Util/EditorUtils.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <ViewportTitleDlg.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace ViewportTitleDlgFuncsUnitTests
|
||||
{
|
||||
|
||||
class ViewportTitleDlgPythonBindingsFixture
|
||||
: public testing::Test
|
||||
{
|
||||
public:
|
||||
AzToolsFramework::ToolsApplication m_app;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AzFramework::Application::Descriptor appDesc;
|
||||
appDesc.m_enableDrilling = false;
|
||||
|
||||
m_app.Start(appDesc);
|
||||
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
|
||||
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
|
||||
// in the unit tests.
|
||||
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
|
||||
m_app.RegisterComponentDescriptor(AzToolsFramework::ViewportTitleDlgPythonFuncsHandler::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_app.Stop();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ViewportTitleDlgPythonBindingsFixture, ViewportTitleDlgCommands_ApiExists)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
|
||||
ASSERT_TRUE(behaviorContext);
|
||||
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("toggle_helpers") != behaviorContext->m_methods.end());
|
||||
EXPECT_TRUE(behaviorContext->m_methods.find("is_helpers_shown") != behaviorContext->m_methods.end());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user