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
GetMirroredDisplayName() {
69 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
70 return base::UTF8ToUTF16(display_manager
->GetDisplayNameForId(
71 display_manager
->mirrored_display_id()));
74 class TrayDisplayTest
: public ash::test::AshTestBase
{
77 virtual ~TrayDisplayTest();
79 virtual 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(
232 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
, GetMirroredDisplayName());
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(
274 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
, GetMirroredDisplayName());
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(
329 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
, GetMirroredDisplayName());
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");
427 l10n_util::GetStringFUTF16(
428 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetFirstDisplayName(),
429 l10n_util::GetStringUTF16(
430 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90
)),
431 GetDisplayNotificationText());
432 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
435 UpdateDisplay("400x400");
437 l10n_util::GetStringFUTF16(
438 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetFirstDisplayName(),
439 l10n_util::GetStringUTF16(
440 IDS_ASH_STATUS_TRAY_DISPLAY_STANDARD_ORIENTATION
)),
441 GetDisplayNotificationText());
442 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
446 UpdateDisplay("400x400@1.5");
448 l10n_util::GetStringFUTF16(
449 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED
,
450 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")),
451 GetDisplayNotificationText());
452 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
456 UpdateDisplay("400x400");
458 l10n_util::GetStringFUTF16(
459 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED
,
460 GetFirstDisplayName(), base::UTF8ToUTF16("400x400")),
461 GetDisplayNotificationText());
462 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
466 UpdateDisplay("400x400");
467 EXPECT_TRUE(GetDisplayNotificationText().empty());
468 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
472 UpdateDisplay("400x400,200x200");
474 l10n_util::GetStringFUTF16(
475 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
, GetSecondDisplayName()),
476 GetDisplayNotificationText());
477 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
481 display_manager
->SetSoftwareMirroring(true);
482 UpdateDisplay("400x400,200x200");
484 l10n_util::GetStringFUTF16(
485 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
, GetMirroredDisplayName()),
486 GetDisplayNotificationText());
487 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
491 display_manager
->SetSoftwareMirroring(false);
492 UpdateDisplay("400x400,200x200");
494 l10n_util::GetStringFUTF16(
495 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
, GetSecondDisplayName()),
496 GetDisplayNotificationText());
497 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
499 // Resize the first display.
500 UpdateDisplay("400x400@1.5,200x200");
502 l10n_util::GetStringFUTF16(
503 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED
,
504 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")),
505 GetDisplayNotificationText());
506 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
508 // Rotate the second.
509 UpdateDisplay("400x400@1.5,200x200/r");
511 l10n_util::GetStringFUTF16(
512 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
,
513 GetSecondDisplayName(),
514 l10n_util::GetStringUTF16(
515 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90
)),
516 GetDisplayNotificationText());
517 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
519 // Enters closed lid mode.
520 UpdateDisplay("400x400@1.5,200x200");
521 gfx::Display::SetInternalDisplayId(ScreenUtil::GetSecondaryDisplay().id());
522 UpdateDisplay("400x400@1.5");
523 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED
),
524 GetDisplayNotificationText());
526 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION
),
527 GetDisplayNotificationAdditionalText());
530 TEST_F(TrayDisplayTest
, DisplayConfigurationChangedTwice
) {
531 test::TestSystemTrayDelegate
* tray_delegate
=
532 static_cast<test::TestSystemTrayDelegate
*>(
533 Shell::GetInstance()->system_tray_delegate());
534 tray_delegate
->set_should_show_display_notification(true);
536 UpdateDisplay("400x400,200x200");
538 l10n_util::GetStringUTF16(
539 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL
),
540 GetDisplayNotificationText());
542 // OnDisplayConfigurationChanged() may be called more than once for a single
543 // update display in case of primary is swapped or recovered from dock mode.
544 // Should not remove the notification in such case.
545 tray_display()->OnDisplayConfigurationChanged();
547 l10n_util::GetStringUTF16(
548 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL
),
549 GetDisplayNotificationText());
551 // Back to the single display. It SHOULD remove the notification since the
552 // information is stale.
553 UpdateDisplay("400x400");
554 EXPECT_TRUE(GetDisplayNotificationText().empty());
557 TEST_F(TrayDisplayTest
, UpdateAfterSuppressDisplayNotification
) {
558 UpdateDisplay("400x400,200x200");
560 test::TestSystemTrayDelegate
* tray_delegate
=
561 static_cast<test::TestSystemTrayDelegate
*>(
562 Shell::GetInstance()->system_tray_delegate());
563 tray_delegate
->set_should_show_display_notification(true);
565 // rotate the second.
566 UpdateDisplay("400x400,200x200/r");
568 l10n_util::GetStringFUTF16(
569 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
,
570 GetSecondDisplayName(),
571 l10n_util::GetStringUTF16(
572 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90
)),
573 GetDisplayNotificationText());