Formatting-only change - Update Manipulator and Viewport AzToolsFramework files (#1143)

* formatting changes to AzToolsFramework viewport related types + API comment style updates

* minor format change - include ordering

* improve formatting by moving comment

* fix compile error and switch to use AZ_Printf

* small polish changes after review feedback
This commit is contained in:
Tom Hulton-Harrop
2021-06-07 14:50:49 +01:00
committed by GitHub
parent c751cda73d
commit cf8a6761bf
83 changed files with 4455 additions and 4509 deletions
@@ -1,30 +1,31 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "ComponentModeTestDoubles.h"
#include "ComponentModeTestFixture.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzFramework/Components/TransformComponent.h>
#include <AzFramework/Entity/EntityContext.h>
#include <AzTest/AzTest.h>
#include <AzToolsFramework/Application/ToolsApplication.h>
#include <AzToolsFramework/API/EntityCompositionRequestBus.h>
#include <AzToolsFramework/Application/ToolsApplication.h>
#include <AzToolsFramework/ComponentMode/ComponentModeCollection.h>
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
#include <AzToolsFramework/ToolsComponents/EditorLockComponent.h>
#include <AzToolsFramework/ToolsComponents/EditorVisibilityComponent.h>
#include <AzToolsFramework/ToolsComponents/EditorPendingCompositionBus.h>
#include <AzToolsFramework/ToolsComponents/EditorVisibilityComponent.h>
#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
#include <AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.hxx>
#include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
@@ -32,7 +33,6 @@
#include <AzToolsFramework/ViewportSelection/EditorDefaultSelection.h>
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
#include <AzToolsFramework/ViewportSelection/EditorVisibleEntityDataCache.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <QApplication>
namespace UnitTest
@@ -47,19 +47,16 @@ namespace UnitTest
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Given
QWidget rootWidget;
ActionOverrideRequestBus::Event(
GetEntityContextId(), &ActionOverrideRequests::SetupActionOverrideHandler, &rootWidget);
ActionOverrideRequestBus::Event(GetEntityContextId(), &ActionOverrideRequests::SetupActionOverrideHandler, &rootWidget);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// When
ComponentModeSystemRequestBus::Broadcast(
&ComponentModeSystemRequests::BeginComponentMode,
AZStd::vector<EntityAndComponentModeBuilders>{});
&ComponentModeSystemRequests::BeginComponentMode, AZStd::vector<EntityAndComponentModeBuilders>{});
bool inComponentMode = false;
ComponentModeSystemRequestBus::BroadcastResult(
inComponentMode, &ComponentModeSystemRequests::InComponentMode);
ComponentModeSystemRequestBus::BroadcastResult(inComponentMode, &ComponentModeSystemRequests::InComponentMode);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -69,11 +66,9 @@ namespace UnitTest
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// When
ComponentModeSystemRequestBus::Broadcast(
&ComponentModeSystemRequests::EndComponentMode);
ComponentModeSystemRequestBus::Broadcast(&ComponentModeSystemRequests::EndComponentMode);
ComponentModeSystemRequestBus::BroadcastResult(
inComponentMode, &ComponentModeSystemRequests::InComponentMode);
ComponentModeSystemRequestBus::BroadcastResult(inComponentMode, &ComponentModeSystemRequests::InComponentMode);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -81,8 +76,7 @@ namespace UnitTest
EXPECT_FALSE(inComponentMode);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
ActionOverrideRequestBus::Event(
GetEntityContextId(), &ActionOverrideRequests::TeardownActionOverrideHandler);
ActionOverrideRequestBus::Event(GetEntityContextId(), &ActionOverrideRequests::TeardownActionOverrideHandler);
}
TEST_F(ComponentModeTestFixture, TwoComponentsOnSingleEntityWithSameComponentModeBothBegin)
@@ -104,8 +98,7 @@ namespace UnitTest
// mimic selecting the entity in the viewport (after selection the ComponentModeDelegate
// connects to the ComponentModeDelegateRequestBus on the entity/component pair address)
const AzToolsFramework::EntityIdList entityIds = { entityId };
ToolsApplicationRequestBus::Broadcast(
&ToolsApplicationRequests::SetSelectedEntities, entityIds);
ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequests::SetSelectedEntities, entityIds);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -113,8 +106,7 @@ namespace UnitTest
// move all selected components into ComponentMode
// (mimic pressing the 'Edit' button to begin Component Mode)
ComponentModeSystemRequestBus::Broadcast(
&ComponentModeSystemRequests::AddSelectedComponentModesOfType,
AZ::AzTypeInfo<PlaceholderEditorComponent>::Uuid());
&ComponentModeSystemRequests::AddSelectedComponentModesOfType, AZ::AzTypeInfo<PlaceholderEditorComponent>::Uuid());
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -152,8 +144,7 @@ namespace UnitTest
// mimic selecting the entity in the viewport (after selection the ComponentModeDelegate
// connects to the ComponentModeDelegateRequestBus on the entity/component pair address)
const AzToolsFramework::EntityIdList entityIds = { entityId };
ToolsApplicationRequestBus::Broadcast(
&ToolsApplicationRequests::SetSelectedEntities, entityIds);
ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequests::SetSelectedEntities, entityIds);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -161,8 +152,7 @@ namespace UnitTest
// move all selected components into ComponentMode
// (mimic pressing the 'Edit' button to begin Component Mode)
ComponentModeSystemRequestBus::Broadcast(
&ComponentModeSystemRequests::AddSelectedComponentModesOfType,
AZ::AzTypeInfo<PlaceholderEditorComponent>::Uuid());
&ComponentModeSystemRequests::AddSelectedComponentModesOfType, AZ::AzTypeInfo<PlaceholderEditorComponent>::Uuid());
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -202,8 +192,7 @@ namespace UnitTest
// mimic selecting the entity in the viewport (after selection the ComponentModeDelegate
// connects to the ComponentModeDelegateRequestBus on the entity/component pair address)
const AzToolsFramework::EntityIdList entityIds = { entityId };
ToolsApplicationRequestBus::Broadcast(
&ToolsApplicationRequests::SetSelectedEntities, entityIds);
ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequests::SetSelectedEntities, entityIds);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -211,16 +200,13 @@ namespace UnitTest
// move all selected components into ComponentMode
// (mimic pressing the 'Edit' button to begin Component Mode)
ComponentModeSystemRequestBus::Broadcast(
&ComponentModeSystemRequests::AddSelectedComponentModesOfType,
AZ::AzTypeInfo<PlaceholderEditorComponent>::Uuid());
&ComponentModeSystemRequests::AddSelectedComponentModesOfType, AZ::AzTypeInfo<PlaceholderEditorComponent>::Uuid());
bool nextModeCycled = true;
ComponentModeSystemRequestBus::BroadcastResult(
nextModeCycled, &ComponentModeSystemRequests::SelectNextActiveComponentMode);
ComponentModeSystemRequestBus::BroadcastResult(nextModeCycled, &ComponentModeSystemRequests::SelectNextActiveComponentMode);
bool previousModeCycled = true;
ComponentModeSystemRequestBus::BroadcastResult(
previousModeCycled, &ComponentModeSystemRequests::SelectPreviousActiveComponentMode);
ComponentModeSystemRequestBus::BroadcastResult(previousModeCycled, &ComponentModeSystemRequests::SelectPreviousActiveComponentMode);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -250,8 +236,7 @@ namespace UnitTest
// mimic selecting the entity in the viewport (after selection the ComponentModeDelegate
// connects to the ComponentModeDelegateRequestBus on the entity/component pair address)
const AzToolsFramework::EntityIdList entityIds = { entityId };
ToolsApplicationRequestBus::Broadcast(
&ToolsApplicationRequests::SetSelectedEntities, entityIds);
ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequests::SetSelectedEntities, entityIds);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -259,15 +244,13 @@ namespace UnitTest
// move all selected components into ComponentMode
// (mimic pressing the 'Edit' button to begin Component Mode)
ComponentModeSystemRequestBus::Broadcast(
&ComponentModeSystemRequests::AddSelectedComponentModesOfType,
AZ::AzTypeInfo<PlaceholderEditorComponent>::Uuid());
&ComponentModeSystemRequests::AddSelectedComponentModesOfType, AZ::AzTypeInfo<PlaceholderEditorComponent>::Uuid());
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Then
bool multipleComponentModeTypes = true;
ComponentModeSystemRequestBus::BroadcastResult(
multipleComponentModeTypes, &ComponentModeSystemRequests::HasMultipleComponentTypes);
ComponentModeSystemRequestBus::BroadcastResult(multipleComponentModeTypes, &ComponentModeSystemRequests::HasMultipleComponentTypes);
EXPECT_FALSE(multipleComponentModeTypes);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -294,8 +277,7 @@ namespace UnitTest
// mimic selecting the entity in the viewport (after selection the ComponentModeDelegate
// connects to the ComponentModeDelegateRequestBus on the entity/component pair address)
const AzToolsFramework::EntityIdList entityIds = { entityId };
ToolsApplicationRequestBus::Broadcast(
&ToolsApplicationRequests::SetSelectedEntities, entityIds);
ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequests::SetSelectedEntities, entityIds);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -303,15 +285,13 @@ namespace UnitTest
// move all selected components into ComponentMode
// (mimic pressing the 'Edit' button to begin Component Mode)
ComponentModeSystemRequestBus::Broadcast(
&ComponentModeSystemRequests::AddSelectedComponentModesOfType,
AZ::AzTypeInfo<AnotherPlaceholderEditorComponent>::Uuid());
&ComponentModeSystemRequests::AddSelectedComponentModesOfType, AZ::AzTypeInfo<AnotherPlaceholderEditorComponent>::Uuid());
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Then
bool multipleComponentModeTypes = true;
ComponentModeSystemRequestBus::BroadcastResult(
multipleComponentModeTypes, &ComponentModeSystemRequests::HasMultipleComponentTypes);
ComponentModeSystemRequestBus::BroadcastResult(multipleComponentModeTypes, &ComponentModeSystemRequests::HasMultipleComponentTypes);
EXPECT_FALSE(multipleComponentModeTypes);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -341,8 +321,7 @@ namespace UnitTest
// mimic selecting the entity in the viewport (after selection the ComponentModeDelegate
// connects to the ComponentModeDelegateRequestBus on the entity/component pair address)
const AzToolsFramework::EntityIdList entityIds = { entityId };
ToolsApplicationRequestBus::Broadcast(
&ToolsApplicationRequests::SetSelectedEntities, entityIds);
ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequests::SetSelectedEntities, entityIds);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -350,15 +329,13 @@ namespace UnitTest
// move all selected components into ComponentMode
// (mimic pressing the 'Edit' button to begin Component Mode)
ComponentModeSystemRequestBus::Broadcast(
&ComponentModeSystemRequests::AddSelectedComponentModesOfType,
AZ::AzTypeInfo<DependentPlaceholderEditorComponent>::Uuid());
&ComponentModeSystemRequests::AddSelectedComponentModesOfType, AZ::AzTypeInfo<DependentPlaceholderEditorComponent>::Uuid());
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Then
bool multipleComponentModeTypes = false;
ComponentModeSystemRequestBus::BroadcastResult(
multipleComponentModeTypes, &ComponentModeSystemRequests::HasMultipleComponentTypes);
ComponentModeSystemRequestBus::BroadcastResult(multipleComponentModeTypes, &ComponentModeSystemRequests::HasMultipleComponentTypes);
bool secondComponentModeInstantiated = false;
ComponentModeSystemRequestBus::BroadcastResult(
@@ -366,8 +343,7 @@ namespace UnitTest
AZ::EntityComponentIdPair(entityId, placeholder2->GetId()));
AZ::Uuid activeComponentType = AZ::Uuid::CreateNull();
ComponentModeSystemRequestBus::BroadcastResult(
activeComponentType, &ComponentModeSystemRequests::ActiveComponentMode);
ComponentModeSystemRequestBus::BroadcastResult(activeComponentType, &ComponentModeSystemRequests::ActiveComponentMode);
EXPECT_TRUE(multipleComponentModeTypes);
EXPECT_TRUE(secondComponentModeInstantiated);
@@ -412,13 +388,11 @@ namespace UnitTest
// Component Mode is will sent the notification to the correct address.
ComponentModeActionSignalRequestBus::Event(
AZ::EntityComponentIdPair(entityId, placeholder1->GetId()),
&ComponentModeActionSignalRequests::SetComponentModeActionNotificationBusToNotify,
checkerBusId);
&ComponentModeActionSignalRequests::SetComponentModeActionNotificationBusToNotify, checkerBusId);
ComponentModeActionSignalRequestBus::Event(
AZ::EntityComponentIdPair(entityId, placeholder2->GetId()),
&ComponentModeActionSignalRequests::SetComponentModeActionNotificationBusToNotify,
checkerBusId);
&ComponentModeActionSignalRequests::SetComponentModeActionNotificationBusToNotify, checkerBusId);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -470,8 +444,7 @@ namespace UnitTest
using MouseInteractionResult = AzToolsFramework::ViewportInteraction::MouseInteractionResult;
MouseInteractionResult handled = MouseInteractionResult::None;
EditorInteractionSystemViewportSelectionRequestBus::BroadcastResult(
handled, &EditorInteractionSystemViewportSelectionRequestBus::Events::InternalHandleAllMouseInteractions,
interactionEvent);
handled, &EditorInteractionSystemViewportSelectionRequestBus::Events::InternalHandleAllMouseInteractions, interactionEvent);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -482,8 +455,7 @@ namespace UnitTest
}
// Test version of EntityPropertyEditor to detect/ensure certain functions were called
class TestEntityPropertyEditor
: public AzToolsFramework::EntityPropertyEditor
class TestEntityPropertyEditor : public AzToolsFramework::EntityPropertyEditor
{
public:
void InvalidatePropertyDisplay(PropertyModificationRefreshLevel level) override;
@@ -496,8 +468,7 @@ namespace UnitTest
}
// Simple fixture to encapsulate a TestEntityPropertyEditor
class ComponentModePinnedSelectionFixture
: public ToolsApplicationFixture
class ComponentModePinnedSelectionFixture : public ToolsApplicationFixture
{
public:
void SetUpEditorFixtureImpl() override
@@ -533,7 +504,7 @@ namespace UnitTest
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// When
// select entity
const auto selectedEntities = AzToolsFramework::EntityIdList { entityId };
const auto selectedEntities = AzToolsFramework::EntityIdList{ entityId };
SelectEntities(selectedEntities);
// pin entity
@@ -549,8 +520,7 @@ namespace UnitTest
EXPECT_TRUE(m_testEntityPropertyEditor->IsLockedToSpecificEntities());
EXPECT_TRUE(m_testEntityPropertyEditor->m_invalidatePropertyDisplayCalled);
bool couldBeginComponentMode =
AzToolsFramework::ComponentModeFramework::CouldBeginComponentModeWithEntity(entityId);
bool couldBeginComponentMode = AzToolsFramework::ComponentModeFramework::CouldBeginComponentModeWithEntity(entityId);
EXPECT_FALSE(couldBeginComponentMode);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -566,29 +536,26 @@ namespace UnitTest
entity->Deactivate();
AzToolsFramework::EntityCompositionRequestBus::Broadcast(
&AzToolsFramework::EntityCompositionRequestBus::Events::AddComponentsToEntities,
AzToolsFramework::EntityIdList{entityId},
&AzToolsFramework::EntityCompositionRequestBus::Events::AddComponentsToEntities, AzToolsFramework::EntityIdList{ entityId },
AZ::ComponentTypeList{ AZ::AzTypeInfo<AnotherPlaceholderEditorComponent>::Uuid() });
AzToolsFramework::EntityCompositionRequestBus::Broadcast(
&AzToolsFramework::EntityCompositionRequestBus::Events::AddComponentsToEntities,
AzToolsFramework::EntityIdList{entityId},
AZ::ComponentTypeList{AZ::AzTypeInfo<IncompatiblePlaceholderEditorComponent>::Uuid()});
&AzToolsFramework::EntityCompositionRequestBus::Events::AddComponentsToEntities, AzToolsFramework::EntityIdList{ entityId },
AZ::ComponentTypeList{ AZ::AzTypeInfo<IncompatiblePlaceholderEditorComponent>::Uuid() });
entity->Activate();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// When
SelectEntities(AzToolsFramework::EntityIdList{entityId});
SelectEntities(AzToolsFramework::EntityIdList{ entityId });
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Then
AZ::Entity::ComponentArrayType pendingComponents;
AzToolsFramework::EditorPendingCompositionRequestBus::Event(
entityId, &AzToolsFramework::EditorPendingCompositionRequestBus::Events::GetPendingComponents,
pendingComponents);
entityId, &AzToolsFramework::EditorPendingCompositionRequestBus::Events::GetPendingComponents, pendingComponents);
// ensure we do have pending components
EXPECT_EQ(pendingComponents.size(), 1);