Add an integration test to validate pick mode crash (#2935)
* add an integration test to validate pick mode crash Signed-off-by: hultonha <hultonha@amazon.co.uk> * update to test after review feedback Signed-off-by: hultonha <hultonha@amazon.co.uk>
This commit is contained in:
+29
@@ -65,6 +65,35 @@ namespace UnitTest
|
||||
}
|
||||
}
|
||||
|
||||
bool FocusInteractionWidget::event(QEvent* event)
|
||||
{
|
||||
using AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus;
|
||||
|
||||
auto eventType = event->type();
|
||||
|
||||
switch (eventType)
|
||||
{
|
||||
case QEvent::MouseButtonPress:
|
||||
EditorInteractionSystemViewportSelectionRequestBus::Event(
|
||||
AzToolsFramework::GetEntityContextId(), &EditorInteractionSystemViewportSelectionRequestBus::Events::SetDefaultHandler);
|
||||
return true;
|
||||
case QEvent::FocusIn:
|
||||
case QEvent::FocusOut:
|
||||
{
|
||||
bool handled = false;
|
||||
AzToolsFramework::ViewportInteraction::MouseInteraction mouseInteraction;
|
||||
EditorInteractionSystemViewportSelectionRequestBus::EventResult(
|
||||
handled, AzToolsFramework::GetEntityContextId(),
|
||||
&EditorInteractionSystemViewportSelectionRequestBus::Events::InternalHandleMouseViewportInteraction,
|
||||
AzToolsFramework::ViewportInteraction::MouseInteractionEvent(
|
||||
mouseInteraction, AzToolsFramework::ViewportInteraction::MouseEvent::Down));
|
||||
return handled;
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void TestEditorActions::Connect()
|
||||
{
|
||||
using AzToolsFramework::GetEntityContextId;
|
||||
|
||||
+15
-11
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Slice/SliceAsset.h>
|
||||
@@ -31,6 +32,7 @@
|
||||
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
|
||||
#include <AzToolsFramework/SourceControl/PerforceConnection.h>
|
||||
#include <AzToolsFramework/UnitTest/ToolsTestApplication.h>
|
||||
#endif // !defined(Q_MOC_RUN)
|
||||
|
||||
#include <ostream>
|
||||
|
||||
@@ -40,7 +42,7 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
#define AUTO_RESULT_IF_SETTING_TRUE(_settingName, _result) \
|
||||
{ \
|
||||
bool settingValue = true; \
|
||||
bool settingValue = true; \
|
||||
if (auto* registry = AZ::SettingsRegistry::Get()) \
|
||||
{ \
|
||||
registry->Get(settingValue, _settingName); \
|
||||
@@ -51,23 +53,16 @@ AZ_POP_DISABLE_WARNING
|
||||
EXPECT_TRUE(_result); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class Entity;
|
||||
class EntityId;
|
||||
|
||||
} // namespace AZ
|
||||
}
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
constexpr AZStd::string_view prefabSystemSetting = "/Amazon/Preferences/EnablePrefabSystem";
|
||||
|
||||
/// Test widget to store QActions generated by EditorTransformComponentSelection.
|
||||
class TestWidget
|
||||
: public QWidget
|
||||
class TestWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestWidget()
|
||||
: QWidget()
|
||||
@@ -79,6 +74,15 @@ namespace UnitTest
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
};
|
||||
|
||||
/// Widget used to trigger a viewport interaction event while a focus change is happening.
|
||||
class FocusInteractionWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FocusInteractionWidget(QWidget* parent = nullptr) : QWidget(parent) {}
|
||||
bool event(QEvent* event) override;
|
||||
};
|
||||
|
||||
/// Stores actions registered for either normal mode (regular viewport) editing and
|
||||
/// component mode editing.
|
||||
class TestEditorActions
|
||||
|
||||
Reference in New Issue
Block a user