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 test::DisplayManagerTestApi::EnableUnifiedDesktopForTest();
319 display_manager
->SetDefaultMultiDisplayMode(DisplayManager::UNIFIED
);
320 display_manager
->SetMultiDisplayMode(DisplayManager::UNIFIED
);
321 UpdateDisplay("300x200,400x500");
322 // Update the cache variables as the primary root window changed.
323 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
324 EXPECT_TRUE(IsDisplayVisibleInTray());
325 expected
= l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_UNIFIED
);
326 EXPECT_EQ(expected
, GetTrayDisplayText());
329 TEST_F(TrayDisplayTest
, ExternalDisplayResized
) {
330 UpdateDisplay("400x400");
331 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
332 gfx::Display::SetInternalDisplayId(display_manager
->first_display_id());
334 // Shows the tray_display even though there's a single-display.
335 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
336 EXPECT_FALSE(IsDisplayVisibleInTray());
339 UpdateDisplay("400x400,200x200@1.5");
340 const gfx::Display
& secondary_display
= ScreenUtil::GetSecondaryDisplay();
342 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
343 EXPECT_TRUE(IsDisplayVisibleInTray());
344 base::string16 expected
= l10n_util::GetStringFUTF16(
345 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
,
346 l10n_util::GetStringFUTF16(
347 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME
,
348 GetSecondDisplayName(),
349 base::UTF8ToUTF16(secondary_display
.size().ToString())));
350 EXPECT_EQ(expected
, GetTrayDisplayText());
351 EXPECT_EQ(GetTooltipText(expected
, GetFirstDisplayName(), "400x400",
352 GetSecondDisplayName(), "300x300"),
353 GetTrayDisplayTooltipText());
354 CheckAccessibleName();
357 display_manager
->SetSoftwareMirroring(true);
358 UpdateDisplay("400x400,200x200@1.5");
359 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
360 EXPECT_TRUE(IsDisplayVisibleInTray());
361 expected
= l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
,
362 GetMirroringDisplayName());
363 EXPECT_EQ(expected
, GetTrayDisplayText());
364 EXPECT_EQ(GetMirroredTooltipText(expected
, GetFirstDisplayName(), "400x400"),
365 GetTrayDisplayTooltipText());
366 CheckAccessibleName();
369 TEST_F(TrayDisplayTest
, OverscanDisplay
) {
370 UpdateDisplay("400x400,300x300/o");
371 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
372 gfx::Display::SetInternalDisplayId(display_manager
->first_display_id());
374 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
375 EXPECT_TRUE(IsDisplayVisibleInTray());
377 // /o creates the default overscan, and if overscan is set, the annotation
378 // should be the size.
379 base::string16 overscan
= l10n_util::GetStringUTF16(
380 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN
);
381 base::string16 headline
= l10n_util::GetStringFUTF16(
382 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
,
383 l10n_util::GetStringFUTF16(
384 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME
,
385 GetSecondDisplayName(), base::UTF8ToUTF16("286x286")));
386 std::string second_data
= l10n_util::GetStringFUTF8(
387 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION
,
388 base::UTF8ToUTF16("286x286"), overscan
);
389 EXPECT_EQ(GetTooltipText(headline
, GetFirstDisplayName(), "400x400",
390 GetSecondDisplayName(), second_data
),
391 GetTrayDisplayTooltipText());
393 // reset the overscan.
394 display_manager
->SetOverscanInsets(
395 ScreenUtil::GetSecondaryDisplay().id(), gfx::Insets());
396 headline
= l10n_util::GetStringFUTF16(
397 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
,
398 l10n_util::GetStringFUTF16(
399 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME
,
400 GetSecondDisplayName(), overscan
));
401 second_data
= l10n_util::GetStringFUTF8(
402 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION
,
403 base::UTF8ToUTF16("300x300"), overscan
);
404 EXPECT_EQ(GetTooltipText(headline
, GetFirstDisplayName(), "400x400",
405 GetSecondDisplayName(), second_data
),
406 GetTrayDisplayTooltipText());
409 TEST_F(TrayDisplayTest
, UpdateDuringDisplayConfigurationChange
) {
410 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
411 EXPECT_FALSE(IsDisplayVisibleInTray());
413 UpdateDisplay("400x400@1.5");
414 EXPECT_TRUE(GetTray()->HasSystemBubble());
415 EXPECT_TRUE(IsDisplayVisibleInTray());
416 base::string16 internal_info
= l10n_util::GetStringFUTF16(
417 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY
,
418 GetFirstDisplayName(), base::UTF8ToUTF16("600x600"));
419 EXPECT_EQ(internal_info
, GetTrayDisplayText());
420 EXPECT_EQ(GetTooltipText(base::string16(), GetFirstDisplayName(), "600x600",
421 base::string16(), std::string()),
422 GetTrayDisplayTooltipText());
423 CheckAccessibleName();
425 UpdateDisplay("400x400,200x200");
426 EXPECT_TRUE(GetTray()->HasSystemBubble());
427 EXPECT_TRUE(IsDisplayVisibleInTray());
428 base::string16 expected
= l10n_util::GetStringUTF16(
429 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL
);
430 base::string16 first_name
= GetFirstDisplayName();
431 EXPECT_EQ(expected
, GetTrayDisplayText());
432 EXPECT_EQ(GetTooltipText(expected
, GetFirstDisplayName(), "400x400",
433 GetSecondDisplayName(), "200x200"),
434 GetTrayDisplayTooltipText());
435 CheckAccessibleName();
437 UpdateDisplay("400x400@1.5");
438 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING
);
440 // Back to the default state, the display tray item should disappear.
441 UpdateDisplay("400x400");
442 EXPECT_TRUE(GetTray()->HasSystemBubble());
443 EXPECT_FALSE(IsDisplayVisibleInTray());
446 TEST_F(TrayDisplayTest
, DisplayNotifications
) {
447 test::TestSystemTrayDelegate
* tray_delegate
=
448 static_cast<test::TestSystemTrayDelegate
*>(
449 Shell::GetInstance()->system_tray_delegate());
450 tray_delegate
->set_should_show_display_notification(true);
452 UpdateDisplay("400x400");
453 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
454 gfx::Display::SetInternalDisplayId(display_manager
->first_display_id());
455 EXPECT_TRUE(GetDisplayNotificationText().empty());
458 UpdateDisplay("400x400/r");
459 EXPECT_EQ(l10n_util::GetStringFUTF16(
460 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetFirstDisplayName(),
461 l10n_util::GetStringUTF16(
462 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90
)),
463 GetDisplayNotificationAdditionalText());
464 EXPECT_TRUE(GetDisplayNotificationText().empty());
467 UpdateDisplay("400x400");
468 EXPECT_EQ(l10n_util::GetStringFUTF16(
469 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetFirstDisplayName(),
470 l10n_util::GetStringUTF16(
471 IDS_ASH_STATUS_TRAY_DISPLAY_STANDARD_ORIENTATION
)),
472 GetDisplayNotificationAdditionalText());
473 EXPECT_TRUE(GetDisplayNotificationText().empty());
477 UpdateDisplay("400x400@1.5");
478 EXPECT_EQ(l10n_util::GetStringFUTF16(
479 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED
,
480 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")),
481 GetDisplayNotificationAdditionalText());
482 EXPECT_TRUE(GetDisplayNotificationText().empty());
486 UpdateDisplay("400x400");
487 EXPECT_EQ(l10n_util::GetStringFUTF16(
488 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED
,
489 GetFirstDisplayName(), base::UTF8ToUTF16("400x400")),
490 GetDisplayNotificationAdditionalText());
491 EXPECT_TRUE(GetDisplayNotificationText().empty());
495 UpdateDisplay("400x400");
496 EXPECT_TRUE(GetDisplayNotificationText().empty());
497 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
501 UpdateDisplay("400x400,200x200");
503 l10n_util::GetStringFUTF16(
504 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
, GetSecondDisplayName()),
505 GetDisplayNotificationText());
506 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
510 display_manager
->SetSoftwareMirroring(true);
511 UpdateDisplay("400x400,200x200");
512 EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING
,
513 GetMirroringDisplayName()),
514 GetDisplayNotificationText());
515 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
519 display_manager
->SetSoftwareMirroring(false);
520 UpdateDisplay("400x400,200x200");
522 l10n_util::GetStringFUTF16(
523 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED
, GetSecondDisplayName()),
524 GetDisplayNotificationText());
525 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
527 // Resize the first display.
528 UpdateDisplay("400x400@1.5,200x200");
529 EXPECT_EQ(l10n_util::GetStringFUTF16(
530 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED
,
531 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")),
532 GetDisplayNotificationAdditionalText());
533 EXPECT_TRUE(GetDisplayNotificationText().empty());
535 // Rotate the second.
536 UpdateDisplay("400x400@1.5,200x200/r");
537 EXPECT_EQ(l10n_util::GetStringFUTF16(
538 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetSecondDisplayName(),
539 l10n_util::GetStringUTF16(
540 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90
)),
541 GetDisplayNotificationAdditionalText());
542 EXPECT_TRUE(GetDisplayNotificationText().empty());
544 // Enters closed lid mode.
545 UpdateDisplay("400x400@1.5,200x200");
546 gfx::Display::SetInternalDisplayId(ScreenUtil::GetSecondaryDisplay().id());
547 UpdateDisplay("400x400@1.5");
548 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED
),
549 GetDisplayNotificationText());
551 ash::SubstituteChromeOSDeviceType(
552 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION
),
553 GetDisplayNotificationAdditionalText());
556 TEST_F(TrayDisplayTest
, DisplayConfigurationChangedTwice
) {
557 test::TestSystemTrayDelegate
* tray_delegate
=
558 static_cast<test::TestSystemTrayDelegate
*>(
559 Shell::GetInstance()->system_tray_delegate());
560 tray_delegate
->set_should_show_display_notification(true);
562 UpdateDisplay("400x400,200x200");
564 l10n_util::GetStringUTF16(
565 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL
),
566 GetDisplayNotificationText());
568 // OnDisplayConfigurationChanged() may be called more than once for a single
569 // update display in case of primary is swapped or recovered from dock mode.
570 // Should not remove the notification in such case.
571 GetTrayDisplay()->OnDisplayConfigurationChanged();
573 l10n_util::GetStringUTF16(
574 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL
),
575 GetDisplayNotificationText());
577 // Back to the single display. It SHOULD remove the notification since the
578 // information is stale.
579 UpdateDisplay("400x400");
580 EXPECT_TRUE(GetDisplayNotificationText().empty());
583 TEST_F(TrayDisplayTest
, UpdateAfterSuppressDisplayNotification
) {
584 UpdateDisplay("400x400,200x200");
586 test::TestSystemTrayDelegate
* tray_delegate
=
587 static_cast<test::TestSystemTrayDelegate
*>(
588 Shell::GetInstance()->system_tray_delegate());
589 tray_delegate
->set_should_show_display_notification(true);
591 // rotate the second.
592 UpdateDisplay("400x400,200x200/r");
593 EXPECT_EQ(l10n_util::GetStringFUTF16(
594 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED
, GetSecondDisplayName(),
595 l10n_util::GetStringUTF16(
596 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90
)),
597 GetDisplayNotificationAdditionalText());