| OLD | NEW |
| 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/screen_layout_observer.h" | 5 #include "ash/system/chromeos/screen_layout_observer.h" |
| 6 | 6 |
| 7 #include "ash/common/system/chromeos/devicetype_utils.h" | 7 #include "ash/common/system/chromeos/devicetype_utils.h" |
| 8 #include "ash/common/system/tray/system_tray.h" | 8 #include "ash/common/system/tray/system_tray.h" |
| 9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/display_manager_test_api.h" | 12 #include "ash/test/display_manager_test_api.h" |
| 13 #include "ash/test/test_system_tray_delegate.h" | |
| 14 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 15 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 17 #include "grit/ash_strings.h" | 16 #include "grit/ash_strings.h" |
| 18 #include "ui/accessibility/ax_view_state.h" | 17 #include "ui/accessibility/ax_view_state.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/display/display.h" | 19 #include "ui/display/display.h" |
| 21 #include "ui/message_center/message_center.h" | 20 #include "ui/message_center/message_center.h" |
| 22 #include "ui/message_center/notification.h" | 21 #include "ui/message_center/notification.h" |
| 23 #include "ui/message_center/notification_list.h" | 22 #include "ui/message_center/notification_list.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 notifications.begin(); | 97 notifications.begin(); |
| 99 iter != notifications.end(); ++iter) { | 98 iter != notifications.end(); ++iter) { |
| 100 if ((*iter)->id() == ScreenLayoutObserver::kNotificationId) | 99 if ((*iter)->id() == ScreenLayoutObserver::kNotificationId) |
| 101 return *iter; | 100 return *iter; |
| 102 } | 101 } |
| 103 | 102 |
| 104 return NULL; | 103 return NULL; |
| 105 } | 104 } |
| 106 | 105 |
| 107 TEST_F(ScreenLayoutObserverTest, DisplayNotifications) { | 106 TEST_F(ScreenLayoutObserverTest, DisplayNotifications) { |
| 108 test::TestSystemTrayDelegate* tray_delegate = GetSystemTrayDelegate(); | |
| 109 tray_delegate->set_should_show_display_notification(true); | |
| 110 | |
| 111 UpdateDisplay("400x400"); | 107 UpdateDisplay("400x400"); |
| 112 display::Display::SetInternalDisplayId(display_manager()->first_display_id()); | 108 display::Display::SetInternalDisplayId(display_manager()->first_display_id()); |
| 113 EXPECT_TRUE(GetDisplayNotificationText().empty()); | 109 EXPECT_TRUE(GetDisplayNotificationText().empty()); |
| 114 | 110 |
| 115 // rotation. | 111 // rotation. |
| 116 UpdateDisplay("400x400/r"); | 112 UpdateDisplay("400x400/r"); |
| 117 EXPECT_EQ(l10n_util::GetStringFUTF16( | 113 EXPECT_EQ(l10n_util::GetStringFUTF16( |
| 118 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetFirstDisplayName(), | 114 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetFirstDisplayName(), |
| 119 l10n_util::GetStringUTF16( | 115 l10n_util::GetStringUTF16( |
| 120 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90)), | 116 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90)), |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED), | 201 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED), |
| 206 GetDisplayNotificationText()); | 202 GetDisplayNotificationText()); |
| 207 EXPECT_EQ(ash::SubstituteChromeOSDeviceType( | 203 EXPECT_EQ(ash::SubstituteChromeOSDeviceType( |
| 208 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION), | 204 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION), |
| 209 GetDisplayNotificationAdditionalText()); | 205 GetDisplayNotificationAdditionalText()); |
| 210 } | 206 } |
| 211 | 207 |
| 212 // Verify that notification shows up when display is switched from dock mode to | 208 // Verify that notification shows up when display is switched from dock mode to |
| 213 // extend mode. | 209 // extend mode. |
| 214 TEST_F(ScreenLayoutObserverTest, DisplayConfigurationChangedTwice) { | 210 TEST_F(ScreenLayoutObserverTest, DisplayConfigurationChangedTwice) { |
| 215 test::TestSystemTrayDelegate* tray_delegate = GetSystemTrayDelegate(); | |
| 216 tray_delegate->set_should_show_display_notification(true); | |
| 217 UpdateDisplay("400x400,200x200"); | 211 UpdateDisplay("400x400,200x200"); |
| 218 EXPECT_EQ(l10n_util::GetStringUTF16( | 212 EXPECT_EQ(l10n_util::GetStringUTF16( |
| 219 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL), | 213 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL), |
| 220 GetDisplayNotificationText()); | 214 GetDisplayNotificationText()); |
| 221 | 215 |
| 222 // OnDisplayConfigurationChanged() may be called more than once for a single | 216 // OnDisplayConfigurationChanged() may be called more than once for a single |
| 223 // update display in case of primary is swapped or recovered from dock mode. | 217 // update display in case of primary is swapped or recovered from dock mode. |
| 224 // Should not remove the notification in such case. | 218 // Should not remove the notification in such case. |
| 225 GetScreenLayoutObserver()->OnDisplayConfigurationChanged(); | 219 GetScreenLayoutObserver()->OnDisplayConfigurationChanged(); |
| 226 EXPECT_EQ(l10n_util::GetStringUTF16( | 220 EXPECT_EQ(l10n_util::GetStringUTF16( |
| 227 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL), | 221 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL), |
| 228 GetDisplayNotificationText()); | 222 GetDisplayNotificationText()); |
| 229 | 223 |
| 230 // Back to the single display. It SHOULD remove the notification since the | 224 // Back to the single display. It SHOULD remove the notification since the |
| 231 // information is stale. | 225 // information is stale. |
| 232 UpdateDisplay("400x400"); | 226 UpdateDisplay("400x400"); |
| 233 EXPECT_TRUE(GetDisplayNotificationText().empty()); | 227 EXPECT_TRUE(GetDisplayNotificationText().empty()); |
| 234 } | 228 } |
| 235 | 229 |
| 236 // Verify the notification message content when one of the 2 displays that | 230 // Verify the notification message content when one of the 2 displays that |
| 237 // connected to the device is rotated. | 231 // connected to the device is rotated. |
| 238 TEST_F(ScreenLayoutObserverTest, UpdateAfterSuppressDisplayNotification) { | 232 TEST_F(ScreenLayoutObserverTest, UpdateAfterSuppressDisplayNotification) { |
| 239 UpdateDisplay("400x400,200x200"); | 233 UpdateDisplay("400x400,200x200"); |
| 240 | 234 |
| 241 test::TestSystemTrayDelegate* tray_delegate = GetSystemTrayDelegate(); | 235 // Rotate the second. |
| 242 tray_delegate->set_should_show_display_notification(true); | |
| 243 | |
| 244 // rotate the second. | |
| 245 UpdateDisplay("400x400,200x200/r"); | 236 UpdateDisplay("400x400,200x200/r"); |
| 246 EXPECT_EQ(l10n_util::GetStringFUTF16( | 237 EXPECT_EQ(l10n_util::GetStringFUTF16( |
| 247 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetSecondDisplayName(), | 238 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetSecondDisplayName(), |
| 248 l10n_util::GetStringUTF16( | 239 l10n_util::GetStringUTF16( |
| 249 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90)), | 240 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90)), |
| 250 GetDisplayNotificationAdditionalText()); | 241 GetDisplayNotificationAdditionalText()); |
| 251 } | 242 } |
| 252 | 243 |
| 253 // Verify that no notification is shown when overscan of a screen is changed. | 244 // Verify that no notification is shown when overscan of a screen is changed. |
| 254 TEST_F(ScreenLayoutObserverTest, OverscanDisplay) { | 245 TEST_F(ScreenLayoutObserverTest, OverscanDisplay) { |
| 255 UpdateDisplay("400x400, 300x300"); | 246 UpdateDisplay("400x400, 300x300"); |
| 256 test::TestSystemTrayDelegate* tray_delegate = GetSystemTrayDelegate(); | |
| 257 tray_delegate->set_should_show_display_notification(true); | |
| 258 display::Display::SetInternalDisplayId(display_manager()->first_display_id()); | 247 display::Display::SetInternalDisplayId(display_manager()->first_display_id()); |
| 248 CloseNotification(); |
| 259 | 249 |
| 260 // /o creates the default overscan. | 250 // /o creates the default overscan. |
| 261 UpdateDisplay("400x400, 300x300/o"); | 251 UpdateDisplay("400x400, 300x300/o"); |
| 262 EXPECT_TRUE(GetDisplayNotificationText().empty()); | 252 EXPECT_TRUE(GetDisplayNotificationText().empty()); |
| 263 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty()); | 253 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty()); |
| 264 | 254 |
| 265 // Reset the overscan. | 255 // Reset the overscan. |
| 266 Shell::GetInstance()->display_manager()->SetOverscanInsets( | 256 Shell::GetInstance()->display_manager()->SetOverscanInsets( |
| 267 display_manager()->GetSecondaryDisplay().id(), gfx::Insets()); | 257 display_manager()->GetSecondaryDisplay().id(), gfx::Insets()); |
| 268 EXPECT_TRUE(GetDisplayNotificationText().empty()); | 258 EXPECT_TRUE(GetDisplayNotificationText().empty()); |
| 269 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty()); | 259 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty()); |
| 270 } | 260 } |
| 271 | 261 |
| 272 } // namespace ash | 262 } // namespace ash |
| OLD | NEW |