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:
@@ -31,8 +31,10 @@
|
||||
#include <AzToolsFramework/Viewport/ActionBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorDefaultSelection.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorPickEntitySelection.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorVisibleEntityDataCache.h>
|
||||
#include <AzToolsFramework/ViewportUi/ViewportUiManager.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -188,6 +190,47 @@ namespace UnitTest
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// EditorTransformComponentSelection Tests
|
||||
|
||||
TEST_F(EditorTransformComponentSelectionFixture, Focus_is_not_changed_while_switching_viewport_interaction_request_instance)
|
||||
{
|
||||
// setup a dummy widget and make it the active window to ensure focus in/out events are fired
|
||||
auto dummyWidget = AZStd::make_unique<QWidget>();
|
||||
QApplication::setActiveWindow(dummyWidget.get());
|
||||
|
||||
// note: it is important to make sure the focus widget is parented to the dummy widget to have focus in/out events fire
|
||||
auto focusWidget = AZStd::make_unique<UnitTest::FocusInteractionWidget>(dummyWidget.get());
|
||||
|
||||
const auto previousFocusWidget = QApplication::focusWidget();
|
||||
|
||||
// Given
|
||||
// setup viewport ui system
|
||||
AzToolsFramework::ViewportUi::ViewportUiManager viewportUiManager;
|
||||
viewportUiManager.ConnectViewportUiBus(AzToolsFramework::ViewportUi::DefaultViewportId);
|
||||
viewportUiManager.InitializeViewportUi(&m_editorActions.m_defaultWidget, focusWidget.get());
|
||||
|
||||
// begin EditorPickEntitySelection
|
||||
using AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus;
|
||||
EditorInteractionSystemViewportSelectionRequestBus::Event(
|
||||
AzToolsFramework::GetEntityContextId(), &EditorInteractionSystemViewportSelectionRequestBus::Events::SetHandler,
|
||||
[](const AzToolsFramework::EditorVisibleEntityDataCache* entityDataCache)
|
||||
{
|
||||
return AZStd::make_unique<AzToolsFramework::EditorPickEntitySelection>(entityDataCache);
|
||||
});
|
||||
|
||||
// When
|
||||
// a mouse event is sent to the focus widget (set to be the render overlay in the viewport ui system)
|
||||
QTest::mouseClick(focusWidget.get(), Qt::MouseButton::LeftButton);
|
||||
|
||||
// Then
|
||||
// focus should not change
|
||||
EXPECT_FALSE(focusWidget->hasFocus());
|
||||
EXPECT_EQ(previousFocusWidget, QApplication::focusWidget());
|
||||
|
||||
// clean up
|
||||
viewportUiManager.DisconnectViewportUiBus();
|
||||
focusWidget.reset();
|
||||
dummyWidget.reset();
|
||||
}
|
||||
|
||||
TEST_F(EditorTransformComponentSelectionFixture, ManipulatorOrientationIsResetWhenEntityOrientationIsReset)
|
||||
{
|
||||
using AzToolsFramework::EditorTransformComponentSelectionRequestBus;
|
||||
|
||||
Reference in New Issue
Block a user