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