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/chromeos/devicetype_utils.h"
12 #include "ash/system/tray/system_tray.h"
13 #include "ash/test/ash_test_base.h"
14 #include "ash/test/display_manager_test_api.h"
15 #include "ash/test/test_system_tray_delegate.h"
16 #include "base/strings/string16.h"
17 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h"
19 #include "grit/ash_strings.h"
20 #include "ui/accessibility/ax_view_state.h"
21 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/gfx/display.h"
23 #include "ui/message_center/message_center.h"
24 #include "ui/message_center/notification.h"
25 #include "ui/message_center/notification_list.h"
26 #include "ui/views/controls/label.h"
30 base::string16
GetTooltipText(const base::string16
& headline
,
31 const base::string16
& name1
,
32 const std::string
& data1
,
33 const base::string16
& name2
,
34 const std::string
& data2
) {
35 std::vector
<base::string16
> lines
;
36 lines
.push_back(headline
);
38 lines
.push_back(name1
);
40 lines
.push_back(l10n_util::GetStringFUTF16(
41 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY
,
42 name1
, base::UTF8ToUTF16(data1
)));
45 lines
.push_back(l10n_util::GetStringFUTF16(
46 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY
,
47 name2
, base::UTF8ToUTF16(data2
)));
49 return base::JoinString(lines
, base::ASCIIToUTF16("\n"));
52 base::string16
GetMirroredTooltipText(const base::string16
& headline
,
53 const base::string16
& name
,
54 const std::string
& data
) {
55 return GetTooltipText(headline
, name
, data
, base::string16(), "");
58 base::string16
GetFirstDisplayName() {
59 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
60 return base::UTF8ToUTF16(display_manager
->GetDisplayNameForId(
61 display_manager
->first_display_id()));
64 base::string16
GetSecondDisplayName() {
65 return base::UTF8ToUTF16(
66 Shell::GetInstance()->display_manager()->GetDisplayNameForId(
67 ScreenUtil::GetSecondaryDisplay().id()));
70 base::string16
GetMirroringDisplayName() {
71 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
72 return base::UTF8ToUTF16(display_manager
->GetDisplayNameForId(
73 display_manager
->mirroring_display_id()));
76 class TrayDisplayTest
: public ash::test::AshTestBase
{
79 ~TrayDisplayTest() override
;
81 void SetUp() override
;
84 SystemTray
* GetTray();
85 TrayDisplay
* GetTrayDisplay();
88 void CloseNotification();
89 bool IsDisplayVisibleInTray() const;
90 base::string16
GetTrayDisplayText() const;
91 void CheckAccessibleName() const;
92 base::string16
GetTrayDisplayTooltipText() const;
93 base::string16
GetDisplayNotificationText() const;
94 base::string16
GetDisplayNotificationAdditionalText() const;
97 const message_center::Notification
* GetDisplayNotification() const;
99 // Weak reference, owned by Shell.
102 // Weak reference, owned by |tray_|.
103 TrayDisplay
* tray_display_
;
105 DISALLOW_COPY_AND_ASSIGN(TrayDisplayTest
);
108 TrayDisplayTest::TrayDisplayTest() : tray_(NULL
), tray_display_(NULL
) {
111 TrayDisplayTest::~TrayDisplayTest() {
114 void TrayDisplayTest::SetUp() {
115 ash::test::AshTestBase::SetUp();
116 // Populate tray_ and tray_display_.
120 SystemTray
* TrayDisplayTest::GetTray() {
125 TrayDisplay
* TrayDisplayTest::GetTrayDisplay() {
127 return tray_display_
;
130 void TrayDisplayTest::CheckUpdate() {
131 SystemTray
* current
=
132 Shell::GetPrimaryRootWindowController()->GetSystemTray();
133 if (tray_
!= current
) {
135 tray_display_
= new TrayDisplay(tray_
);
136 tray_
->AddTrayItem(tray_display_
);
140 void TrayDisplayTest::CloseNotification() {
141 message_center::MessageCenter::Get()->RemoveNotification(
142 TrayDisplay::kNotificationId
, false);
143 RunAllPendingInMessageLoop();
146 bool TrayDisplayTest::IsDisplayVisibleInTray() const {
147 return tray_
->HasSystemBubble() &&
148 tray_display_
->default_view() &&
149 tray_display_
->default_view()->visible();
152 base::string16
TrayDisplayTest::GetTrayDisplayText() const {
153 return tray_display_
->GetDefaultViewMessage();
156 void TrayDisplayTest::CheckAccessibleName() const {
157 ui::AXViewState state
;
158 if (tray_display_
->GetAccessibleStateForTesting(&state
)) {
159 base::string16 expected
= tray_display_
->GetDefaultViewMessage();
160 EXPECT_EQ(expected
, state
.name
);
164 base::string16
TrayDisplayTest::GetTrayDisplayTooltipText() const {
165 if (!tray_display_
->default_view())
166 return base::string16();
168 base::string16 tooltip
;
169 if (!tray_display_
->default_view()->GetTooltipText(gfx::Point(), &tooltip
))
170 return base::string16();
174 base::string16
TrayDisplayTest::GetDisplayNotificationText() const {
175 const message_center::Notification
* notification
= GetDisplayNotification();
176 return notification
? notification
->title() : base::string16();
179 base::string16
TrayDisplayTest::GetDisplayNotificationAdditionalText() const {
180 const message_center::Notification
* notification
= GetDisplayNotification();
181 return notification
? notification
->message() : base::string16();
184 const message_center::Notification
* TrayDisplayTest::GetDisplayNotification()
186 const message_center::NotificationList::Notifications notifications
=
187 message_center::MessageCenter::Get()->GetVisibleNotifications();
188 for (message_center::NotificationList::Notifications::const_iterator iter
=
189 notifications
.begin(); iter
!= notifications
.end(); ++iter
) {
190 if ((*iter
)->id() == TrayDisplay::kNotificationId
)
197 TEST_F(TrayDisplayTest
, NoInternalDisplay
) {
198 UpdateDisplay("400x400");
199 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
200 EXPECT_FALSE(IsDisplayVisibleInTray());
202 UpdateDisplay("400x400,200x200");
203 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
204 EXPECT_TRUE(IsDisplayVisibleInTray());
205 base::string16 expected
= l10n_util::GetStringUTF16(
206 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL
);
207 base::string16 first_name
= GetFirstDisplayName();
208 EXPECT_EQ(expected
, GetTrayDisplayText());
209 EXPECT_EQ(GetTooltipText(expected
, GetFirstDisplayName(), "400x400",
210 GetSecondDisplayName(), "200x200"),
211 GetTrayDisplayTooltipText());
212 CheckAccessibleName();
215 Shell::GetInstance()->display_manager()->SetSoftwareMirroring(true);
216 UpdateDisplay("400x400,200x200");
217 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
218 EXPECT_TRUE(IsDisplayVisibleInTray());
219 expected
= l10n_util::GetStringUTF16(
220 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL
);
221 EXPECT_EQ(expected
, GetTrayDisplayText());
222 EXPECT_EQ(GetMirroredTooltipText(expected
, GetFirstDisplayName(), "400x400"),
223 GetTrayDisplayTooltipText());
224 CheckAccessibleName();
227 TEST_F(TrayDisplayTest
, InternalDisplay
) {
228 UpdateDisplay("400x400");
229 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
230 gfx::Display::SetInternalDisplayId(display_manager
->first_display_id());
232 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
233 EXPECT_FALSE(IsDisplayVisibleInTray());
236 UpdateDisplay("400x400,200x200");
237 base::string16 expected
= l10n_util::GetStringFUTF16(
238 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
, GetSecondDisplayName());
239 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
240 EXPECT_TRUE(IsDisplayVisibleInTray());
241 EXPECT_EQ(expected
, GetTrayDisplayText());
242 EXPECT_EQ(GetTooltipText(expected
, GetFirstDisplayName(), "400x400",
243 GetSecondDisplayName(), "200x200"),
244 GetTrayDisplayTooltipText());
245 CheckAccessibleName();
248 display_manager
->SetSoftwareMirroring(true);
249 UpdateDisplay("400x400,200x200");
250 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
251 EXPECT_TRUE(IsDisplayVisibleInTray());
253 expected
= l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
,
254 GetMirroringDisplayName());
255 EXPECT_EQ(expected
, GetTrayDisplayText());
256 EXPECT_EQ(GetMirroredTooltipText(expected
, GetFirstDisplayName(), "400x400"),
257 GetTrayDisplayTooltipText());
258 CheckAccessibleName();
261 TEST_F(TrayDisplayTest
, InternalDisplayResized
) {
262 UpdateDisplay("400x400@1.5");
263 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
264 gfx::Display::SetInternalDisplayId(display_manager
->first_display_id());
266 // Shows the tray_display even though there's a single-display.
267 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
268 EXPECT_TRUE(IsDisplayVisibleInTray());
269 base::string16 internal_info
= l10n_util::GetStringFUTF16(
270 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY
,
271 GetFirstDisplayName(), base::UTF8ToUTF16("600x600"));
272 EXPECT_EQ(internal_info
, GetTrayDisplayText());
273 EXPECT_EQ(GetTooltipText(base::string16(), GetFirstDisplayName(), "600x600",
274 base::string16(), std::string()),
275 GetTrayDisplayTooltipText());
276 CheckAccessibleName();
279 UpdateDisplay("400x400@1.5,200x200");
280 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
281 EXPECT_TRUE(IsDisplayVisibleInTray());
282 base::string16 expected
= l10n_util::GetStringFUTF16(
283 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
, GetSecondDisplayName());
284 EXPECT_EQ(expected
, GetTrayDisplayText());
285 EXPECT_EQ(GetTooltipText(expected
, GetFirstDisplayName(), "600x600",
286 GetSecondDisplayName(), "200x200"),
287 GetTrayDisplayTooltipText());
288 CheckAccessibleName();
291 display_manager
->SetSoftwareMirroring(true);
292 UpdateDisplay("400x400@1.5,200x200");
293 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
294 EXPECT_TRUE(IsDisplayVisibleInTray());
295 expected
= l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
,
296 GetMirroringDisplayName());
297 EXPECT_EQ(expected
, GetTrayDisplayText());
298 EXPECT_EQ(GetMirroredTooltipText(expected
, GetFirstDisplayName(), "600x600"),
299 GetTrayDisplayTooltipText());
300 CheckAccessibleName();
303 display_manager
->SetSoftwareMirroring(false);
304 UpdateDisplay("400x400@1.5,200x200");
305 gfx::Display::SetInternalDisplayId(ScreenUtil::GetSecondaryDisplay().id());
306 UpdateDisplay("400x400@1.5");
307 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
308 EXPECT_TRUE(IsDisplayVisibleInTray());
309 expected
= l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED
);
310 EXPECT_EQ(expected
, GetTrayDisplayText());
313 expected
, GetFirstDisplayName(), "600x600", base::string16(), ""),
314 GetTrayDisplayTooltipText());
315 CheckAccessibleName();
318 display_manager
->SetUnifiedDesktopEnabled(true);
319 UpdateDisplay("300x200,400x500");
320 // Update the cache variables as the primary root window changed.
321 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
322 EXPECT_TRUE(IsDisplayVisibleInTray());
323 expected
= l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_UNIFIED
);
324 EXPECT_EQ(expected
, GetTrayDisplayText());
327 TEST_F(TrayDisplayTest
, ExternalDisplayResized
) {
328 UpdateDisplay("400x400");
329 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
330 gfx::Display::SetInternalDisplayId(display_manager
->first_display_id());
332 // Shows the tray_display even though there's a single-display.
333 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
334 EXPECT_FALSE(IsDisplayVisibleInTray());
337 UpdateDisplay("400x400,200x200@1.5");
338 const gfx::Display
& secondary_display
= ScreenUtil::GetSecondaryDisplay();
340 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
341 EXPECT_TRUE(IsDisplayVisibleInTray());
342 base::string16 expected
= l10n_util::GetStringFUTF16(
343 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
,
344 l10n_util::GetStringFUTF16(
345 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME
,
346 GetSecondDisplayName(),
347 base::UTF8ToUTF16(secondary_display
.size().ToString())));
348 EXPECT_EQ(expected
, GetTrayDisplayText());
349 EXPECT_EQ(GetTooltipText(expected
, GetFirstDisplayName(), "400x400",
350 GetSecondDisplayName(), "300x300"),
351 GetTrayDisplayTooltipText());
352 CheckAccessibleName();
355 display_manager
->SetSoftwareMirroring(true);
356 UpdateDisplay("400x400,200x200@1.5");
357 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
358 EXPECT_TRUE(IsDisplayVisibleInTray());
359 expected
= l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
,
360 GetMirroringDisplayName());
361 EXPECT_EQ(expected
, GetTrayDisplayText());
362 EXPECT_EQ(GetMirroredTooltipText(expected
, GetFirstDisplayName(), "400x400"),
363 GetTrayDisplayTooltipText());
364 CheckAccessibleName();
367 TEST_F(TrayDisplayTest
, OverscanDisplay
) {
368 UpdateDisplay("400x400,300x300/o");
369 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
370 gfx::Display::SetInternalDisplayId(display_manager
->first_display_id());
372 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
373 EXPECT_TRUE(IsDisplayVisibleInTray());
375 // /o creates the default overscan, and if overscan is set, the annotation
376 // should be the size.
377 base::string16 overscan
= l10n_util::GetStringUTF16(
378 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN
);
379 base::string16 headline
= l10n_util::GetStringFUTF16(
380 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
,
381 l10n_util::GetStringFUTF16(
382 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME
,
383 GetSecondDisplayName(), base::UTF8ToUTF16("286x286")));
384 std::string second_data
= l10n_util::GetStringFUTF8(
385 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION
,
386 base::UTF8ToUTF16("286x286"), overscan
);
387 EXPECT_EQ(GetTooltipText(headline
, GetFirstDisplayName(), "400x400",
388 GetSecondDisplayName(), second_data
),
389 GetTrayDisplayTooltipText());
391 // reset the overscan.
392 display_manager
->SetOverscanInsets(
393 ScreenUtil::GetSecondaryDisplay().id(), gfx::Insets());
394 headline
= l10n_util::GetStringFUTF16(
395 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
,
396 l10n_util::GetStringFUTF16(
397 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME
,
398 GetSecondDisplayName(), overscan
));
399 second_data
= l10n_util::GetStringFUTF8(
400 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION
,
401 base::UTF8ToUTF16("300x300"), overscan
);
402 EXPECT_EQ(GetTooltipText(headline
, GetFirstDisplayName(), "400x400",
403 GetSecondDisplayName(), second_data
),
404 GetTrayDisplayTooltipText());
407 TEST_F(TrayDisplayTest
, UpdateDuringDisplayConfigurationChange
) {
408 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
409 EXPECT_FALSE(IsDisplayVisibleInTray());
411 UpdateDisplay("400x400@1.5");
412 EXPECT_TRUE(GetTray()->HasSystemBubble());
413 EXPECT_TRUE(IsDisplayVisibleInTray());
414 base::string16 internal_info
= l10n_util::GetStringFUTF16(
415 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY
,
416 GetFirstDisplayName(), base::UTF8ToUTF16("600x600"));
417 EXPECT_EQ(internal_info
, GetTrayDisplayText());
418 EXPECT_EQ(GetTooltipText(base::string16(), GetFirstDisplayName(), "600x600",
419 base::string16(), std::string()),
420 GetTrayDisplayTooltipText());
421 CheckAccessibleName();
423 UpdateDisplay("400x400,200x200");
424 EXPECT_TRUE(GetTray()->HasSystemBubble());
425 EXPECT_TRUE(IsDisplayVisibleInTray());
426 base::string16 expected
= l10n_util::GetStringUTF16(
427 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL
);
428 base::string16 first_name
= GetFirstDisplayName();
429 EXPECT_EQ(expected
, GetTrayDisplayText());
430 EXPECT_EQ(GetTooltipText(expected
, GetFirstDisplayName(), "400x400",
431 GetSecondDisplayName(), "200x200"),
432 GetTrayDisplayTooltipText());
433 CheckAccessibleName();
435 UpdateDisplay("400x400@1.5");
436 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
438 // Back to the default state, the display tray item should disappear.
439 UpdateDisplay("400x400");
440 EXPECT_TRUE(GetTray()->HasSystemBubble());
441 EXPECT_FALSE(IsDisplayVisibleInTray());
444 TEST_F(TrayDisplayTest
, DisplayNotifications
) {
445 test::TestSystemTrayDelegate
* tray_delegate
=
446 static_cast<test::TestSystemTrayDelegate
*>(
447 Shell::GetInstance()->system_tray_delegate());
448 tray_delegate
->set_should_show_display_notification(true);
450 UpdateDisplay("400x400");
451 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
452 gfx::Display::SetInternalDisplayId(display_manager
->first_display_id());
453 EXPECT_TRUE(GetDisplayNotificationText().empty());
456 UpdateDisplay("400x400/r");
457 EXPECT_EQ(l10n_util::GetStringFUTF16(
458 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetFirstDisplayName(),
459 l10n_util::GetStringUTF16(
460 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90
)),
461 GetDisplayNotificationAdditionalText());
462 EXPECT_TRUE(GetDisplayNotificationText().empty());
465 UpdateDisplay("400x400");
466 EXPECT_EQ(l10n_util::GetStringFUTF16(
467 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetFirstDisplayName(),
468 l10n_util::GetStringUTF16(
469 IDS_ASH_STATUS_TRAY_DISPLAY_STANDARD_ORIENTATION
)),
470 GetDisplayNotificationAdditionalText());
471 EXPECT_TRUE(GetDisplayNotificationText().empty());
475 UpdateDisplay("400x400@1.5");
476 EXPECT_EQ(l10n_util::GetStringFUTF16(
477 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED
,
478 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")),
479 GetDisplayNotificationAdditionalText());
480 EXPECT_TRUE(GetDisplayNotificationText().empty());
484 UpdateDisplay("400x400");
485 EXPECT_EQ(l10n_util::GetStringFUTF16(
486 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED
,
487 GetFirstDisplayName(), base::UTF8ToUTF16("400x400")),
488 GetDisplayNotificationAdditionalText());
489 EXPECT_TRUE(GetDisplayNotificationText().empty());
493 UpdateDisplay("400x400");
494 EXPECT_TRUE(GetDisplayNotificationText().empty());
495 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
499 UpdateDisplay("400x400,200x200");
501 l10n_util::GetStringFUTF16(
502 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
, GetSecondDisplayName()),
503 GetDisplayNotificationText());
504 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
508 display_manager
->SetSoftwareMirroring(true);
509 UpdateDisplay("400x400,200x200");
510 EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
,
511 GetMirroringDisplayName()),
512 GetDisplayNotificationText());
513 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
517 display_manager
->SetSoftwareMirroring(false);
518 UpdateDisplay("400x400,200x200");
520 l10n_util::GetStringFUTF16(
521 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
, GetSecondDisplayName()),
522 GetDisplayNotificationText());
523 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
525 // Resize the first display.
526 UpdateDisplay("400x400@1.5,200x200");
527 EXPECT_EQ(l10n_util::GetStringFUTF16(
528 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED
,
529 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")),
530 GetDisplayNotificationAdditionalText());
531 EXPECT_TRUE(GetDisplayNotificationText().empty());
533 // Rotate the second.
534 UpdateDisplay("400x400@1.5,200x200/r");
535 EXPECT_EQ(l10n_util::GetStringFUTF16(
536 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetSecondDisplayName(),
537 l10n_util::GetStringUTF16(
538 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90
)),
539 GetDisplayNotificationAdditionalText());
540 EXPECT_TRUE(GetDisplayNotificationText().empty());
542 // Enters closed lid mode.
543 UpdateDisplay("400x400@1.5,200x200");
544 gfx::Display::SetInternalDisplayId(ScreenUtil::GetSecondaryDisplay().id());
545 UpdateDisplay("400x400@1.5");
546 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED
),
547 GetDisplayNotificationText());
549 ash::SubstituteChromeOSDeviceType(
550 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION
),
551 GetDisplayNotificationAdditionalText());
554 TEST_F(TrayDisplayTest
, DisplayConfigurationChangedTwice
) {
555 test::TestSystemTrayDelegate
* tray_delegate
=
556 static_cast<test::TestSystemTrayDelegate
*>(
557 Shell::GetInstance()->system_tray_delegate());
558 tray_delegate
->set_should_show_display_notification(true);
560 UpdateDisplay("400x400,200x200");
562 l10n_util::GetStringUTF16(
563 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL
),
564 GetDisplayNotificationText());
566 // OnDisplayConfigurationChanged() may be called more than once for a single
567 // update display in case of primary is swapped or recovered from dock mode.
568 // Should not remove the notification in such case.
569 GetTrayDisplay()->OnDisplayConfigurationChanged();
571 l10n_util::GetStringUTF16(
572 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL
),
573 GetDisplayNotificationText());
575 // Back to the single display. It SHOULD remove the notification since the
576 // information is stale.
577 UpdateDisplay("400x400");
578 EXPECT_TRUE(GetDisplayNotificationText().empty());
581 TEST_F(TrayDisplayTest
, UpdateAfterSuppressDisplayNotification
) {
582 UpdateDisplay("400x400,200x200");
584 test::TestSystemTrayDelegate
* tray_delegate
=
585 static_cast<test::TestSystemTrayDelegate
*>(
586 Shell::GetInstance()->system_tray_delegate());
587 tray_delegate
->set_should_show_display_notification(true);
589 // rotate the second.
590 UpdateDisplay("400x400,200x200/r");
591 EXPECT_EQ(l10n_util::GetStringFUTF16(
592 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetSecondDisplayName(),
593 l10n_util::GetStringUTF16(
594 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90
)),
595 GetDisplayNotificationAdditionalText());