123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #include "AzManipulatorTestFrameworkTestFixtures.h"
- #include <AzManipulatorTestFramework/ViewportInteraction.h>
- namespace UnitTest
- {
- class AValidViewportInteraction : public ToolsApplicationFixture<>
- {
- public:
- AValidViewportInteraction()
- : m_viewportInteraction(
- AZStd::make_unique<AzManipulatorTestFramework::ViewportInteraction>(AZStd::make_shared<NullDebugDisplayRequests>()))
- {
- }
- protected:
- void SetUpEditorFixtureImpl() override
- {
- m_cameraState = AzFramework::CreateIdentityDefaultCamera(AZ::Vector3::CreateZero(), AzFramework::ScreenSize(800, 600));
- }
- public:
- AZStd::unique_ptr<AzManipulatorTestFramework::ViewportInteraction> m_viewportInteraction;
- AzFramework::CameraState m_cameraState;
- };
- TEST_F(AValidViewportInteraction, HasViewportId1234)
- {
- EXPECT_EQ(m_viewportInteraction->GetViewportId(), 1234);
- }
- TEST_F(AValidViewportInteraction, CanSetAndGetCameraState)
- {
- m_viewportInteraction->SetCameraState(m_cameraState);
- const auto cameraState = m_viewportInteraction->GetCameraState();
- EXPECT_EQ(cameraState.m_position, m_cameraState.m_position);
- EXPECT_EQ(cameraState.m_forward, m_cameraState.m_forward);
- }
- TEST_F(AValidViewportInteraction, CanEnableGridSnapping)
- {
- bool snapping = false;
- m_viewportInteraction->SetGridSnapping(true);
- AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
- snapping, m_viewportInteraction->GetViewportId(),
- &AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::GridSnappingEnabled);
- EXPECT_TRUE(snapping);
- }
- TEST_F(AValidViewportInteraction, CanDisableGridSnapping)
- {
- bool snapping = true;
- m_viewportInteraction->SetGridSnapping(false);
- AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
- snapping, m_viewportInteraction->GetViewportId(),
- &AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::GridSnappingEnabled);
- EXPECT_FALSE(snapping);
- }
- TEST_F(AValidViewportInteraction, CanGetAndSetGridSize)
- {
- float gridSize = 0.0f;
- const float expectedGridSize = 50.0f;
- m_viewportInteraction->SetGridSize(expectedGridSize);
- m_viewportInteraction->SetGridSnapping(false);
- AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
- gridSize, m_viewportInteraction->GetViewportId(),
- &AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::GridSize);
- EXPECT_EQ(gridSize, expectedGridSize);
- }
- TEST_F(AValidViewportInteraction, CanEnableAngularSnapping)
- {
- bool snapping = false;
- m_viewportInteraction->SetAngularSnapping(true);
- AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
- snapping, m_viewportInteraction->GetViewportId(),
- &AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::AngleSnappingEnabled);
- EXPECT_TRUE(snapping);
- }
- TEST_F(AValidViewportInteraction, CanDisableAngularSnapping)
- {
- bool snapping = true;
- m_viewportInteraction->SetAngularSnapping(false);
- AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
- snapping, m_viewportInteraction->GetViewportId(),
- &AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::AngleSnappingEnabled);
- EXPECT_FALSE(snapping);
- }
- TEST_F(AValidViewportInteraction, CanGetAndSetAngleStep)
- {
- float angularStep = 0.0f;
- const float expectedAngularStep = 50.0f;
- m_viewportInteraction->SetAngularStep(expectedAngularStep);
- AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::EventResult(
- angularStep, m_viewportInteraction->GetViewportId(),
- &AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::AngleStep);
- EXPECT_EQ(angularStep, expectedAngularStep);
- }
- TEST_F(AValidViewportInteraction, HasAValidGetDebugDisplay)
- {
- AzFramework::DebugDisplayRequests& debugDisplay = m_viewportInteraction->GetDebugDisplay();
- EXPECT_NE(nullptr, &debugDisplay);
- }
- } // namespace UnitTest
|