Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(676)

Side by Side Diff: ash/common/system/tray/system_tray_unittest.cc

Issue 2162153002: Added Ash.SystemMenu.DefaultView.VisibleItems histogram. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unnecessary includes after self review. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 std::string kVisibleRowsHistogramName =
James Cook 2016/07/20 20:13:49 I don't think we're allowed to have statically ini
bruthig 2016/07/21 14:34:58 Done.
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(true);
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::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::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::TEST, 2);
97
98 ASSERT_TRUE(tray->CloseSystemBubble());
99 RunAllPendingInMessageLoop();
100 }
101
102 // Verifies null default views are not recorded in the
103 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram.
104 TEST_F(SystemTrayTest, NullDefaultViewIsNotRecorded) {
105 SystemTray* tray = GetPrimarySystemTray();
106 ASSERT_TRUE(tray->GetWidget());
107
108 TestSystemTrayItem* test_item = new TestSystemTrayItem(false);
109 tray->AddTrayItem(test_item);
110
111 base::HistogramTester histogram_tester;
112
113 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
114 RunAllPendingInMessageLoop();
115 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName,
116 SystemTrayItem::TEST, 0);
117
118 ASSERT_TRUE(tray->CloseSystemBubble());
119 RunAllPendingInMessageLoop();
120 }
121
122 // Verifies visible detailed views are not recorded in the
123 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram.
124 TEST_F(SystemTrayTest, VisibleDetailedViewsIsNotRecorded) {
125 SystemTray* tray = GetPrimarySystemTray();
126 ASSERT_TRUE(tray->GetWidget());
127
128 TestSystemTrayItem* test_item = new TestSystemTrayItem(true);
129 tray->AddTrayItem(test_item);
130
131 base::HistogramTester histogram_tester;
132
133 tray->ShowDetailedView(test_item, 0, false, BUBBLE_CREATE_NEW);
134 RunAllPendingInMessageLoop();
135
136 histogram_tester.ExpectTotalCount(kVisibleRowsHistogramName, 0);
137
138 ASSERT_TRUE(tray->CloseSystemBubble());
139 RunAllPendingInMessageLoop();
140 }
141
142 // Verifies visible default views are not recorded for menu re-shows in the
143 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram.
144 TEST_F(SystemTrayTest, VisibleDefaultViewIsNotRecordedOnReshow) {
145 SystemTray* tray = GetPrimarySystemTray();
146 ASSERT_TRUE(tray->GetWidget());
147
148 TestSystemTrayItem* test_item = new TestSystemTrayItem(true);
149 tray->AddTrayItem(test_item);
150
151 base::HistogramTester histogram_tester;
152
153 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
154 RunAllPendingInMessageLoop();
155 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName,
156 SystemTrayItem::TEST, 1);
157
158 tray->ShowDetailedView(test_item, 0, false, BUBBLE_USE_EXISTING);
159 RunAllPendingInMessageLoop();
160 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName,
161 SystemTrayItem::TEST, 1);
162
163 tray->ShowDefaultView(BUBBLE_USE_EXISTING);
164 RunAllPendingInMessageLoop();
165 histogram_tester.ExpectBucketCount(kVisibleRowsHistogramName,
166 SystemTrayItem::TEST, 1);
167
168 ASSERT_TRUE(tray->CloseSystemBubble());
169 RunAllPendingInMessageLoop();
170 }
James Cook 2016/07/20 20:13:49 Thanks for writing a nice test suite for this.
171
148 TEST_F(SystemTrayTest, SystemTrayDefaultView) { 172 TEST_F(SystemTrayTest, SystemTrayDefaultView) {
149 SystemTray* tray = GetPrimarySystemTray(); 173 SystemTray* tray = GetPrimarySystemTray();
150 ASSERT_TRUE(tray->GetWidget()); 174 ASSERT_TRUE(tray->GetWidget());
151 175
152 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 176 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
153 177
154 // Ensure that closing the bubble destroys it. 178 // Ensure that closing the bubble destroys it.
155 ASSERT_TRUE(tray->CloseSystemBubble()); 179 ASSERT_TRUE(tray->CloseSystemBubble());
156 RunAllPendingInMessageLoop(); 180 RunAllPendingInMessageLoop();
157 ASSERT_FALSE(tray->CloseSystemBubble()); 181 ASSERT_FALSE(tray->CloseSystemBubble());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 ASSERT_FALSE(tray->draw_background_as_active()); 218 ASSERT_FALSE(tray->draw_background_as_active());
195 RunAllPendingInMessageLoop(); 219 RunAllPendingInMessageLoop();
196 // The bubble should already be closed by now. 220 // The bubble should already be closed by now.
197 ASSERT_FALSE(tray->CloseSystemBubble()); 221 ASSERT_FALSE(tray->CloseSystemBubble());
198 } 222 }
199 223
200 TEST_F(SystemTrayTest, SystemTrayTestItems) { 224 TEST_F(SystemTrayTest, SystemTrayTestItems) {
201 SystemTray* tray = GetPrimarySystemTray(); 225 SystemTray* tray = GetPrimarySystemTray();
202 ASSERT_TRUE(tray->GetWidget()); 226 ASSERT_TRUE(tray->GetWidget());
203 227
204 TestItem* test_item = new TestItem; 228 TestSystemTrayItem* test_item = new TestSystemTrayItem(true);
205 TestItem* detailed_item = new TestItem; 229 TestSystemTrayItem* detailed_item = new TestSystemTrayItem(true);
206 tray->AddTrayItem(test_item); 230 tray->AddTrayItem(test_item);
207 tray->AddTrayItem(detailed_item); 231 tray->AddTrayItem(detailed_item);
208 232
209 // Check items have been added 233 // Check items have been added
210 const std::vector<SystemTrayItem*>& items = tray->GetTrayItems(); 234 const std::vector<SystemTrayItem*>& items = tray->GetTrayItems();
211 ASSERT_TRUE(std::find(items.begin(), items.end(), test_item) != items.end()); 235 ASSERT_TRUE(std::find(items.begin(), items.end(), test_item) != items.end());
212 ASSERT_TRUE(std::find(items.begin(), items.end(), detailed_item) != 236 ASSERT_TRUE(std::find(items.begin(), items.end(), detailed_item) !=
213 items.end()); 237 items.end());
214 238
215 // Ensure the tray views are created. 239 // Ensure the tray views are created.
(...skipping 16 matching lines...) Expand all
232 RunAllPendingInMessageLoop(); 256 RunAllPendingInMessageLoop();
233 ASSERT_TRUE(test_item->default_view() != NULL); 257 ASSERT_TRUE(test_item->default_view() != NULL);
234 ASSERT_TRUE(detailed_item->detailed_view() == NULL); 258 ASSERT_TRUE(detailed_item->detailed_view() == NULL);
235 } 259 }
236 260
237 TEST_F(SystemTrayTest, SystemTrayNoViewItems) { 261 TEST_F(SystemTrayTest, SystemTrayNoViewItems) {
238 SystemTray* tray = GetPrimarySystemTray(); 262 SystemTray* tray = GetPrimarySystemTray();
239 ASSERT_TRUE(tray->GetWidget()); 263 ASSERT_TRUE(tray->GetWidget());
240 264
241 // Verify that no crashes occur on items lacking some views. 265 // Verify that no crashes occur on items lacking some views.
242 TestNoViewItem* no_view_item = new TestNoViewItem; 266 TestSystemTrayItem* no_view_item = new TestSystemTrayItem(false);
243 tray->AddTrayItem(no_view_item); 267 tray->AddTrayItem(no_view_item);
244 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 268 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
245 tray->ShowDetailedView(no_view_item, 0, false, BUBBLE_USE_EXISTING); 269 tray->ShowDetailedView(no_view_item, 0, false, BUBBLE_USE_EXISTING);
246 RunAllPendingInMessageLoop(); 270 RunAllPendingInMessageLoop();
247 } 271 }
248 272
249 TEST_F(SystemTrayTest, TrayWidgetAutoResizes) { 273 TEST_F(SystemTrayTest, TrayWidgetAutoResizes) {
250 SystemTray* tray = GetPrimarySystemTray(); 274 SystemTray* tray = GetPrimarySystemTray();
251 ASSERT_TRUE(tray->GetWidget()); 275 ASSERT_TRUE(tray->GetWidget());
252 276
253 // Add an initial tray item so that the tray gets laid out correctly. 277 // Add an initial tray item so that the tray gets laid out correctly.
254 TestItem* initial_item = new TestItem; 278 TestSystemTrayItem* initial_item = new TestSystemTrayItem(true);
255 tray->AddTrayItem(initial_item); 279 tray->AddTrayItem(initial_item);
256 280
257 gfx::Size initial_size = tray->GetWidget()->GetWindowBoundsInScreen().size(); 281 gfx::Size initial_size = tray->GetWidget()->GetWindowBoundsInScreen().size();
258 282
259 TestItem* new_item = new TestItem; 283 TestSystemTrayItem* new_item = new TestSystemTrayItem(true);
260 tray->AddTrayItem(new_item); 284 tray->AddTrayItem(new_item);
261 285
262 gfx::Size new_size = tray->GetWidget()->GetWindowBoundsInScreen().size(); 286 gfx::Size new_size = tray->GetWidget()->GetWindowBoundsInScreen().size();
263 287
264 // Adding the new item should change the size of the tray. 288 // Adding the new item should change the size of the tray.
265 EXPECT_NE(initial_size.ToString(), new_size.ToString()); 289 EXPECT_NE(initial_size.ToString(), new_size.ToString());
266 290
267 // Hiding the tray view of the new item should also change the size of the 291 // Hiding the tray view of the new item should also change the size of the
268 // tray. 292 // tray.
269 new_item->tray_view()->SetVisible(false); 293 new_item->tray_view()->SetVisible(false);
270 EXPECT_EQ(initial_size.ToString(), 294 EXPECT_EQ(initial_size.ToString(),
271 tray->GetWidget()->GetWindowBoundsInScreen().size().ToString()); 295 tray->GetWidget()->GetWindowBoundsInScreen().size().ToString());
272 296
273 new_item->tray_view()->SetVisible(true); 297 new_item->tray_view()->SetVisible(true);
274 EXPECT_EQ(new_size.ToString(), 298 EXPECT_EQ(new_size.ToString(),
275 tray->GetWidget()->GetWindowBoundsInScreen().size().ToString()); 299 tray->GetWidget()->GetWindowBoundsInScreen().size().ToString());
276 } 300 }
277 301
278 TEST_F(SystemTrayTest, SystemTrayNotifications) { 302 TEST_F(SystemTrayTest, SystemTrayNotifications) {
279 SystemTray* tray = GetPrimarySystemTray(); 303 SystemTray* tray = GetPrimarySystemTray();
280 ASSERT_TRUE(tray->GetWidget()); 304 ASSERT_TRUE(tray->GetWidget());
281 305
282 TestItem* test_item = new TestItem; 306 TestSystemTrayItem* test_item = new TestSystemTrayItem(true);
283 TestItem* detailed_item = new TestItem; 307 TestSystemTrayItem* detailed_item = new TestSystemTrayItem(true);
284 tray->AddTrayItem(test_item); 308 tray->AddTrayItem(test_item);
285 tray->AddTrayItem(detailed_item); 309 tray->AddTrayItem(detailed_item);
286 310
287 // Ensure the tray views are created. 311 // Ensure the tray views are created.
288 ASSERT_TRUE(test_item->tray_view() != NULL); 312 ASSERT_TRUE(test_item->tray_view() != NULL);
289 ASSERT_TRUE(detailed_item->tray_view() != NULL); 313 ASSERT_TRUE(detailed_item->tray_view() != NULL);
290 314
291 // Ensure a notification view is created. 315 // Ensure a notification view is created.
292 tray->ShowNotificationView(test_item); 316 tray->ShowNotificationView(test_item);
293 ASSERT_TRUE(test_item->notification_view() != NULL); 317 ASSERT_TRUE(test_item->notification_view() != NULL);
(...skipping 13 matching lines...) Expand all
307 ASSERT_TRUE(tray->CloseSystemBubble()); 331 ASSERT_TRUE(tray->CloseSystemBubble());
308 RunAllPendingInMessageLoop(); 332 RunAllPendingInMessageLoop();
309 ASSERT_TRUE(detailed_item->detailed_view() == NULL); 333 ASSERT_TRUE(detailed_item->detailed_view() == NULL);
310 ASSERT_TRUE(test_item->notification_view() != NULL); 334 ASSERT_TRUE(test_item->notification_view() != NULL);
311 } 335 }
312 336
313 TEST_F(SystemTrayTest, BubbleCreationTypesTest) { 337 TEST_F(SystemTrayTest, BubbleCreationTypesTest) {
314 SystemTray* tray = GetPrimarySystemTray(); 338 SystemTray* tray = GetPrimarySystemTray();
315 ASSERT_TRUE(tray->GetWidget()); 339 ASSERT_TRUE(tray->GetWidget());
316 340
317 TestItem* test_item = new TestItem; 341 TestSystemTrayItem* test_item = new TestSystemTrayItem(true);
318 tray->AddTrayItem(test_item); 342 tray->AddTrayItem(test_item);
319 343
320 // Ensure the tray views are created. 344 // Ensure the tray views are created.
321 ASSERT_TRUE(test_item->tray_view() != NULL); 345 ASSERT_TRUE(test_item->tray_view() != NULL);
322 346
323 // Show the default view, ensure the notification view is destroyed. 347 // Show the default view, ensure the notification view is destroyed.
324 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 348 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
325 RunAllPendingInMessageLoop(); 349 RunAllPendingInMessageLoop();
326 350
327 views::Widget* widget = test_item->default_view()->GetWidget(); 351 views::Widget* widget = test_item->default_view()->GetWidget();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 401 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
378 window_bounds = widget->GetWindowBoundsInScreen(); 402 window_bounds = widget->GetWindowBoundsInScreen();
379 tray_bounds = tray->GetBoundsInScreen(); 403 tray_bounds = tray->GetBoundsInScreen();
380 EXPECT_TRUE(window_bounds.Contains(tray_bounds)); 404 EXPECT_TRUE(window_bounds.Contains(tray_bounds));
381 } 405 }
382 406
383 TEST_F(SystemTrayTest, PersistentBubble) { 407 TEST_F(SystemTrayTest, PersistentBubble) {
384 SystemTray* tray = GetPrimarySystemTray(); 408 SystemTray* tray = GetPrimarySystemTray();
385 ASSERT_TRUE(tray->GetWidget()); 409 ASSERT_TRUE(tray->GetWidget());
386 410
387 TestItem* test_item = new TestItem; 411 TestSystemTrayItem* test_item = new TestSystemTrayItem(true);
388 tray->AddTrayItem(test_item); 412 tray->AddTrayItem(test_item);
389 413
390 std::unique_ptr<views::Widget> widget(CreateTestWidget( 414 std::unique_ptr<views::Widget> widget(CreateTestWidget(
391 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(0, 0, 100, 100))); 415 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(0, 0, 100, 100)));
392 416
393 // Tests for usual default view while activating a window. 417 // Tests for usual default view while activating a window.
394 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 418 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
395 ASSERT_TRUE(tray->HasSystemBubble()); 419 ASSERT_TRUE(tray->HasSystemBubble());
396 widget->Activate(); 420 widget->Activate();
397 base::RunLoop().RunUntilIdle(); 421 base::RunLoop().RunUntilIdle();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 // Hide the default view, ensure the tray bubble height is back to zero. 570 // Hide the default view, ensure the tray bubble height is back to zero.
547 ASSERT_TRUE(tray->CloseSystemBubble()); 571 ASSERT_TRUE(tray->CloseSystemBubble());
548 RunAllPendingInMessageLoop(); 572 RunAllPendingInMessageLoop();
549 573
550 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); 574 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test());
551 } 575 }
552 #endif // OS_CHROMEOS 576 #endif // OS_CHROMEOS
553 577
554 } // namespace test 578 } // namespace test
555 } // namespace ash 579 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698