Commit 32bef8c1 authored by oshima's avatar oshima Committed by Commit bot

Notificaiton Message for Unified mode

BUG=486187
TEST=covered by test

Review URL: https://codereview.chromium.org/1138253003

Cr-Commit-Position: refs/heads/master@{#329782}
parent 9b142396
...@@ -249,6 +249,9 @@ ...@@ -249,6 +249,9 @@
<message name="IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_270" desc="The value of display orientation option item: 270-degree rotated"> <message name="IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_270" desc="The value of display orientation option item: 270-degree rotated">
270&#x00B0; 270&#x00B0;
</message> </message>
<message name="IDS_ASH_STATUS_TRAY_DISPLAY_UNIFIED" desc="The title of the notification indicating that the system is in unified desktop mode.">
Unified desktop mode
</message>
<message name="IDS_ASH_STATUS_TRAY_CAPS_LOCK_ENABLED" desc="The label used for the tray item to indicate caps lock is on and to toggle caps lock by the click."> <message name="IDS_ASH_STATUS_TRAY_CAPS_LOCK_ENABLED" desc="The label used for the tray item to indicate caps lock is on and to toggle caps lock by the click.">
CAPS LOCK is on CAPS LOCK is on
</message> </message>
......
...@@ -246,6 +246,9 @@ class DisplayView : public ActionableView { ...@@ -246,6 +246,9 @@ class DisplayView : public ActionableView {
IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL); IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL);
} }
if (display_manager->IsInUnifiedMode())
return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_UNIFIED);
int64 primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); int64 primary_id = Shell::GetScreen()->GetPrimaryDisplay().id();
if (gfx::Display::HasInternalDisplay() && if (gfx::Display::HasInternalDisplay() &&
!(gfx::Display::InternalDisplayId() == primary_id)) { !(gfx::Display::InternalDisplayId() == primary_id)) {
......
...@@ -79,8 +79,9 @@ class TrayDisplayTest : public ash::test::AshTestBase { ...@@ -79,8 +79,9 @@ class TrayDisplayTest : public ash::test::AshTestBase {
void SetUp() override; void SetUp() override;
protected: protected:
SystemTray* tray() { return tray_; } SystemTray* GetTray();
TrayDisplay* tray_display() { return tray_display_; } TrayDisplay* GetTrayDisplay();
void CheckUpdate();
void CloseNotification(); void CloseNotification();
bool IsDisplayVisibleInTray() const; bool IsDisplayVisibleInTray() const;
...@@ -110,9 +111,28 @@ TrayDisplayTest::~TrayDisplayTest() { ...@@ -110,9 +111,28 @@ TrayDisplayTest::~TrayDisplayTest() {
void TrayDisplayTest::SetUp() { void TrayDisplayTest::SetUp() {
ash::test::AshTestBase::SetUp(); ash::test::AshTestBase::SetUp();
tray_ = Shell::GetPrimaryRootWindowController()->GetSystemTray(); // Populate tray_ and tray_display_.
tray_display_ = new TrayDisplay(tray_); CheckUpdate();
tray_->AddTrayItem(tray_display_); }
SystemTray* TrayDisplayTest::GetTray() {
CheckUpdate();
return tray_;
}
TrayDisplay* TrayDisplayTest::GetTrayDisplay() {
CheckUpdate();
return tray_display_;
}
void TrayDisplayTest::CheckUpdate() {
SystemTray* current =
Shell::GetPrimaryRootWindowController()->GetSystemTray();
if (tray_ != current) {
tray_ = current;
tray_display_ = new TrayDisplay(tray_);
tray_->AddTrayItem(tray_display_);
}
} }
void TrayDisplayTest::CloseNotification() { void TrayDisplayTest::CloseNotification() {
...@@ -174,11 +194,11 @@ const message_center::Notification* TrayDisplayTest::GetDisplayNotification() ...@@ -174,11 +194,11 @@ const message_center::Notification* TrayDisplayTest::GetDisplayNotification()
TEST_F(TrayDisplayTest, NoInternalDisplay) { TEST_F(TrayDisplayTest, NoInternalDisplay) {
UpdateDisplay("400x400"); UpdateDisplay("400x400");
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_FALSE(IsDisplayVisibleInTray()); EXPECT_FALSE(IsDisplayVisibleInTray());
UpdateDisplay("400x400,200x200"); UpdateDisplay("400x400,200x200");
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_TRUE(IsDisplayVisibleInTray()); EXPECT_TRUE(IsDisplayVisibleInTray());
base::string16 expected = l10n_util::GetStringUTF16( base::string16 expected = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL); IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL);
...@@ -192,7 +212,7 @@ TEST_F(TrayDisplayTest, NoInternalDisplay) { ...@@ -192,7 +212,7 @@ TEST_F(TrayDisplayTest, NoInternalDisplay) {
// mirroring // mirroring
Shell::GetInstance()->display_manager()->SetSoftwareMirroring(true); Shell::GetInstance()->display_manager()->SetSoftwareMirroring(true);
UpdateDisplay("400x400,200x200"); UpdateDisplay("400x400,200x200");
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_TRUE(IsDisplayVisibleInTray()); EXPECT_TRUE(IsDisplayVisibleInTray());
expected = l10n_util::GetStringUTF16( expected = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL); IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL);
...@@ -207,14 +227,14 @@ TEST_F(TrayDisplayTest, InternalDisplay) { ...@@ -207,14 +227,14 @@ TEST_F(TrayDisplayTest, InternalDisplay) {
DisplayManager* display_manager = Shell::GetInstance()->display_manager(); DisplayManager* display_manager = Shell::GetInstance()->display_manager();
gfx::Display::SetInternalDisplayId(display_manager->first_display_id()); gfx::Display::SetInternalDisplayId(display_manager->first_display_id());
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_FALSE(IsDisplayVisibleInTray()); EXPECT_FALSE(IsDisplayVisibleInTray());
// Extended // Extended
UpdateDisplay("400x400,200x200"); UpdateDisplay("400x400,200x200");
base::string16 expected = l10n_util::GetStringFUTF16( base::string16 expected = l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetSecondDisplayName()); IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetSecondDisplayName());
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_TRUE(IsDisplayVisibleInTray()); EXPECT_TRUE(IsDisplayVisibleInTray());
EXPECT_EQ(expected, GetTrayDisplayText()); EXPECT_EQ(expected, GetTrayDisplayText());
EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "400x400", EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "400x400",
...@@ -225,7 +245,7 @@ TEST_F(TrayDisplayTest, InternalDisplay) { ...@@ -225,7 +245,7 @@ TEST_F(TrayDisplayTest, InternalDisplay) {
// Mirroring // Mirroring
display_manager->SetSoftwareMirroring(true); display_manager->SetSoftwareMirroring(true);
UpdateDisplay("400x400,200x200"); UpdateDisplay("400x400,200x200");
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_TRUE(IsDisplayVisibleInTray()); EXPECT_TRUE(IsDisplayVisibleInTray());
expected = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, expected = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING,
...@@ -242,7 +262,7 @@ TEST_F(TrayDisplayTest, InternalDisplayResized) { ...@@ -242,7 +262,7 @@ TEST_F(TrayDisplayTest, InternalDisplayResized) {
gfx::Display::SetInternalDisplayId(display_manager->first_display_id()); gfx::Display::SetInternalDisplayId(display_manager->first_display_id());
// Shows the tray_display even though there's a single-display. // Shows the tray_display even though there's a single-display.
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_TRUE(IsDisplayVisibleInTray()); EXPECT_TRUE(IsDisplayVisibleInTray());
base::string16 internal_info = l10n_util::GetStringFUTF16( base::string16 internal_info = l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY, IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY,
...@@ -255,7 +275,7 @@ TEST_F(TrayDisplayTest, InternalDisplayResized) { ...@@ -255,7 +275,7 @@ TEST_F(TrayDisplayTest, InternalDisplayResized) {
// Extended // Extended
UpdateDisplay("400x400@1.5,200x200"); UpdateDisplay("400x400@1.5,200x200");
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_TRUE(IsDisplayVisibleInTray()); EXPECT_TRUE(IsDisplayVisibleInTray());
base::string16 expected = l10n_util::GetStringFUTF16( base::string16 expected = l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetSecondDisplayName()); IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetSecondDisplayName());
...@@ -268,7 +288,7 @@ TEST_F(TrayDisplayTest, InternalDisplayResized) { ...@@ -268,7 +288,7 @@ TEST_F(TrayDisplayTest, InternalDisplayResized) {
// Mirroring // Mirroring
display_manager->SetSoftwareMirroring(true); display_manager->SetSoftwareMirroring(true);
UpdateDisplay("400x400@1.5,200x200"); UpdateDisplay("400x400@1.5,200x200");
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_TRUE(IsDisplayVisibleInTray()); EXPECT_TRUE(IsDisplayVisibleInTray());
expected = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, expected = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING,
GetMirroringDisplayName()); GetMirroringDisplayName());
...@@ -282,7 +302,7 @@ TEST_F(TrayDisplayTest, InternalDisplayResized) { ...@@ -282,7 +302,7 @@ TEST_F(TrayDisplayTest, InternalDisplayResized) {
UpdateDisplay("400x400@1.5,200x200"); UpdateDisplay("400x400@1.5,200x200");
gfx::Display::SetInternalDisplayId(ScreenUtil::GetSecondaryDisplay().id()); gfx::Display::SetInternalDisplayId(ScreenUtil::GetSecondaryDisplay().id());
UpdateDisplay("400x400@1.5"); UpdateDisplay("400x400@1.5");
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_TRUE(IsDisplayVisibleInTray()); EXPECT_TRUE(IsDisplayVisibleInTray());
expected = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED); expected = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED);
EXPECT_EQ(expected, GetTrayDisplayText()); EXPECT_EQ(expected, GetTrayDisplayText());
...@@ -291,6 +311,16 @@ TEST_F(TrayDisplayTest, InternalDisplayResized) { ...@@ -291,6 +311,16 @@ TEST_F(TrayDisplayTest, InternalDisplayResized) {
expected, GetFirstDisplayName(), "600x600", base::string16(), ""), expected, GetFirstDisplayName(), "600x600", base::string16(), ""),
GetTrayDisplayTooltipText()); GetTrayDisplayTooltipText());
CheckAccessibleName(); CheckAccessibleName();
// Unified mode
display_manager->SetDefaultMultiDisplayMode(DisplayManager::UNIFIED);
display_manager->SetMultiDisplayMode(DisplayManager::UNIFIED);
UpdateDisplay("300x200,400x500");
// Update the cache variables as the primary root window changed.
GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_TRUE(IsDisplayVisibleInTray());
expected = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_UNIFIED);
EXPECT_EQ(expected, GetTrayDisplayText());
} }
TEST_F(TrayDisplayTest, ExternalDisplayResized) { TEST_F(TrayDisplayTest, ExternalDisplayResized) {
...@@ -299,14 +329,14 @@ TEST_F(TrayDisplayTest, ExternalDisplayResized) { ...@@ -299,14 +329,14 @@ TEST_F(TrayDisplayTest, ExternalDisplayResized) {
gfx::Display::SetInternalDisplayId(display_manager->first_display_id()); gfx::Display::SetInternalDisplayId(display_manager->first_display_id());
// Shows the tray_display even though there's a single-display. // Shows the tray_display even though there's a single-display.
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_FALSE(IsDisplayVisibleInTray()); EXPECT_FALSE(IsDisplayVisibleInTray());
// Extended // Extended
UpdateDisplay("400x400,200x200@1.5"); UpdateDisplay("400x400,200x200@1.5");
const gfx::Display& secondary_display = ScreenUtil::GetSecondaryDisplay(); const gfx::Display& secondary_display = ScreenUtil::GetSecondaryDisplay();
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_TRUE(IsDisplayVisibleInTray()); EXPECT_TRUE(IsDisplayVisibleInTray());
base::string16 expected = l10n_util::GetStringFUTF16( base::string16 expected = l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED,
...@@ -323,7 +353,7 @@ TEST_F(TrayDisplayTest, ExternalDisplayResized) { ...@@ -323,7 +353,7 @@ TEST_F(TrayDisplayTest, ExternalDisplayResized) {
// Mirroring // Mirroring
display_manager->SetSoftwareMirroring(true); display_manager->SetSoftwareMirroring(true);
UpdateDisplay("400x400,200x200@1.5"); UpdateDisplay("400x400,200x200@1.5");
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_TRUE(IsDisplayVisibleInTray()); EXPECT_TRUE(IsDisplayVisibleInTray());
expected = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, expected = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING,
GetMirroringDisplayName()); GetMirroringDisplayName());
...@@ -338,7 +368,7 @@ TEST_F(TrayDisplayTest, OverscanDisplay) { ...@@ -338,7 +368,7 @@ TEST_F(TrayDisplayTest, OverscanDisplay) {
DisplayManager* display_manager = Shell::GetInstance()->display_manager(); DisplayManager* display_manager = Shell::GetInstance()->display_manager();
gfx::Display::SetInternalDisplayId(display_manager->first_display_id()); gfx::Display::SetInternalDisplayId(display_manager->first_display_id());
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_TRUE(IsDisplayVisibleInTray()); EXPECT_TRUE(IsDisplayVisibleInTray());
// /o creates the default overscan, and if overscan is set, the annotation // /o creates the default overscan, and if overscan is set, the annotation
...@@ -374,11 +404,11 @@ TEST_F(TrayDisplayTest, OverscanDisplay) { ...@@ -374,11 +404,11 @@ TEST_F(TrayDisplayTest, OverscanDisplay) {
} }
TEST_F(TrayDisplayTest, UpdateDuringDisplayConfigurationChange) { TEST_F(TrayDisplayTest, UpdateDuringDisplayConfigurationChange) {
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
EXPECT_FALSE(IsDisplayVisibleInTray()); EXPECT_FALSE(IsDisplayVisibleInTray());
UpdateDisplay("400x400@1.5"); UpdateDisplay("400x400@1.5");
EXPECT_TRUE(tray()->HasSystemBubble()); EXPECT_TRUE(GetTray()->HasSystemBubble());
EXPECT_TRUE(IsDisplayVisibleInTray()); EXPECT_TRUE(IsDisplayVisibleInTray());
base::string16 internal_info = l10n_util::GetStringFUTF16( base::string16 internal_info = l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY, IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY,
...@@ -390,7 +420,7 @@ TEST_F(TrayDisplayTest, UpdateDuringDisplayConfigurationChange) { ...@@ -390,7 +420,7 @@ TEST_F(TrayDisplayTest, UpdateDuringDisplayConfigurationChange) {
CheckAccessibleName(); CheckAccessibleName();
UpdateDisplay("400x400,200x200"); UpdateDisplay("400x400,200x200");
EXPECT_TRUE(tray()->HasSystemBubble()); EXPECT_TRUE(GetTray()->HasSystemBubble());
EXPECT_TRUE(IsDisplayVisibleInTray()); EXPECT_TRUE(IsDisplayVisibleInTray());
base::string16 expected = l10n_util::GetStringUTF16( base::string16 expected = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL); IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL);
...@@ -402,11 +432,11 @@ TEST_F(TrayDisplayTest, UpdateDuringDisplayConfigurationChange) { ...@@ -402,11 +432,11 @@ TEST_F(TrayDisplayTest, UpdateDuringDisplayConfigurationChange) {
CheckAccessibleName(); CheckAccessibleName();
UpdateDisplay("400x400@1.5"); UpdateDisplay("400x400@1.5");
tray()->ShowDefaultView(BUBBLE_USE_EXISTING); GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
// Back to the default state, the display tray item should disappear. // Back to the default state, the display tray item should disappear.
UpdateDisplay("400x400"); UpdateDisplay("400x400");
EXPECT_TRUE(tray()->HasSystemBubble()); EXPECT_TRUE(GetTray()->HasSystemBubble());
EXPECT_FALSE(IsDisplayVisibleInTray()); EXPECT_FALSE(IsDisplayVisibleInTray());
} }
...@@ -534,7 +564,7 @@ TEST_F(TrayDisplayTest, DisplayConfigurationChangedTwice) { ...@@ -534,7 +564,7 @@ TEST_F(TrayDisplayTest, DisplayConfigurationChangedTwice) {
// OnDisplayConfigurationChanged() may be called more than once for a single // OnDisplayConfigurationChanged() may be called more than once for a single
// update display in case of primary is swapped or recovered from dock mode. // update display in case of primary is swapped or recovered from dock mode.
// Should not remove the notification in such case. // Should not remove the notification in such case.
tray_display()->OnDisplayConfigurationChanged(); GetTrayDisplay()->OnDisplayConfigurationChanged();
EXPECT_EQ( EXPECT_EQ(
l10n_util::GetStringUTF16( l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL), IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment