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

Side by Side Diff: ash/system/chromeos/tray_display_unittest.cc

Issue 2058173002: mash: Move SystemTrayDelegate ownership to WmShell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review feedback Created 4 years, 6 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 2013 The Chromium Authors. All rights reserved. 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 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/system/chromeos/tray_display.h" 5 #include "ash/system/chromeos/tray_display.h"
6 6
7 #include "ash/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 UpdateDisplay("400x400@1.5"); 436 UpdateDisplay("400x400@1.5");
437 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING); 437 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
438 438
439 // Back to the default state, the display tray item should disappear. 439 // Back to the default state, the display tray item should disappear.
440 UpdateDisplay("400x400"); 440 UpdateDisplay("400x400");
441 EXPECT_TRUE(GetTray()->HasSystemBubble()); 441 EXPECT_TRUE(GetTray()->HasSystemBubble());
442 EXPECT_FALSE(IsDisplayVisibleInTray()); 442 EXPECT_FALSE(IsDisplayVisibleInTray());
443 } 443 }
444 444
445 TEST_F(TrayDisplayTest, DisplayNotifications) { 445 TEST_F(TrayDisplayTest, DisplayNotifications) {
446 test::TestSystemTrayDelegate* tray_delegate = 446 test::TestSystemTrayDelegate* tray_delegate = GetSystemTrayDelegate();
447 static_cast<test::TestSystemTrayDelegate*>(
448 Shell::GetInstance()->system_tray_delegate());
449 tray_delegate->set_should_show_display_notification(true); 447 tray_delegate->set_should_show_display_notification(true);
450 448
451 UpdateDisplay("400x400"); 449 UpdateDisplay("400x400");
452 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 450 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
453 display::Display::SetInternalDisplayId(display_manager->first_display_id()); 451 display::Display::SetInternalDisplayId(display_manager->first_display_id());
454 EXPECT_TRUE(GetDisplayNotificationText().empty()); 452 EXPECT_TRUE(GetDisplayNotificationText().empty());
455 453
456 // rotation. 454 // rotation.
457 UpdateDisplay("400x400/r"); 455 UpdateDisplay("400x400/r");
458 EXPECT_EQ(l10n_util::GetStringFUTF16( 456 EXPECT_EQ(l10n_util::GetStringFUTF16(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 UpdateDisplay("400x400@1.5"); 545 UpdateDisplay("400x400@1.5");
548 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED), 546 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED),
549 GetDisplayNotificationText()); 547 GetDisplayNotificationText());
550 EXPECT_EQ( 548 EXPECT_EQ(
551 ash::SubstituteChromeOSDeviceType( 549 ash::SubstituteChromeOSDeviceType(
552 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION), 550 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION),
553 GetDisplayNotificationAdditionalText()); 551 GetDisplayNotificationAdditionalText());
554 } 552 }
555 553
556 TEST_F(TrayDisplayTest, DisplayConfigurationChangedTwice) { 554 TEST_F(TrayDisplayTest, DisplayConfigurationChangedTwice) {
557 test::TestSystemTrayDelegate* tray_delegate = 555 test::TestSystemTrayDelegate* tray_delegate = GetSystemTrayDelegate();
558 static_cast<test::TestSystemTrayDelegate*>(
559 Shell::GetInstance()->system_tray_delegate());
560 tray_delegate->set_should_show_display_notification(true); 556 tray_delegate->set_should_show_display_notification(true);
561 557
562 UpdateDisplay("400x400,200x200"); 558 UpdateDisplay("400x400,200x200");
563 EXPECT_EQ( 559 EXPECT_EQ(
564 l10n_util::GetStringUTF16( 560 l10n_util::GetStringUTF16(
565 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL), 561 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL),
566 GetDisplayNotificationText()); 562 GetDisplayNotificationText());
567 563
568 // OnDisplayConfigurationChanged() may be called more than once for a single 564 // OnDisplayConfigurationChanged() may be called more than once for a single
569 // update display in case of primary is swapped or recovered from dock mode. 565 // update display in case of primary is swapped or recovered from dock mode.
570 // Should not remove the notification in such case. 566 // Should not remove the notification in such case.
571 GetTrayDisplay()->OnDisplayConfigurationChanged(); 567 GetTrayDisplay()->OnDisplayConfigurationChanged();
572 EXPECT_EQ( 568 EXPECT_EQ(
573 l10n_util::GetStringUTF16( 569 l10n_util::GetStringUTF16(
574 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL), 570 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL),
575 GetDisplayNotificationText()); 571 GetDisplayNotificationText());
576 572
577 // Back to the single display. It SHOULD remove the notification since the 573 // Back to the single display. It SHOULD remove the notification since the
578 // information is stale. 574 // information is stale.
579 UpdateDisplay("400x400"); 575 UpdateDisplay("400x400");
580 EXPECT_TRUE(GetDisplayNotificationText().empty()); 576 EXPECT_TRUE(GetDisplayNotificationText().empty());
581 } 577 }
582 578
583 TEST_F(TrayDisplayTest, UpdateAfterSuppressDisplayNotification) { 579 TEST_F(TrayDisplayTest, UpdateAfterSuppressDisplayNotification) {
584 UpdateDisplay("400x400,200x200"); 580 UpdateDisplay("400x400,200x200");
585 581
586 test::TestSystemTrayDelegate* tray_delegate = 582 test::TestSystemTrayDelegate* tray_delegate = GetSystemTrayDelegate();
587 static_cast<test::TestSystemTrayDelegate*>(
588 Shell::GetInstance()->system_tray_delegate());
589 tray_delegate->set_should_show_display_notification(true); 583 tray_delegate->set_should_show_display_notification(true);
590 584
591 // rotate the second. 585 // rotate the second.
592 UpdateDisplay("400x400,200x200/r"); 586 UpdateDisplay("400x400,200x200/r");
593 EXPECT_EQ(l10n_util::GetStringFUTF16( 587 EXPECT_EQ(l10n_util::GetStringFUTF16(
594 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetSecondDisplayName(), 588 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetSecondDisplayName(),
595 l10n_util::GetStringUTF16( 589 l10n_util::GetStringUTF16(
596 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90)), 590 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90)),
597 GetDisplayNotificationAdditionalText()); 591 GetDisplayNotificationAdditionalText());
598 } 592 }
(...skipping 27 matching lines...) Expand all
626 display::Display::ROTATION_SOURCE_ACCELEROMETER); 620 display::Display::ROTATION_SOURCE_ACCELEROMETER);
627 EXPECT_FALSE(IsDisplayVisibleInTray()); 621 EXPECT_FALSE(IsDisplayVisibleInTray());
628 622
629 // If a non-rotation setting is changed, display regardless of the source of 623 // If a non-rotation setting is changed, display regardless of the source of
630 // rotation so that the full message is shown. 624 // rotation so that the full message is shown.
631 UpdateDisplay("400x400@1.5"); 625 UpdateDisplay("400x400@1.5");
632 EXPECT_TRUE(IsDisplayVisibleInTray()); 626 EXPECT_TRUE(IsDisplayVisibleInTray());
633 } 627 }
634 628
635 } // namespace ash 629 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698