CursorStateTests.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/UnitTest/TestTypes.h>
  9. #include <AzFramework/Viewport/CursorState.h>
  10. #include <Tests/Utils/Printers.h>
  11. namespace UnitTest
  12. {
  13. using AzFramework::CursorState;
  14. using AzFramework::ScreenPoint;
  15. using AzFramework::ScreenVector;
  16. class CursorStateFixture : public ::testing::Test
  17. {
  18. public:
  19. CursorState m_cursorState;
  20. };
  21. TEST_F(CursorStateFixture, CursorStateHasZeroDeltaInitially)
  22. {
  23. using ::testing::Eq;
  24. EXPECT_THAT(m_cursorState.CursorDelta(), Eq(ScreenVector(0, 0)));
  25. }
  26. TEST_F(CursorStateFixture, CursorStateReturnsZeroDeltaAfterSingleMoveAndUpdate)
  27. {
  28. using ::testing::Eq;
  29. m_cursorState.SetCurrentPosition(ScreenPoint(10, 10));
  30. m_cursorState.Update();
  31. EXPECT_THAT(m_cursorState.CursorDelta(), Eq(ScreenVector(0, 0)));
  32. }
  33. TEST_F(CursorStateFixture, CursorStateReturnsDeltaAfterSecondMoveAndUpdate)
  34. {
  35. using ::testing::Eq;
  36. m_cursorState.SetCurrentPosition(ScreenPoint(10, 10));
  37. m_cursorState.Update();
  38. m_cursorState.SetCurrentPosition(ScreenPoint(15, 22));
  39. EXPECT_THAT(m_cursorState.CursorDelta(), Eq(ScreenVector(5, 12)));
  40. }
  41. } // namespace UnitTest