notification_manager_unittest.cc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/keyboard/ui/notification_manager.h"
  5. #include "testing/gtest/include/gtest/gtest.h"
  6. namespace keyboard {
  7. TEST(NotificationManagerTest, DoesNotSendIfSameAsInitialState) {
  8. NotificationManager manager;
  9. EXPECT_FALSE(manager.ShouldSendVisibilityNotification(false));
  10. EXPECT_FALSE(manager.ShouldSendVisualBoundsNotification(gfx::Rect()));
  11. EXPECT_FALSE(manager.ShouldSendOccludedBoundsNotification(gfx::Rect()));
  12. EXPECT_FALSE(
  13. manager.ShouldSendWorkspaceDisplacementBoundsNotification(gfx::Rect()));
  14. }
  15. TEST(NotificationManagerTest, ConsolidatesVisibilityChanges) {
  16. NotificationManager manager;
  17. EXPECT_TRUE(manager.ShouldSendVisibilityNotification(true));
  18. EXPECT_FALSE(manager.ShouldSendVisibilityNotification(true));
  19. EXPECT_TRUE(manager.ShouldSendVisibilityNotification(false));
  20. }
  21. TEST(NotificationManagerTest, ConsolidatesVisualBoundsChanges) {
  22. NotificationManager manager;
  23. EXPECT_TRUE(
  24. manager.ShouldSendVisualBoundsNotification(gfx::Rect(10, 10, 10, 10)));
  25. EXPECT_FALSE(
  26. manager.ShouldSendVisualBoundsNotification(gfx::Rect(10, 10, 10, 10)));
  27. EXPECT_TRUE(
  28. manager.ShouldSendVisualBoundsNotification(gfx::Rect(10, 10, 20, 20)));
  29. // This is technically empty
  30. EXPECT_TRUE(
  31. manager.ShouldSendVisualBoundsNotification(gfx::Rect(0, 0, 0, 100)));
  32. // This is still empty
  33. EXPECT_FALSE(
  34. manager.ShouldSendVisualBoundsNotification(gfx::Rect(0, 0, 100, 0)));
  35. }
  36. TEST(NotificationManagerTest, ConsolidatesOccludedBoundsChanges) {
  37. NotificationManager manager;
  38. // Still empty
  39. EXPECT_FALSE(
  40. manager.ShouldSendOccludedBoundsNotification(gfx::Rect(0, 0, 10, 0)));
  41. EXPECT_TRUE(
  42. manager.ShouldSendOccludedBoundsNotification(gfx::Rect(0, 0, 10, 10)));
  43. // Different bounds, same size
  44. EXPECT_TRUE(
  45. manager.ShouldSendOccludedBoundsNotification(gfx::Rect(30, 30, 10, 10)));
  46. }
  47. } // namespace keyboard