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

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: 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/common/wm_shell.h"
7 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
8 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 10 #include "ash/screen_util.h"
10 #include "ash/shell.h" 11 #include "ash/shell.h"
11 #include "ash/system/chromeos/devicetype_utils.h" 12 #include "ash/system/chromeos/devicetype_utils.h"
12 #include "ash/system/tray/system_tray.h" 13 #include "ash/system/tray/system_tray.h"
13 #include "ash/test/ash_test_base.h" 14 #include "ash/test/ash_test_base.h"
14 #include "ash/test/display_manager_test_api.h" 15 #include "ash/test/display_manager_test_api.h"
15 #include "ash/test/test_system_tray_delegate.h" 16 #include "ash/test/test_system_tray_delegate.h"
16 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 UpdateDisplay("400x400@1.5"); 437 UpdateDisplay("400x400@1.5");
437 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING); 438 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
438 439
439 // Back to the default state, the display tray item should disappear. 440 // Back to the default state, the display tray item should disappear.
440 UpdateDisplay("400x400"); 441 UpdateDisplay("400x400");
441 EXPECT_TRUE(GetTray()->HasSystemBubble()); 442 EXPECT_TRUE(GetTray()->HasSystemBubble());
442 EXPECT_FALSE(IsDisplayVisibleInTray()); 443 EXPECT_FALSE(IsDisplayVisibleInTray());
443 } 444 }
444 445
445 TEST_F(TrayDisplayTest, DisplayNotifications) { 446 TEST_F(TrayDisplayTest, DisplayNotifications) {
446 test::TestSystemTrayDelegate* tray_delegate = 447 test::TestSystemTrayDelegate* tray_delegate =
msw 2016/06/10 18:48:21 nit: AshTestBase::GetSystemTrayDelegate here and t
James Cook 2016/06/10 20:20:32 Done.
447 static_cast<test::TestSystemTrayDelegate*>( 448 static_cast<test::TestSystemTrayDelegate*>(
448 Shell::GetInstance()->system_tray_delegate()); 449 WmShell::Get()->system_tray_delegate());
449 tray_delegate->set_should_show_display_notification(true); 450 tray_delegate->set_should_show_display_notification(true);
450 451
451 UpdateDisplay("400x400"); 452 UpdateDisplay("400x400");
452 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 453 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
453 display::Display::SetInternalDisplayId(display_manager->first_display_id()); 454 display::Display::SetInternalDisplayId(display_manager->first_display_id());
454 EXPECT_TRUE(GetDisplayNotificationText().empty()); 455 EXPECT_TRUE(GetDisplayNotificationText().empty());
455 456
456 // rotation. 457 // rotation.
457 UpdateDisplay("400x400/r"); 458 UpdateDisplay("400x400/r");
458 EXPECT_EQ(l10n_util::GetStringFUTF16( 459 EXPECT_EQ(l10n_util::GetStringFUTF16(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 GetDisplayNotificationText()); 550 GetDisplayNotificationText());
550 EXPECT_EQ( 551 EXPECT_EQ(
551 ash::SubstituteChromeOSDeviceType( 552 ash::SubstituteChromeOSDeviceType(
552 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION), 553 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION),
553 GetDisplayNotificationAdditionalText()); 554 GetDisplayNotificationAdditionalText());
554 } 555 }
555 556
556 TEST_F(TrayDisplayTest, DisplayConfigurationChangedTwice) { 557 TEST_F(TrayDisplayTest, DisplayConfigurationChangedTwice) {
557 test::TestSystemTrayDelegate* tray_delegate = 558 test::TestSystemTrayDelegate* tray_delegate =
558 static_cast<test::TestSystemTrayDelegate*>( 559 static_cast<test::TestSystemTrayDelegate*>(
559 Shell::GetInstance()->system_tray_delegate()); 560 WmShell::Get()->system_tray_delegate());
560 tray_delegate->set_should_show_display_notification(true); 561 tray_delegate->set_should_show_display_notification(true);
561 562
562 UpdateDisplay("400x400,200x200"); 563 UpdateDisplay("400x400,200x200");
563 EXPECT_EQ( 564 EXPECT_EQ(
564 l10n_util::GetStringUTF16( 565 l10n_util::GetStringUTF16(
565 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL), 566 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL),
566 GetDisplayNotificationText()); 567 GetDisplayNotificationText());
567 568
568 // OnDisplayConfigurationChanged() may be called more than once for a single 569 // 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 // update display in case of primary is swapped or recovered from dock mode.
570 // Should not remove the notification in such case. 571 // Should not remove the notification in such case.
571 GetTrayDisplay()->OnDisplayConfigurationChanged(); 572 GetTrayDisplay()->OnDisplayConfigurationChanged();
572 EXPECT_EQ( 573 EXPECT_EQ(
573 l10n_util::GetStringUTF16( 574 l10n_util::GetStringUTF16(
574 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL), 575 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL),
575 GetDisplayNotificationText()); 576 GetDisplayNotificationText());
576 577
577 // Back to the single display. It SHOULD remove the notification since the 578 // Back to the single display. It SHOULD remove the notification since the
578 // information is stale. 579 // information is stale.
579 UpdateDisplay("400x400"); 580 UpdateDisplay("400x400");
580 EXPECT_TRUE(GetDisplayNotificationText().empty()); 581 EXPECT_TRUE(GetDisplayNotificationText().empty());
581 } 582 }
582 583
583 TEST_F(TrayDisplayTest, UpdateAfterSuppressDisplayNotification) { 584 TEST_F(TrayDisplayTest, UpdateAfterSuppressDisplayNotification) {
584 UpdateDisplay("400x400,200x200"); 585 UpdateDisplay("400x400,200x200");
585 586
586 test::TestSystemTrayDelegate* tray_delegate = 587 test::TestSystemTrayDelegate* tray_delegate =
587 static_cast<test::TestSystemTrayDelegate*>( 588 static_cast<test::TestSystemTrayDelegate*>(
588 Shell::GetInstance()->system_tray_delegate()); 589 WmShell::Get()->system_tray_delegate());
589 tray_delegate->set_should_show_display_notification(true); 590 tray_delegate->set_should_show_display_notification(true);
590 591
591 // rotate the second. 592 // rotate the second.
592 UpdateDisplay("400x400,200x200/r"); 593 UpdateDisplay("400x400,200x200/r");
593 EXPECT_EQ(l10n_util::GetStringFUTF16( 594 EXPECT_EQ(l10n_util::GetStringFUTF16(
594 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetSecondDisplayName(), 595 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetSecondDisplayName(),
595 l10n_util::GetStringUTF16( 596 l10n_util::GetStringUTF16(
596 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90)), 597 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90)),
597 GetDisplayNotificationAdditionalText()); 598 GetDisplayNotificationAdditionalText());
598 } 599 }
(...skipping 27 matching lines...) Expand all
626 display::Display::ROTATION_SOURCE_ACCELEROMETER); 627 display::Display::ROTATION_SOURCE_ACCELEROMETER);
627 EXPECT_FALSE(IsDisplayVisibleInTray()); 628 EXPECT_FALSE(IsDisplayVisibleInTray());
628 629
629 // If a non-rotation setting is changed, display regardless of the source of 630 // If a non-rotation setting is changed, display regardless of the source of
630 // rotation so that the full message is shown. 631 // rotation so that the full message is shown.
631 UpdateDisplay("400x400@1.5"); 632 UpdateDisplay("400x400@1.5");
632 EXPECT_TRUE(IsDisplayVisibleInTray()); 633 EXPECT_TRUE(IsDisplayVisibleInTray());
633 } 634 }
634 635
635 } // namespace ash 636 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698