1 // Copyright 2013 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.
5 #include "ash/system/chromeos/tray_display.h"
7 #include "ash/display/display_manager.h"
8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h"
10 #include "ash/shell.h"
11 #include "ash/system/tray/system_tray.h"
12 #include "ash/test/ash_test_base.h"
13 #include "ash/test/test_system_tray_delegate.h"
14 #include "base/strings/string16.h"
15 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h"
17 #include "grit/ash_strings.h"
18 #include "ui/accessibility/ax_view_state.h"
19 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/gfx/display.h"
21 #include "ui/message_center/message_center.h"
22 #include "ui/message_center/notification.h"
23 #include "ui/message_center/notification_list.h"
24 #include "ui/views/controls/label.h"
28 base::string16
GetTooltipText(const base::string16
& headline
,
29 const base::string16
& name1
,
30 const std::string
& data1
,
31 const base::string16
& name2
,
32 const std::string
& data2
) {
33 std::vector
<base::string16
> lines
;
34 lines
.push_back(headline
);
36 lines
.push_back(name1
);
38 lines
.push_back(l10n_util::GetStringFUTF16(
39 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY
,
40 name1
, base::UTF8ToUTF16(data1
)));
43 lines
.push_back(l10n_util::GetStringFUTF16(
44 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY
,
45 name2
, base::UTF8ToUTF16(data2
)));
47 return JoinString(lines
, '\n');
50 base::string16
GetMirroredTooltipText(const base::string16
& headline
,
51 const base::string16
& name
,
52 const std::string
& data
) {
53 return GetTooltipText(headline
, name
, data
, base::string16(), "");
56 base::string16
GetFirstDisplayName() {
57 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
58 return base::UTF8ToUTF16(display_manager
->GetDisplayNameForId(
59 display_manager
->first_display_id()));
62 base::string16
GetSecondDisplayName() {
63 return base::UTF8ToUTF16(
64 Shell::GetInstance()->display_manager()->GetDisplayNameForId(
65 ScreenUtil::GetSecondaryDisplay().id()));
68 base::string16
GetMirroringDisplayName() {
69 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
70 return base::UTF8ToUTF16(display_manager
->GetDisplayNameForId(
71 display_manager
->mirroring_display_id()));
74 class TrayDisplayTest
: public ash::test::AshTestBase
{
77 ~TrayDisplayTest() override
;
79 void SetUp() override
;
82 SystemTray
* tray() { return tray_
; }
83 TrayDisplay
* tray_display() { return tray_display_
; }
85 void CloseNotification();
86 bool IsDisplayVisibleInTray() const;
87 base::string16
GetTrayDisplayText() const;
88 void CheckAccessibleName() const;
89 base::string16
GetTrayDisplayTooltipText() const;
90 base::string16
GetDisplayNotificationText() const;
91 base::string16
GetDisplayNotificationAdditionalText() const;
94 const message_center::Notification
* GetDisplayNotification() const;
96 // Weak reference, owned by Shell.
99 // Weak reference, owned by |tray_|.
100 TrayDisplay
* tray_display_
;
102 DISALLOW_COPY_AND_ASSIGN(TrayDisplayTest
);
105 TrayDisplayTest::TrayDisplayTest() : tray_(NULL
), tray_display_(NULL
) {
108 TrayDisplayTest::~TrayDisplayTest() {
111 void TrayDisplayTest::SetUp() {
112 ash::test::AshTestBase::SetUp();
113 tray_
= Shell::GetPrimaryRootWindowController()->GetSystemTray();
114 tray_display_
= new TrayDisplay(tray_
);
115 tray_
->AddTrayItem(tray_display_
);
118 void TrayDisplayTest::CloseNotification() {
119 message_center::MessageCenter::Get()->RemoveNotification(
120 TrayDisplay::kNotificationId
, false);
121 RunAllPendingInMessageLoop();
124 bool TrayDisplayTest::IsDisplayVisibleInTray() const {
125 return tray_
->HasSystemBubble() &&
126 tray_display_
->default_view() &&
127 tray_display_
->default_view()->visible();
130 base::string16
TrayDisplayTest::GetTrayDisplayText() const {
131 return tray_display_
->GetDefaultViewMessage();
134 void TrayDisplayTest::CheckAccessibleName() const {
135 ui::AXViewState state
;
136 if (tray_display_
->GetAccessibleStateForTesting(&state
)) {
137 base::string16 expected
= tray_display_
->GetDefaultViewMessage();
138 EXPECT_EQ(expected
, state
.name
);
142 base::string16
TrayDisplayTest::GetTrayDisplayTooltipText() const {
143 if (!tray_display_
->default_view())
144 return base::string16();
146 base::string16 tooltip
;
147 if (!tray_display_
->default_view()->GetTooltipText(gfx::Point(), &tooltip
))
148 return base::string16();
152 base::string16
TrayDisplayTest::GetDisplayNotificationText() const {
153 const message_center::Notification
* notification
= GetDisplayNotification();
154 return notification
? notification
->title() : base::string16();
157 base::string16
TrayDisplayTest::GetDisplayNotificationAdditionalText() const {
158 const message_center::Notification
* notification
= GetDisplayNotification();
159 return notification
? notification
->message() : base::string16();
162 const message_center::Notification
* TrayDisplayTest::GetDisplayNotification()
164 const message_center::NotificationList::Notifications notifications
=
165 message_center::MessageCenter::Get()->GetVisibleNotifications();
166 for (message_center::NotificationList::Notifications::const_iterator iter
=
167 notifications
.begin(); iter
!= notifications
.end(); ++iter
) {
168 if ((*iter
)->id() == TrayDisplay::kNotificationId
)
175 TEST_F(TrayDisplayTest
, NoInternalDisplay
) {
176 UpdateDisplay("400x400");
177 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
178 EXPECT_FALSE(IsDisplayVisibleInTray());
180 UpdateDisplay("400x400,200x200");
181 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
182 EXPECT_TRUE(IsDisplayVisibleInTray());
183 base::string16 expected
= l10n_util::GetStringUTF16(
184 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL
);
185 base::string16 first_name
= GetFirstDisplayName();
186 EXPECT_EQ(expected
, GetTrayDisplayText());
187 EXPECT_EQ(GetTooltipText(expected
, GetFirstDisplayName(), "400x400",
188 GetSecondDisplayName(), "200x200"),
189 GetTrayDisplayTooltipText());
190 CheckAccessibleName();
193 Shell::GetInstance()->display_manager()->SetSoftwareMirroring(true);
194 UpdateDisplay("400x400,200x200");
195 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
196 EXPECT_TRUE(IsDisplayVisibleInTray());
197 expected
= l10n_util::GetStringUTF16(
198 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL
);
199 EXPECT_EQ(expected
, GetTrayDisplayText());
200 EXPECT_EQ(GetMirroredTooltipText(expected
, GetFirstDisplayName(), "400x400"),
201 GetTrayDisplayTooltipText());
202 CheckAccessibleName();
205 TEST_F(TrayDisplayTest
, InternalDisplay
) {
206 UpdateDisplay("400x400");
207 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
208 gfx::Display::SetInternalDisplayId(display_manager
->first_display_id());
210 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
211 EXPECT_FALSE(IsDisplayVisibleInTray());
214 UpdateDisplay("400x400,200x200");
215 base::string16 expected
= l10n_util::GetStringFUTF16(
216 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
, GetSecondDisplayName());
217 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
218 EXPECT_TRUE(IsDisplayVisibleInTray());
219 EXPECT_EQ(expected
, GetTrayDisplayText());
220 EXPECT_EQ(GetTooltipText(expected
, GetFirstDisplayName(), "400x400",
221 GetSecondDisplayName(), "200x200"),
222 GetTrayDisplayTooltipText());
223 CheckAccessibleName();
226 display_manager
->SetSoftwareMirroring(true);
227 UpdateDisplay("400x400,200x200");
228 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
229 EXPECT_TRUE(IsDisplayVisibleInTray());
231 expected
= l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
,
232 GetMirroringDisplayName());
233 EXPECT_EQ(expected
, GetTrayDisplayText());
234 EXPECT_EQ(GetMirroredTooltipText(expected
, GetFirstDisplayName(), "400x400"),
235 GetTrayDisplayTooltipText());
236 CheckAccessibleName();
239 TEST_F(TrayDisplayTest
, InternalDisplayResized
) {
240 UpdateDisplay("400x400@1.5");
241 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
242 gfx::Display::SetInternalDisplayId(display_manager
->first_display_id());
244 // Shows the tray_display even though there's a single-display.
245 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
246 EXPECT_TRUE(IsDisplayVisibleInTray());
247 base::string16 internal_info
= l10n_util::GetStringFUTF16(
248 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY
,
249 GetFirstDisplayName(), base::UTF8ToUTF16("600x600"));
250 EXPECT_EQ(internal_info
, GetTrayDisplayText());
251 EXPECT_EQ(GetTooltipText(base::string16(), GetFirstDisplayName(), "600x600",
252 base::string16(), std::string()),
253 GetTrayDisplayTooltipText());
254 CheckAccessibleName();
257 UpdateDisplay("400x400@1.5,200x200");
258 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
259 EXPECT_TRUE(IsDisplayVisibleInTray());
260 base::string16 expected
= l10n_util::GetStringFUTF16(
261 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
, GetSecondDisplayName());
262 EXPECT_EQ(expected
, GetTrayDisplayText());
263 EXPECT_EQ(GetTooltipText(expected
, GetFirstDisplayName(), "600x600",
264 GetSecondDisplayName(), "200x200"),
265 GetTrayDisplayTooltipText());
266 CheckAccessibleName();
269 display_manager
->SetSoftwareMirroring(true);
270 UpdateDisplay("400x400@1.5,200x200");
271 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
272 EXPECT_TRUE(IsDisplayVisibleInTray());
273 expected
= l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
,
274 GetMirroringDisplayName());
275 EXPECT_EQ(expected
, GetTrayDisplayText());
276 EXPECT_EQ(GetMirroredTooltipText(expected
, GetFirstDisplayName(), "600x600"),
277 GetTrayDisplayTooltipText());
278 CheckAccessibleName();
281 display_manager
->SetSoftwareMirroring(false);
282 UpdateDisplay("400x400@1.5,200x200");
283 gfx::Display::SetInternalDisplayId(ScreenUtil::GetSecondaryDisplay().id());
284 UpdateDisplay("400x400@1.5");
285 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
286 EXPECT_TRUE(IsDisplayVisibleInTray());
287 expected
= l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED
);
288 EXPECT_EQ(expected
, GetTrayDisplayText());
291 expected
, GetFirstDisplayName(), "600x600", base::string16(), ""),
292 GetTrayDisplayTooltipText());
293 CheckAccessibleName();
296 TEST_F(TrayDisplayTest
, ExternalDisplayResized
) {
297 UpdateDisplay("400x400");
298 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
299 gfx::Display::SetInternalDisplayId(display_manager
->first_display_id());
301 // Shows the tray_display even though there's a single-display.
302 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
303 EXPECT_FALSE(IsDisplayVisibleInTray());
306 UpdateDisplay("400x400,200x200@1.5");
307 const gfx::Display
& secondary_display
= ScreenUtil::GetSecondaryDisplay();
309 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
310 EXPECT_TRUE(IsDisplayVisibleInTray());
311 base::string16 expected
= l10n_util::GetStringFUTF16(
312 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
,
313 l10n_util::GetStringFUTF16(
314 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME
,
315 GetSecondDisplayName(),
316 base::UTF8ToUTF16(secondary_display
.size().ToString())));
317 EXPECT_EQ(expected
, GetTrayDisplayText());
318 EXPECT_EQ(GetTooltipText(expected
, GetFirstDisplayName(), "400x400",
319 GetSecondDisplayName(), "300x300"),
320 GetTrayDisplayTooltipText());
321 CheckAccessibleName();
324 display_manager
->SetSoftwareMirroring(true);
325 UpdateDisplay("400x400,200x200@1.5");
326 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
327 EXPECT_TRUE(IsDisplayVisibleInTray());
328 expected
= l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
,
329 GetMirroringDisplayName());
330 EXPECT_EQ(expected
, GetTrayDisplayText());
331 EXPECT_EQ(GetMirroredTooltipText(expected
, GetFirstDisplayName(), "400x400"),
332 GetTrayDisplayTooltipText());
333 CheckAccessibleName();
336 TEST_F(TrayDisplayTest
, OverscanDisplay
) {
337 UpdateDisplay("400x400,300x300/o");
338 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
339 gfx::Display::SetInternalDisplayId(display_manager
->first_display_id());
341 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
342 EXPECT_TRUE(IsDisplayVisibleInTray());
344 // /o creates the default overscan, and if overscan is set, the annotation
345 // should be the size.
346 base::string16 overscan
= l10n_util::GetStringUTF16(
347 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN
);
348 base::string16 headline
= l10n_util::GetStringFUTF16(
349 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
,
350 l10n_util::GetStringFUTF16(
351 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME
,
352 GetSecondDisplayName(), base::UTF8ToUTF16("286x286")));
353 std::string second_data
= l10n_util::GetStringFUTF8(
354 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION
,
355 base::UTF8ToUTF16("286x286"), overscan
);
356 EXPECT_EQ(GetTooltipText(headline
, GetFirstDisplayName(), "400x400",
357 GetSecondDisplayName(), second_data
),
358 GetTrayDisplayTooltipText());
360 // reset the overscan.
361 display_manager
->SetOverscanInsets(
362 ScreenUtil::GetSecondaryDisplay().id(), gfx::Insets());
363 headline
= l10n_util::GetStringFUTF16(
364 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
,
365 l10n_util::GetStringFUTF16(
366 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME
,
367 GetSecondDisplayName(), overscan
));
368 second_data
= l10n_util::GetStringFUTF8(
369 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION
,
370 base::UTF8ToUTF16("300x300"), overscan
);
371 EXPECT_EQ(GetTooltipText(headline
, GetFirstDisplayName(), "400x400",
372 GetSecondDisplayName(), second_data
),
373 GetTrayDisplayTooltipText());
376 TEST_F(TrayDisplayTest
, UpdateDuringDisplayConfigurationChange
) {
377 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
378 EXPECT_FALSE(IsDisplayVisibleInTray());
380 UpdateDisplay("400x400@1.5");
381 EXPECT_TRUE(tray()->HasSystemBubble());
382 EXPECT_TRUE(IsDisplayVisibleInTray());
383 base::string16 internal_info
= l10n_util::GetStringFUTF16(
384 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY
,
385 GetFirstDisplayName(), base::UTF8ToUTF16("600x600"));
386 EXPECT_EQ(internal_info
, GetTrayDisplayText());
387 EXPECT_EQ(GetTooltipText(base::string16(), GetFirstDisplayName(), "600x600",
388 base::string16(), std::string()),
389 GetTrayDisplayTooltipText());
390 CheckAccessibleName();
392 UpdateDisplay("400x400,200x200");
393 EXPECT_TRUE(tray()->HasSystemBubble());
394 EXPECT_TRUE(IsDisplayVisibleInTray());
395 base::string16 expected
= l10n_util::GetStringUTF16(
396 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL
);
397 base::string16 first_name
= GetFirstDisplayName();
398 EXPECT_EQ(expected
, GetTrayDisplayText());
399 EXPECT_EQ(GetTooltipText(expected
, GetFirstDisplayName(), "400x400",
400 GetSecondDisplayName(), "200x200"),
401 GetTrayDisplayTooltipText());
402 CheckAccessibleName();
404 UpdateDisplay("400x400@1.5");
405 tray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
407 // Back to the default state, the display tray item should disappear.
408 UpdateDisplay("400x400");
409 EXPECT_TRUE(tray()->HasSystemBubble());
410 EXPECT_FALSE(IsDisplayVisibleInTray());
413 TEST_F(TrayDisplayTest
, DisplayNotifications
) {
414 test::TestSystemTrayDelegate
* tray_delegate
=
415 static_cast<test::TestSystemTrayDelegate
*>(
416 Shell::GetInstance()->system_tray_delegate());
417 tray_delegate
->set_should_show_display_notification(true);
419 UpdateDisplay("400x400");
420 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
421 gfx::Display::SetInternalDisplayId(display_manager
->first_display_id());
422 EXPECT_TRUE(GetDisplayNotificationText().empty());
425 UpdateDisplay("400x400/r");
426 EXPECT_EQ(l10n_util::GetStringFUTF16(
427 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetFirstDisplayName(),
428 l10n_util::GetStringUTF16(
429 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90
)),
430 GetDisplayNotificationAdditionalText());
431 EXPECT_TRUE(GetDisplayNotificationText().empty());
434 UpdateDisplay("400x400");
435 EXPECT_EQ(l10n_util::GetStringFUTF16(
436 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetFirstDisplayName(),
437 l10n_util::GetStringUTF16(
438 IDS_ASH_STATUS_TRAY_DISPLAY_STANDARD_ORIENTATION
)),
439 GetDisplayNotificationAdditionalText());
440 EXPECT_TRUE(GetDisplayNotificationText().empty());
444 UpdateDisplay("400x400@1.5");
445 EXPECT_EQ(l10n_util::GetStringFUTF16(
446 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED
,
447 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")),
448 GetDisplayNotificationAdditionalText());
449 EXPECT_TRUE(GetDisplayNotificationText().empty());
453 UpdateDisplay("400x400");
454 EXPECT_EQ(l10n_util::GetStringFUTF16(
455 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED
,
456 GetFirstDisplayName(), base::UTF8ToUTF16("400x400")),
457 GetDisplayNotificationAdditionalText());
458 EXPECT_TRUE(GetDisplayNotificationText().empty());
462 UpdateDisplay("400x400");
463 EXPECT_TRUE(GetDisplayNotificationText().empty());
464 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
468 UpdateDisplay("400x400,200x200");
470 l10n_util::GetStringFUTF16(
471 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
, GetSecondDisplayName()),
472 GetDisplayNotificationText());
473 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
477 display_manager
->SetSoftwareMirroring(true);
478 UpdateDisplay("400x400,200x200");
479 EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
,
480 GetMirroringDisplayName()),
481 GetDisplayNotificationText());
482 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
486 display_manager
->SetSoftwareMirroring(false);
487 UpdateDisplay("400x400,200x200");
489 l10n_util::GetStringFUTF16(
490 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
, GetSecondDisplayName()),
491 GetDisplayNotificationText());
492 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
494 // Resize the first display.
495 UpdateDisplay("400x400@1.5,200x200");
496 EXPECT_EQ(l10n_util::GetStringFUTF16(
497 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED
,
498 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")),
499 GetDisplayNotificationAdditionalText());
500 EXPECT_TRUE(GetDisplayNotificationText().empty());
502 // Rotate the second.
503 UpdateDisplay("400x400@1.5,200x200/r");
504 EXPECT_EQ(l10n_util::GetStringFUTF16(
505 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetSecondDisplayName(),
506 l10n_util::GetStringUTF16(
507 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90
)),
508 GetDisplayNotificationAdditionalText());
509 EXPECT_TRUE(GetDisplayNotificationText().empty());
511 // Enters closed lid mode.
512 UpdateDisplay("400x400@1.5,200x200");
513 gfx::Display::SetInternalDisplayId(ScreenUtil::GetSecondaryDisplay().id());
514 UpdateDisplay("400x400@1.5");
515 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED
),
516 GetDisplayNotificationText());
518 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION
),
519 GetDisplayNotificationAdditionalText());
522 TEST_F(TrayDisplayTest
, DisplayConfigurationChangedTwice
) {
523 test::TestSystemTrayDelegate
* tray_delegate
=
524 static_cast<test::TestSystemTrayDelegate
*>(
525 Shell::GetInstance()->system_tray_delegate());
526 tray_delegate
->set_should_show_display_notification(true);
528 UpdateDisplay("400x400,200x200");
530 l10n_util::GetStringUTF16(
531 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL
),
532 GetDisplayNotificationText());
534 // OnDisplayConfigurationChanged() may be called more than once for a single
535 // update display in case of primary is swapped or recovered from dock mode.
536 // Should not remove the notification in such case.
537 tray_display()->OnDisplayConfigurationChanged();
539 l10n_util::GetStringUTF16(
540 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL
),
541 GetDisplayNotificationText());
543 // Back to the single display. It SHOULD remove the notification since the
544 // information is stale.
545 UpdateDisplay("400x400");
546 EXPECT_TRUE(GetDisplayNotificationText().empty());
549 TEST_F(TrayDisplayTest
, UpdateAfterSuppressDisplayNotification
) {
550 UpdateDisplay("400x400,200x200");
552 test::TestSystemTrayDelegate
* tray_delegate
=
553 static_cast<test::TestSystemTrayDelegate
*>(
554 Shell::GetInstance()->system_tray_delegate());
555 tray_delegate
->set_should_show_display_notification(true);
557 // rotate the second.
558 UpdateDisplay("400x400,200x200/r");
559 EXPECT_EQ(l10n_util::GetStringFUTF16(
560 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetSecondDisplayName(),
561 l10n_util::GetStringUTF16(
562 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90
)),
563 GetDisplayNotificationAdditionalText());