OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/common/system/tray/system_tray.h" | 5 #include "ash/common/system/tray/system_tray.h" |
6 | 6 |
| 7 #include <string> |
7 #include <vector> | 8 #include <vector> |
8 | 9 |
9 #include "ash/common/accessibility_delegate.h" | 10 #include "ash/common/accessibility_delegate.h" |
10 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
11 #include "ash/common/shell_window_ids.h" | 12 #include "ash/common/shell_window_ids.h" |
12 #include "ash/common/system/status_area_widget.h" | 13 #include "ash/common/system/status_area_widget.h" |
13 #include "ash/common/system/tray/system_tray_bubble.h" | 14 #include "ash/common/system/tray/system_tray_bubble.h" |
14 #include "ash/common/system/tray/system_tray_item.h" | 15 #include "ash/common/system/tray/system_tray_item.h" |
15 #include "ash/common/system/tray/tray_constants.h" | 16 #include "ash/common/system/tray/tray_constants.h" |
16 #include "ash/common/system/tray/tray_popup_item_container.h" | 17 #include "ash/common/system/tray/tray_popup_item_container.h" |
17 #include "ash/common/system/web_notification/web_notification_tray.h" | 18 #include "ash/common/system/web_notification/web_notification_tray.h" |
18 #include "ash/common/wm_root_window_controller.h" | 19 #include "ash/common/wm_root_window_controller.h" |
19 #include "ash/common/wm_shell.h" | 20 #include "ash/common/wm_shell.h" |
20 #include "ash/common/wm_window.h" | 21 #include "ash/common/wm_window.h" |
21 #include "ash/test/ash_test_base.h" | 22 #include "ash/test/ash_test_base.h" |
22 #include "ash/test/status_area_widget_test_helper.h" | 23 #include "ash/test/status_area_widget_test_helper.h" |
| 24 #include "ash/test/test_system_tray_item.h" |
23 #include "base/run_loop.h" | 25 #include "base/run_loop.h" |
24 #include "base/strings/utf_string_conversions.h" | 26 #include "base/test/histogram_tester.h" |
25 #include "ui/base/ui_base_types.h" | 27 #include "ui/base/ui_base_types.h" |
26 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 28 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
27 #include "ui/events/test/event_generator.h" | 29 #include "ui/events/test/event_generator.h" |
28 #include "ui/gfx/geometry/point.h" | 30 #include "ui/gfx/geometry/point.h" |
29 #include "ui/gfx/geometry/rect.h" | 31 #include "ui/gfx/geometry/rect.h" |
30 #include "ui/views/controls/label.h" | |
31 #include "ui/views/layout/fill_layout.h" | |
32 #include "ui/views/view.h" | 32 #include "ui/views/view.h" |
33 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
34 #include "ui/views/widget/widget_delegate.h" | 34 #include "ui/views/widget/widget_delegate.h" |
35 | 35 |
36 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
37 #include "base/win/windows_version.h" | 37 #include "base/win/windows_version.h" |
38 #endif | 38 #endif |
39 | 39 |
40 namespace ash { | 40 namespace ash { |
41 namespace test { | 41 namespace test { |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 // Trivial item implementation that tracks its views for testing. | 45 const char kVisibleRowsHistogramName[] = |
46 class TestItem : public SystemTrayItem { | 46 "Ash.SystemMenu.DefaultView.VisibleRows"; |
47 public: | |
48 TestItem() | |
49 : SystemTrayItem(AshTestBase::GetPrimarySystemTray()), | |
50 tray_view_(nullptr), | |
51 default_view_(nullptr), | |
52 detailed_view_(nullptr), | |
53 notification_view_(nullptr) {} | |
54 | |
55 views::View* CreateTrayView(LoginStatus status) override { | |
56 tray_view_ = new views::View; | |
57 // Add a label so it has non-zero width. | |
58 tray_view_->SetLayoutManager(new views::FillLayout); | |
59 tray_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Tray"))); | |
60 return tray_view_; | |
61 } | |
62 | |
63 views::View* CreateDefaultView(LoginStatus status) override { | |
64 default_view_ = new views::View; | |
65 default_view_->SetLayoutManager(new views::FillLayout); | |
66 default_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Default"))); | |
67 return default_view_; | |
68 } | |
69 | |
70 views::View* CreateDetailedView(LoginStatus status) override { | |
71 detailed_view_ = new views::View; | |
72 detailed_view_->SetLayoutManager(new views::FillLayout); | |
73 detailed_view_->AddChildView( | |
74 new views::Label(base::UTF8ToUTF16("Detailed"))); | |
75 return detailed_view_; | |
76 } | |
77 | |
78 views::View* CreateNotificationView(LoginStatus status) override { | |
79 notification_view_ = new views::View; | |
80 return notification_view_; | |
81 } | |
82 | |
83 void DestroyTrayView() override { tray_view_ = NULL; } | |
84 | |
85 void DestroyDefaultView() override { default_view_ = NULL; } | |
86 | |
87 void DestroyDetailedView() override { detailed_view_ = NULL; } | |
88 | |
89 void DestroyNotificationView() override { notification_view_ = NULL; } | |
90 | |
91 void UpdateAfterLoginStatusChange(LoginStatus status) override {} | |
92 | |
93 views::View* tray_view() const { return tray_view_; } | |
94 views::View* default_view() const { return default_view_; } | |
95 views::View* detailed_view() const { return detailed_view_; } | |
96 views::View* notification_view() const { return notification_view_; } | |
97 | |
98 private: | |
99 views::View* tray_view_; | |
100 views::View* default_view_; | |
101 views::View* detailed_view_; | |
102 views::View* notification_view_; | |
103 }; | |
104 | |
105 // Trivial item implementation that returns NULL from tray/default/detailed | |
106 // view creation methods. | |
107 class TestNoViewItem : public SystemTrayItem { | |
108 public: | |
109 TestNoViewItem() : SystemTrayItem(AshTestBase::GetPrimarySystemTray()) {} | |
110 | |
111 views::View* CreateTrayView(LoginStatus status) override { return nullptr; } | |
112 | |
113 views::View* CreateDefaultView(LoginStatus status) override { | |
114 return nullptr; | |
115 } | |
116 | |
117 views::View* CreateDetailedView(LoginStatus status) override { | |
118 return nullptr; | |
119 } | |
120 | |
121 views::View* CreateNotificationView(LoginStatus status) override { | |
122 return nullptr; | |
123 } | |
124 | |
125 void DestroyTrayView() override {} | |
126 void DestroyDefaultView() override {} | |
127 void DestroyDetailedView() override {} | |
128 void DestroyNotificationView() override {} | |
129 void UpdateAfterLoginStatusChange(LoginStatus status) override {} | |
130 }; | |
131 | 47 |
132 class ModalWidgetDelegate : public views::WidgetDelegateView { | 48 class ModalWidgetDelegate : public views::WidgetDelegateView { |
133 public: | 49 public: |
134 ModalWidgetDelegate() {} | 50 ModalWidgetDelegate() {} |
135 ~ModalWidgetDelegate() override {} | 51 ~ModalWidgetDelegate() override {} |
136 | 52 |
137 views::View* GetContentsView() override { return this; } | 53 views::View* GetContentsView() override { return this; } |
138 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_SYSTEM; } | 54 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_SYSTEM; } |
139 | 55 |
140 private: | 56 private: |
141 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); | 57 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); |
142 }; | 58 }; |
143 | 59 |
144 } // namespace | 60 } // namespace |
145 | 61 |
146 typedef AshTestBase SystemTrayTest; | 62 typedef AshTestBase SystemTrayTest; |
147 | 63 |
| 64 // Verifies only the visible default views are recorded in the |
| 65 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. |
| 66 TEST_F(SystemTrayTest, OnlyVisibleItemsRecorded) { |
| 67 SystemTray* tray = GetPrimarySystemTray(); |
| 68 ASSERT_TRUE(tray->GetWidget()); |
| 69 |
| 70 TestSystemTrayItem* test_item = new TestSystemTrayItem(); |
| 71 tray->AddTrayItem(test_item); |
| 72 |
| 73 base::HistogramTester histogram_tester; |
| 74 |
| 75 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 76 RunAllPendingInMessageLoop(); |
| 77 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName, |
| 78 SystemTrayItem::UMA_TEST, 1); |
| 79 |
| 80 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 81 RunAllPendingInMessageLoop(); |
| 82 |
| 83 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 84 RunAllPendingInMessageLoop(); |
| 85 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName, |
| 86 SystemTrayItem::UMA_TEST, 2); |
| 87 |
| 88 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 89 RunAllPendingInMessageLoop(); |
| 90 |
| 91 test_item->set_views_are_visible(false); |
| 92 |
| 93 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 94 RunAllPendingInMessageLoop(); |
| 95 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName, |
| 96 SystemTrayItem::UMA_TEST, 2); |
| 97 |
| 98 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 99 RunAllPendingInMessageLoop(); |
| 100 } |
| 101 |
| 102 // Verifies a visible UMA_NOT_RECORDED default view is not recorded in the |
| 103 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. |
| 104 TEST_F(SystemTrayTest, NotRecordedtemsAreNotRecorded) { |
| 105 SystemTray* tray = GetPrimarySystemTray(); |
| 106 ASSERT_TRUE(tray->GetWidget()); |
| 107 |
| 108 TestSystemTrayItem* test_item = |
| 109 new TestSystemTrayItem(SystemTrayItem::UMA_NOT_RECORDED); |
| 110 tray->AddTrayItem(test_item); |
| 111 |
| 112 base::HistogramTester histogram_tester; |
| 113 |
| 114 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 115 RunAllPendingInMessageLoop(); |
| 116 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName, |
| 117 SystemTrayItem::UMA_NOT_RECORDED, 0); |
| 118 |
| 119 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 120 RunAllPendingInMessageLoop(); |
| 121 } |
| 122 |
| 123 // Verifies null default views are not recorded in the |
| 124 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. |
| 125 TEST_F(SystemTrayTest, NullDefaultViewIsNotRecorded) { |
| 126 SystemTray* tray = GetPrimarySystemTray(); |
| 127 ASSERT_TRUE(tray->GetWidget()); |
| 128 |
| 129 TestSystemTrayItem* test_item = new TestSystemTrayItem(); |
| 130 test_item->set_has_views(false); |
| 131 tray->AddTrayItem(test_item); |
| 132 |
| 133 base::HistogramTester histogram_tester; |
| 134 |
| 135 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 136 RunAllPendingInMessageLoop(); |
| 137 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName, |
| 138 SystemTrayItem::UMA_TEST, 0); |
| 139 |
| 140 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 141 RunAllPendingInMessageLoop(); |
| 142 } |
| 143 |
| 144 // Verifies visible detailed views are not recorded in the |
| 145 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. |
| 146 TEST_F(SystemTrayTest, VisibleDetailedViewsIsNotRecorded) { |
| 147 SystemTray* tray = GetPrimarySystemTray(); |
| 148 ASSERT_TRUE(tray->GetWidget()); |
| 149 |
| 150 TestSystemTrayItem* test_item = new TestSystemTrayItem(); |
| 151 tray->AddTrayItem(test_item); |
| 152 |
| 153 base::HistogramTester histogram_tester; |
| 154 |
| 155 tray->ShowDetailedView(test_item, 0, false, BUBBLE_CREATE_NEW); |
| 156 RunAllPendingInMessageLoop(); |
| 157 |
| 158 histogram_tester.ExpectTotalCount(kVisibleRowsHistogramName, 0); |
| 159 |
| 160 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 161 RunAllPendingInMessageLoop(); |
| 162 } |
| 163 |
| 164 // Verifies visible default views are not recorded for menu re-shows in the |
| 165 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. |
| 166 TEST_F(SystemTrayTest, VisibleDefaultViewIsNotRecordedOnReshow) { |
| 167 SystemTray* tray = GetPrimarySystemTray(); |
| 168 ASSERT_TRUE(tray->GetWidget()); |
| 169 |
| 170 TestSystemTrayItem* test_item = new TestSystemTrayItem(); |
| 171 tray->AddTrayItem(test_item); |
| 172 |
| 173 base::HistogramTester histogram_tester; |
| 174 |
| 175 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 176 RunAllPendingInMessageLoop(); |
| 177 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName, |
| 178 SystemTrayItem::UMA_TEST, 1); |
| 179 |
| 180 tray->ShowDetailedView(test_item, 0, false, BUBBLE_USE_EXISTING); |
| 181 RunAllPendingInMessageLoop(); |
| 182 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName, |
| 183 SystemTrayItem::UMA_TEST, 1); |
| 184 |
| 185 tray->ShowDefaultView(BUBBLE_USE_EXISTING); |
| 186 RunAllPendingInMessageLoop(); |
| 187 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName, |
| 188 SystemTrayItem::UMA_TEST, 1); |
| 189 |
| 190 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 191 RunAllPendingInMessageLoop(); |
| 192 } |
| 193 |
148 TEST_F(SystemTrayTest, SystemTrayDefaultView) { | 194 TEST_F(SystemTrayTest, SystemTrayDefaultView) { |
149 SystemTray* tray = GetPrimarySystemTray(); | 195 SystemTray* tray = GetPrimarySystemTray(); |
150 ASSERT_TRUE(tray->GetWidget()); | 196 ASSERT_TRUE(tray->GetWidget()); |
151 | 197 |
152 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 198 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
153 | 199 |
154 // Ensure that closing the bubble destroys it. | 200 // Ensure that closing the bubble destroys it. |
155 ASSERT_TRUE(tray->CloseSystemBubble()); | 201 ASSERT_TRUE(tray->CloseSystemBubble()); |
156 RunAllPendingInMessageLoop(); | 202 RunAllPendingInMessageLoop(); |
157 ASSERT_FALSE(tray->CloseSystemBubble()); | 203 ASSERT_FALSE(tray->CloseSystemBubble()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 ASSERT_FALSE(tray->draw_background_as_active()); | 240 ASSERT_FALSE(tray->draw_background_as_active()); |
195 RunAllPendingInMessageLoop(); | 241 RunAllPendingInMessageLoop(); |
196 // The bubble should already be closed by now. | 242 // The bubble should already be closed by now. |
197 ASSERT_FALSE(tray->CloseSystemBubble()); | 243 ASSERT_FALSE(tray->CloseSystemBubble()); |
198 } | 244 } |
199 | 245 |
200 TEST_F(SystemTrayTest, SystemTrayTestItems) { | 246 TEST_F(SystemTrayTest, SystemTrayTestItems) { |
201 SystemTray* tray = GetPrimarySystemTray(); | 247 SystemTray* tray = GetPrimarySystemTray(); |
202 ASSERT_TRUE(tray->GetWidget()); | 248 ASSERT_TRUE(tray->GetWidget()); |
203 | 249 |
204 TestItem* test_item = new TestItem; | 250 TestSystemTrayItem* test_item = new TestSystemTrayItem(); |
205 TestItem* detailed_item = new TestItem; | 251 TestSystemTrayItem* detailed_item = new TestSystemTrayItem(); |
206 tray->AddTrayItem(test_item); | 252 tray->AddTrayItem(test_item); |
207 tray->AddTrayItem(detailed_item); | 253 tray->AddTrayItem(detailed_item); |
208 | 254 |
209 // Check items have been added | 255 // Check items have been added |
210 const std::vector<SystemTrayItem*>& items = tray->GetTrayItems(); | 256 const std::vector<SystemTrayItem*>& items = tray->GetTrayItems(); |
211 ASSERT_TRUE(std::find(items.begin(), items.end(), test_item) != items.end()); | 257 ASSERT_TRUE(std::find(items.begin(), items.end(), test_item) != items.end()); |
212 ASSERT_TRUE(std::find(items.begin(), items.end(), detailed_item) != | 258 ASSERT_TRUE(std::find(items.begin(), items.end(), detailed_item) != |
213 items.end()); | 259 items.end()); |
214 | 260 |
215 // Ensure the tray views are created. | 261 // Ensure the tray views are created. |
(...skipping 16 matching lines...) Expand all Loading... |
232 RunAllPendingInMessageLoop(); | 278 RunAllPendingInMessageLoop(); |
233 ASSERT_TRUE(test_item->default_view() != NULL); | 279 ASSERT_TRUE(test_item->default_view() != NULL); |
234 ASSERT_TRUE(detailed_item->detailed_view() == NULL); | 280 ASSERT_TRUE(detailed_item->detailed_view() == NULL); |
235 } | 281 } |
236 | 282 |
237 TEST_F(SystemTrayTest, SystemTrayNoViewItems) { | 283 TEST_F(SystemTrayTest, SystemTrayNoViewItems) { |
238 SystemTray* tray = GetPrimarySystemTray(); | 284 SystemTray* tray = GetPrimarySystemTray(); |
239 ASSERT_TRUE(tray->GetWidget()); | 285 ASSERT_TRUE(tray->GetWidget()); |
240 | 286 |
241 // Verify that no crashes occur on items lacking some views. | 287 // Verify that no crashes occur on items lacking some views. |
242 TestNoViewItem* no_view_item = new TestNoViewItem; | 288 TestSystemTrayItem* no_view_item = new TestSystemTrayItem(); |
| 289 no_view_item->set_has_views(false); |
243 tray->AddTrayItem(no_view_item); | 290 tray->AddTrayItem(no_view_item); |
244 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 291 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
245 tray->ShowDetailedView(no_view_item, 0, false, BUBBLE_USE_EXISTING); | 292 tray->ShowDetailedView(no_view_item, 0, false, BUBBLE_USE_EXISTING); |
246 RunAllPendingInMessageLoop(); | 293 RunAllPendingInMessageLoop(); |
247 } | 294 } |
248 | 295 |
249 TEST_F(SystemTrayTest, TrayWidgetAutoResizes) { | 296 TEST_F(SystemTrayTest, TrayWidgetAutoResizes) { |
250 SystemTray* tray = GetPrimarySystemTray(); | 297 SystemTray* tray = GetPrimarySystemTray(); |
251 ASSERT_TRUE(tray->GetWidget()); | 298 ASSERT_TRUE(tray->GetWidget()); |
252 | 299 |
253 // Add an initial tray item so that the tray gets laid out correctly. | 300 // Add an initial tray item so that the tray gets laid out correctly. |
254 TestItem* initial_item = new TestItem; | 301 TestSystemTrayItem* initial_item = new TestSystemTrayItem(); |
255 tray->AddTrayItem(initial_item); | 302 tray->AddTrayItem(initial_item); |
256 | 303 |
257 gfx::Size initial_size = tray->GetWidget()->GetWindowBoundsInScreen().size(); | 304 gfx::Size initial_size = tray->GetWidget()->GetWindowBoundsInScreen().size(); |
258 | 305 |
259 TestItem* new_item = new TestItem; | 306 TestSystemTrayItem* new_item = new TestSystemTrayItem(); |
260 tray->AddTrayItem(new_item); | 307 tray->AddTrayItem(new_item); |
261 | 308 |
262 gfx::Size new_size = tray->GetWidget()->GetWindowBoundsInScreen().size(); | 309 gfx::Size new_size = tray->GetWidget()->GetWindowBoundsInScreen().size(); |
263 | 310 |
264 // Adding the new item should change the size of the tray. | 311 // Adding the new item should change the size of the tray. |
265 EXPECT_NE(initial_size.ToString(), new_size.ToString()); | 312 EXPECT_NE(initial_size.ToString(), new_size.ToString()); |
266 | 313 |
267 // Hiding the tray view of the new item should also change the size of the | 314 // Hiding the tray view of the new item should also change the size of the |
268 // tray. | 315 // tray. |
269 new_item->tray_view()->SetVisible(false); | 316 new_item->tray_view()->SetVisible(false); |
270 EXPECT_EQ(initial_size.ToString(), | 317 EXPECT_EQ(initial_size.ToString(), |
271 tray->GetWidget()->GetWindowBoundsInScreen().size().ToString()); | 318 tray->GetWidget()->GetWindowBoundsInScreen().size().ToString()); |
272 | 319 |
273 new_item->tray_view()->SetVisible(true); | 320 new_item->tray_view()->SetVisible(true); |
274 EXPECT_EQ(new_size.ToString(), | 321 EXPECT_EQ(new_size.ToString(), |
275 tray->GetWidget()->GetWindowBoundsInScreen().size().ToString()); | 322 tray->GetWidget()->GetWindowBoundsInScreen().size().ToString()); |
276 } | 323 } |
277 | 324 |
278 TEST_F(SystemTrayTest, SystemTrayNotifications) { | 325 TEST_F(SystemTrayTest, SystemTrayNotifications) { |
279 SystemTray* tray = GetPrimarySystemTray(); | 326 SystemTray* tray = GetPrimarySystemTray(); |
280 ASSERT_TRUE(tray->GetWidget()); | 327 ASSERT_TRUE(tray->GetWidget()); |
281 | 328 |
282 TestItem* test_item = new TestItem; | 329 TestSystemTrayItem* test_item = new TestSystemTrayItem(); |
283 TestItem* detailed_item = new TestItem; | 330 TestSystemTrayItem* detailed_item = new TestSystemTrayItem(); |
284 tray->AddTrayItem(test_item); | 331 tray->AddTrayItem(test_item); |
285 tray->AddTrayItem(detailed_item); | 332 tray->AddTrayItem(detailed_item); |
286 | 333 |
287 // Ensure the tray views are created. | 334 // Ensure the tray views are created. |
288 ASSERT_TRUE(test_item->tray_view() != NULL); | 335 ASSERT_TRUE(test_item->tray_view() != NULL); |
289 ASSERT_TRUE(detailed_item->tray_view() != NULL); | 336 ASSERT_TRUE(detailed_item->tray_view() != NULL); |
290 | 337 |
291 // Ensure a notification view is created. | 338 // Ensure a notification view is created. |
292 tray->ShowNotificationView(test_item); | 339 tray->ShowNotificationView(test_item); |
293 ASSERT_TRUE(test_item->notification_view() != NULL); | 340 ASSERT_TRUE(test_item->notification_view() != NULL); |
(...skipping 13 matching lines...) Expand all Loading... |
307 ASSERT_TRUE(tray->CloseSystemBubble()); | 354 ASSERT_TRUE(tray->CloseSystemBubble()); |
308 RunAllPendingInMessageLoop(); | 355 RunAllPendingInMessageLoop(); |
309 ASSERT_TRUE(detailed_item->detailed_view() == NULL); | 356 ASSERT_TRUE(detailed_item->detailed_view() == NULL); |
310 ASSERT_TRUE(test_item->notification_view() != NULL); | 357 ASSERT_TRUE(test_item->notification_view() != NULL); |
311 } | 358 } |
312 | 359 |
313 TEST_F(SystemTrayTest, BubbleCreationTypesTest) { | 360 TEST_F(SystemTrayTest, BubbleCreationTypesTest) { |
314 SystemTray* tray = GetPrimarySystemTray(); | 361 SystemTray* tray = GetPrimarySystemTray(); |
315 ASSERT_TRUE(tray->GetWidget()); | 362 ASSERT_TRUE(tray->GetWidget()); |
316 | 363 |
317 TestItem* test_item = new TestItem; | 364 TestSystemTrayItem* test_item = new TestSystemTrayItem(); |
318 tray->AddTrayItem(test_item); | 365 tray->AddTrayItem(test_item); |
319 | 366 |
320 // Ensure the tray views are created. | 367 // Ensure the tray views are created. |
321 ASSERT_TRUE(test_item->tray_view() != NULL); | 368 ASSERT_TRUE(test_item->tray_view() != NULL); |
322 | 369 |
323 // Show the default view, ensure the notification view is destroyed. | 370 // Show the default view, ensure the notification view is destroyed. |
324 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 371 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
325 RunAllPendingInMessageLoop(); | 372 RunAllPendingInMessageLoop(); |
326 | 373 |
327 views::Widget* widget = test_item->default_view()->GetWidget(); | 374 views::Widget* widget = test_item->default_view()->GetWidget(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 424 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
378 window_bounds = widget->GetWindowBoundsInScreen(); | 425 window_bounds = widget->GetWindowBoundsInScreen(); |
379 tray_bounds = tray->GetBoundsInScreen(); | 426 tray_bounds = tray->GetBoundsInScreen(); |
380 EXPECT_TRUE(window_bounds.Contains(tray_bounds)); | 427 EXPECT_TRUE(window_bounds.Contains(tray_bounds)); |
381 } | 428 } |
382 | 429 |
383 TEST_F(SystemTrayTest, PersistentBubble) { | 430 TEST_F(SystemTrayTest, PersistentBubble) { |
384 SystemTray* tray = GetPrimarySystemTray(); | 431 SystemTray* tray = GetPrimarySystemTray(); |
385 ASSERT_TRUE(tray->GetWidget()); | 432 ASSERT_TRUE(tray->GetWidget()); |
386 | 433 |
387 TestItem* test_item = new TestItem; | 434 TestSystemTrayItem* test_item = new TestSystemTrayItem(); |
388 tray->AddTrayItem(test_item); | 435 tray->AddTrayItem(test_item); |
389 | 436 |
390 std::unique_ptr<views::Widget> widget(CreateTestWidget( | 437 std::unique_ptr<views::Widget> widget(CreateTestWidget( |
391 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(0, 0, 100, 100))); | 438 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(0, 0, 100, 100))); |
392 | 439 |
393 // Tests for usual default view while activating a window. | 440 // Tests for usual default view while activating a window. |
394 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 441 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
395 ASSERT_TRUE(tray->HasSystemBubble()); | 442 ASSERT_TRUE(tray->HasSystemBubble()); |
396 widget->Activate(); | 443 widget->Activate(); |
397 base::RunLoop().RunUntilIdle(); | 444 base::RunLoop().RunUntilIdle(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 // Hide the default view, ensure the tray bubble height is back to zero. | 593 // Hide the default view, ensure the tray bubble height is back to zero. |
547 ASSERT_TRUE(tray->CloseSystemBubble()); | 594 ASSERT_TRUE(tray->CloseSystemBubble()); |
548 RunAllPendingInMessageLoop(); | 595 RunAllPendingInMessageLoop(); |
549 | 596 |
550 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); | 597 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); |
551 } | 598 } |
552 #endif // OS_CHROMEOS | 599 #endif // OS_CHROMEOS |
553 | 600 |
554 } // namespace test | 601 } // namespace test |
555 } // namespace ash | 602 } // namespace ash |
OLD | NEW |