OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/display_change_notifier.h" | 5 #include "ui/gfx/display_change_notifier.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/gfx/display.h" | 8 #include "ui/gfx/display.h" |
9 #include "ui/gfx/display_observer.h" | 9 #include "ui/gfx/display_observer.h" |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 change_notifier.NotifyDisplaysChanged( | 63 change_notifier.NotifyDisplaysChanged( |
64 std::vector<Display>(), std::vector<Display>(1, Display())); | 64 std::vector<Display>(), std::vector<Display>(1, Display())); |
65 EXPECT_EQ(0, observer.display_added()); | 65 EXPECT_EQ(0, observer.display_added()); |
66 | 66 |
67 change_notifier.AddObserver(&observer); | 67 change_notifier.AddObserver(&observer); |
68 change_notifier.NotifyDisplaysChanged( | 68 change_notifier.NotifyDisplaysChanged( |
69 std::vector<Display>(), std::vector<Display>(1, Display())); | 69 std::vector<Display>(), std::vector<Display>(1, Display())); |
70 EXPECT_EQ(1, observer.display_added()); | 70 EXPECT_EQ(1, observer.display_added()); |
71 } | 71 } |
72 | 72 |
73 TEST(DisplayChangeNotifierTest, AddObserver_Null) { | |
74 DisplayChangeNotifier change_notifier; | |
75 | |
76 change_notifier.AddObserver(NULL); | |
77 // Should not crash. | |
78 } | |
79 | |
80 TEST(DisplayChangeNotifier, RemoveObserver_Smoke) { | 73 TEST(DisplayChangeNotifier, RemoveObserver_Smoke) { |
81 DisplayChangeNotifier change_notifier; | 74 DisplayChangeNotifier change_notifier; |
82 MockDisplayObserver observer; | 75 MockDisplayObserver observer; |
83 | 76 |
84 change_notifier.NotifyDisplaysChanged( | 77 change_notifier.NotifyDisplaysChanged( |
85 std::vector<Display>(), std::vector<Display>(1, Display())); | 78 std::vector<Display>(), std::vector<Display>(1, Display())); |
86 EXPECT_EQ(0, observer.display_added()); | 79 EXPECT_EQ(0, observer.display_added()); |
87 | 80 |
88 change_notifier.AddObserver(&observer); | 81 change_notifier.AddObserver(&observer); |
89 change_notifier.RemoveObserver(&observer); | 82 change_notifier.RemoveObserver(&observer); |
90 | 83 |
91 change_notifier.NotifyDisplaysChanged( | 84 change_notifier.NotifyDisplaysChanged( |
92 std::vector<Display>(), std::vector<Display>(1, Display())); | 85 std::vector<Display>(), std::vector<Display>(1, Display())); |
93 EXPECT_EQ(0, observer.display_added()); | 86 EXPECT_EQ(0, observer.display_added()); |
94 } | 87 } |
95 | 88 |
96 TEST(DisplayChangeNotifierTest, RemoveObserver_Null) { | |
97 DisplayChangeNotifier change_notifier; | |
98 | |
99 change_notifier.RemoveObserver(NULL); | |
100 // Should not crash. | |
101 } | |
102 | |
103 TEST(DisplayChangeNotifierTest, RemoveObserver_Unknown) { | 89 TEST(DisplayChangeNotifierTest, RemoveObserver_Unknown) { |
104 DisplayChangeNotifier change_notifier; | 90 DisplayChangeNotifier change_notifier; |
105 MockDisplayObserver observer; | 91 MockDisplayObserver observer; |
106 | 92 |
107 change_notifier.RemoveObserver(&observer); | 93 change_notifier.RemoveObserver(&observer); |
108 // Should not crash. | 94 // Should not crash. |
109 } | 95 } |
110 | 96 |
111 TEST(DisplayChangeNotifierTest, NotifyDisplaysChanged_Removed) { | 97 TEST(DisplayChangeNotifierTest, NotifyDisplaysChanged_Removed) { |
112 DisplayChangeNotifier change_notifier; | 98 DisplayChangeNotifier change_notifier; |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 change_notifier.NotifyDisplaysChanged(old_displays, new_displays); | 471 change_notifier.NotifyDisplaysChanged(old_displays, new_displays); |
486 EXPECT_EQ(1, observer.display_changed()); | 472 EXPECT_EQ(1, observer.display_changed()); |
487 uint32_t metrics = DisplayObserver::DISPLAY_METRIC_BOUNDS | | 473 uint32_t metrics = DisplayObserver::DISPLAY_METRIC_BOUNDS | |
488 DisplayObserver::DISPLAY_METRIC_ROTATION | | 474 DisplayObserver::DISPLAY_METRIC_ROTATION | |
489 DisplayObserver::DISPLAY_METRIC_WORK_AREA | | 475 DisplayObserver::DISPLAY_METRIC_WORK_AREA | |
490 DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR; | 476 DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR; |
491 EXPECT_EQ(metrics, observer.latest_metrics_change()); | 477 EXPECT_EQ(metrics, observer.latest_metrics_change()); |
492 } | 478 } |
493 | 479 |
494 } // namespace gfx | 480 } // namespace gfx |
OLD | NEW |