| 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/display/resolution_notification_controller.h" | 5 #include "ash/display/resolution_notification_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/display_manager.h" | 7 #include "ash/display/display_manager.h" |
| 8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 int accept_count_; | 150 int accept_count_; |
| 151 | 151 |
| 152 DISALLOW_COPY_AND_ASSIGN(ResolutionNotificationControllerTest); | 152 DISALLOW_COPY_AND_ASSIGN(ResolutionNotificationControllerTest); |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 // Basic behaviors and verifies it doesn't cause crashes. | 155 // Basic behaviors and verifies it doesn't cause crashes. |
| 156 TEST_F(ResolutionNotificationControllerTest, Basic) { | 156 TEST_F(ResolutionNotificationControllerTest, Basic) { |
| 157 if (!SupportsMultipleDisplays()) | 157 if (!SupportsMultipleDisplays()) |
| 158 return; | 158 return; |
| 159 | 159 |
| 160 UpdateDisplay("300x300#300x300|200x200,250x250#250x250|200x200"); | 160 UpdateDisplay("300x300#300x300%57|200x200%58,250x250#250x250%59|200x200%60"); |
| 161 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); | 161 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); |
| 162 ash::internal::DisplayManager* display_manager = | 162 ash::internal::DisplayManager* display_manager = |
| 163 ash::Shell::GetInstance()->display_manager(); | 163 ash::Shell::GetInstance()->display_manager(); |
| 164 ASSERT_EQ(0, accept_count()); | 164 ASSERT_EQ(0, accept_count()); |
| 165 EXPECT_FALSE(IsNotificationVisible()); | 165 EXPECT_FALSE(IsNotificationVisible()); |
| 166 | 166 |
| 167 // Changes the resolution and apply the result. | 167 // Changes the resolution and apply the result. |
| 168 SetDisplayResolutionAndNotify( | 168 SetDisplayResolutionAndNotify( |
| 169 ScreenUtil::GetSecondaryDisplay(), gfx::Size(200, 200)); | 169 ScreenUtil::GetSecondaryDisplay(), gfx::Size(200, 200)); |
| 170 EXPECT_TRUE(IsNotificationVisible()); | 170 EXPECT_TRUE(IsNotificationVisible()); |
| 171 EXPECT_FALSE(controller()->DoesNotificationTimeout()); | 171 EXPECT_FALSE(controller()->DoesNotificationTimeout()); |
| 172 EXPECT_EQ(ExpectedNotificationMessage(id2, gfx::Size(200, 200)), | 172 EXPECT_EQ(ExpectedNotificationMessage(id2, gfx::Size(200, 200)), |
| 173 GetNotificationMessage()); | 173 GetNotificationMessage()); |
| 174 gfx::Size resolution; | 174 DisplayMode mode; |
| 175 EXPECT_TRUE( | 175 EXPECT_TRUE(display_manager->GetSelectedModeForDisplayId(id2, &mode)); |
| 176 display_manager->GetSelectedResolutionForDisplayId(id2, &resolution)); | 176 EXPECT_EQ("200x200", mode.size.ToString()); |
| 177 EXPECT_EQ("200x200", resolution.ToString()); | 177 EXPECT_EQ(60.0, mode.refresh_rate); |
| 178 | 178 |
| 179 // Click the revert button, which reverts to the best resolution. | 179 // Click the revert button, which reverts to the best resolution. |
| 180 ClickOnNotificationButton(0); | 180 ClickOnNotificationButton(0); |
| 181 RunAllPendingInMessageLoop(); | 181 RunAllPendingInMessageLoop(); |
| 182 EXPECT_FALSE(IsNotificationVisible()); | 182 EXPECT_FALSE(IsNotificationVisible()); |
| 183 EXPECT_EQ(0, accept_count()); | 183 EXPECT_EQ(0, accept_count()); |
| 184 EXPECT_FALSE( | 184 EXPECT_TRUE(display_manager->GetSelectedModeForDisplayId(id2, &mode)); |
| 185 display_manager->GetSelectedResolutionForDisplayId(id2, &resolution)); | 185 EXPECT_EQ("250x250", mode.size.ToString()); |
| 186 EXPECT_EQ(59.0, mode.refresh_rate); |
| 186 } | 187 } |
| 187 | 188 |
| 188 TEST_F(ResolutionNotificationControllerTest, ClickMeansAccept) { | 189 TEST_F(ResolutionNotificationControllerTest, ClickMeansAccept) { |
| 189 if (!SupportsMultipleDisplays()) | 190 if (!SupportsMultipleDisplays()) |
| 190 return; | 191 return; |
| 191 | 192 |
| 192 UpdateDisplay("300x300#300x300|200x200,250x250#250x250|200x200"); | 193 UpdateDisplay("300x300#300x300%57|200x200%58,250x250#250x250%59|200x200%60"); |
| 193 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); | 194 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); |
| 194 ash::internal::DisplayManager* display_manager = | 195 ash::internal::DisplayManager* display_manager = |
| 195 ash::Shell::GetInstance()->display_manager(); | 196 ash::Shell::GetInstance()->display_manager(); |
| 196 ASSERT_EQ(0, accept_count()); | 197 ASSERT_EQ(0, accept_count()); |
| 197 EXPECT_FALSE(IsNotificationVisible()); | 198 EXPECT_FALSE(IsNotificationVisible()); |
| 198 | 199 |
| 199 // Changes the resolution and apply the result. | 200 // Changes the resolution and apply the result. |
| 200 SetDisplayResolutionAndNotify( | 201 SetDisplayResolutionAndNotify( |
| 201 ScreenUtil::GetSecondaryDisplay(), gfx::Size(200, 200)); | 202 ScreenUtil::GetSecondaryDisplay(), gfx::Size(200, 200)); |
| 202 EXPECT_TRUE(IsNotificationVisible()); | 203 EXPECT_TRUE(IsNotificationVisible()); |
| 203 EXPECT_FALSE(controller()->DoesNotificationTimeout()); | 204 EXPECT_FALSE(controller()->DoesNotificationTimeout()); |
| 204 gfx::Size resolution; | 205 DisplayMode mode; |
| 205 EXPECT_TRUE( | 206 EXPECT_TRUE(display_manager->GetSelectedModeForDisplayId(id2, &mode)); |
| 206 display_manager->GetSelectedResolutionForDisplayId(id2, &resolution)); | 207 EXPECT_EQ("200x200", mode.size.ToString()); |
| 207 EXPECT_EQ("200x200", resolution.ToString()); | 208 EXPECT_EQ(60.0, mode.refresh_rate); |
| 208 | 209 |
| 209 // Click the revert button, which reverts the resolution. | 210 // Click the revert button, which reverts the resolution. |
| 210 ClickOnNotification(); | 211 ClickOnNotification(); |
| 211 RunAllPendingInMessageLoop(); | 212 RunAllPendingInMessageLoop(); |
| 212 EXPECT_FALSE(IsNotificationVisible()); | 213 EXPECT_FALSE(IsNotificationVisible()); |
| 213 EXPECT_EQ(1, accept_count()); | 214 EXPECT_EQ(1, accept_count()); |
| 214 EXPECT_TRUE( | 215 EXPECT_TRUE(display_manager->GetSelectedModeForDisplayId(id2, &mode)); |
| 215 display_manager->GetSelectedResolutionForDisplayId(id2, &resolution)); | 216 EXPECT_EQ("200x200", mode.size.ToString()); |
| 216 EXPECT_EQ("200x200", resolution.ToString()); | 217 EXPECT_EQ(60.0, mode.refresh_rate); |
| 217 } | 218 } |
| 218 | 219 |
| 219 TEST_F(ResolutionNotificationControllerTest, AcceptButton) { | 220 TEST_F(ResolutionNotificationControllerTest, AcceptButton) { |
| 220 if (!SupportsMultipleDisplays()) | 221 if (!SupportsMultipleDisplays()) |
| 221 return; | 222 return; |
| 222 | 223 |
| 223 ash::internal::DisplayManager* display_manager = | 224 ash::internal::DisplayManager* display_manager = |
| 224 ash::Shell::GetInstance()->display_manager(); | 225 ash::Shell::GetInstance()->display_manager(); |
| 225 | 226 |
| 226 UpdateDisplay("300x300#300x300|200x200"); | 227 UpdateDisplay("300x300#300x300%59|200x200%60"); |
| 227 const gfx::Display& display = ash::Shell::GetScreen()->GetPrimaryDisplay(); | 228 const gfx::Display& display = ash::Shell::GetScreen()->GetPrimaryDisplay(); |
| 228 SetDisplayResolutionAndNotify(display, gfx::Size(200, 200)); | 229 SetDisplayResolutionAndNotify(display, gfx::Size(200, 200)); |
| 229 EXPECT_TRUE(IsNotificationVisible()); | 230 EXPECT_TRUE(IsNotificationVisible()); |
| 230 | 231 |
| 231 // If there's a single display only, it will have timeout and the first button | 232 // If there's a single display only, it will have timeout and the first button |
| 232 // becomes accept. | 233 // becomes accept. |
| 233 EXPECT_TRUE(controller()->DoesNotificationTimeout()); | 234 EXPECT_TRUE(controller()->DoesNotificationTimeout()); |
| 234 ClickOnNotificationButton(0); | 235 ClickOnNotificationButton(0); |
| 235 EXPECT_FALSE(IsNotificationVisible()); | 236 EXPECT_FALSE(IsNotificationVisible()); |
| 236 EXPECT_EQ(1, accept_count()); | 237 EXPECT_EQ(1, accept_count()); |
| 237 gfx::Size resolution; | 238 DisplayMode mode; |
| 238 EXPECT_TRUE(display_manager->GetSelectedResolutionForDisplayId( | 239 EXPECT_TRUE( |
| 239 display.id(), &resolution)); | 240 display_manager->GetSelectedModeForDisplayId(display.id(), &mode)); |
| 240 EXPECT_EQ("200x200", resolution.ToString()); | 241 EXPECT_EQ("200x200", mode.size.ToString()); |
| 242 EXPECT_EQ(60.0f, mode.refresh_rate); |
| 241 | 243 |
| 242 // In that case the second button is revert. | 244 // In that case the second button is revert. |
| 243 UpdateDisplay("300x300#300x300|200x200"); | 245 UpdateDisplay("300x300#300x300%59|200x200%60"); |
| 244 SetDisplayResolutionAndNotify(display, gfx::Size(200, 200)); | 246 SetDisplayResolutionAndNotify(display, gfx::Size(200, 200)); |
| 245 EXPECT_TRUE(IsNotificationVisible()); | 247 EXPECT_TRUE(IsNotificationVisible()); |
| 246 | 248 |
| 247 EXPECT_TRUE(controller()->DoesNotificationTimeout()); | 249 EXPECT_TRUE(controller()->DoesNotificationTimeout()); |
| 248 ClickOnNotificationButton(1); | 250 ClickOnNotificationButton(1); |
| 249 EXPECT_FALSE(IsNotificationVisible()); | 251 EXPECT_FALSE(IsNotificationVisible()); |
| 250 EXPECT_EQ(1, accept_count()); | 252 EXPECT_EQ(1, accept_count()); |
| 251 EXPECT_FALSE(display_manager->GetSelectedResolutionForDisplayId( | 253 EXPECT_TRUE( |
| 252 display.id(), &resolution)); | 254 display_manager->GetSelectedModeForDisplayId(display.id(), &mode)); |
| 255 EXPECT_EQ("300x300", mode.size.ToString()); |
| 256 EXPECT_EQ(59.0f, mode.refresh_rate); |
| 253 } | 257 } |
| 254 | 258 |
| 255 TEST_F(ResolutionNotificationControllerTest, Close) { | 259 TEST_F(ResolutionNotificationControllerTest, Close) { |
| 256 if (!SupportsMultipleDisplays()) | 260 if (!SupportsMultipleDisplays()) |
| 257 return; | 261 return; |
| 258 | 262 |
| 259 UpdateDisplay("100x100,150x150#150x150|200x200"); | 263 UpdateDisplay("100x100,150x150#150x150%59|200x200%60"); |
| 260 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); | 264 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); |
| 261 ash::internal::DisplayManager* display_manager = | 265 ash::internal::DisplayManager* display_manager = |
| 262 ash::Shell::GetInstance()->display_manager(); | 266 ash::Shell::GetInstance()->display_manager(); |
| 263 ASSERT_EQ(0, accept_count()); | 267 ASSERT_EQ(0, accept_count()); |
| 264 EXPECT_FALSE(IsNotificationVisible()); | 268 EXPECT_FALSE(IsNotificationVisible()); |
| 265 | 269 |
| 266 // Changes the resolution and apply the result. | 270 // Changes the resolution and apply the result. |
| 267 SetDisplayResolutionAndNotify( | 271 SetDisplayResolutionAndNotify( |
| 268 ScreenUtil::GetSecondaryDisplay(), gfx::Size(200, 200)); | 272 ScreenUtil::GetSecondaryDisplay(), gfx::Size(200, 200)); |
| 269 EXPECT_TRUE(IsNotificationVisible()); | 273 EXPECT_TRUE(IsNotificationVisible()); |
| 270 EXPECT_FALSE(controller()->DoesNotificationTimeout()); | 274 EXPECT_FALSE(controller()->DoesNotificationTimeout()); |
| 271 gfx::Size resolution; | 275 DisplayMode mode; |
| 272 EXPECT_TRUE( | 276 EXPECT_TRUE(display_manager->GetSelectedModeForDisplayId(id2, &mode)); |
| 273 display_manager->GetSelectedResolutionForDisplayId(id2, &resolution)); | 277 EXPECT_EQ("200x200", mode.size.ToString()); |
| 274 EXPECT_EQ("200x200", resolution.ToString()); | 278 EXPECT_EQ(60.0f, mode.refresh_rate); |
| 275 | 279 |
| 276 // Close the notification (imitates clicking [x] button). Also verifies if | 280 // Close the notification (imitates clicking [x] button). Also verifies if |
| 277 // this does not cause a crash. See crbug.com/271784 | 281 // this does not cause a crash. See crbug.com/271784 |
| 278 CloseNotification(); | 282 CloseNotification(); |
| 279 RunAllPendingInMessageLoop(); | 283 RunAllPendingInMessageLoop(); |
| 280 EXPECT_FALSE(IsNotificationVisible()); | 284 EXPECT_FALSE(IsNotificationVisible()); |
| 281 EXPECT_EQ(1, accept_count()); | 285 EXPECT_EQ(1, accept_count()); |
| 282 } | 286 } |
| 283 | 287 |
| 284 TEST_F(ResolutionNotificationControllerTest, Timeout) { | 288 TEST_F(ResolutionNotificationControllerTest, Timeout) { |
| 285 if (!SupportsMultipleDisplays()) | 289 if (!SupportsMultipleDisplays()) |
| 286 return; | 290 return; |
| 287 | 291 |
| 288 UpdateDisplay("300x300#300x300|200x200"); | 292 UpdateDisplay("300x300#300x300%59|200x200%60"); |
| 289 const gfx::Display& display = ash::Shell::GetScreen()->GetPrimaryDisplay(); | 293 const gfx::Display& display = ash::Shell::GetScreen()->GetPrimaryDisplay(); |
| 290 SetDisplayResolutionAndNotify(display, gfx::Size(200, 200)); | 294 SetDisplayResolutionAndNotify(display, gfx::Size(200, 200)); |
| 291 | 295 |
| 292 for (int i = 0; i < ResolutionNotificationController::kTimeoutInSec; ++i) { | 296 for (int i = 0; i < ResolutionNotificationController::kTimeoutInSec; ++i) { |
| 293 EXPECT_TRUE(IsNotificationVisible()) << "notification is closed after " | 297 EXPECT_TRUE(IsNotificationVisible()) << "notification is closed after " |
| 294 << i << "-th timer tick"; | 298 << i << "-th timer tick"; |
| 295 TickTimer(); | 299 TickTimer(); |
| 296 RunAllPendingInMessageLoop(); | 300 RunAllPendingInMessageLoop(); |
| 297 } | 301 } |
| 298 EXPECT_FALSE(IsNotificationVisible()); | 302 EXPECT_FALSE(IsNotificationVisible()); |
| 299 EXPECT_EQ(0, accept_count()); | 303 EXPECT_EQ(0, accept_count()); |
| 300 gfx::Size resolution; | |
| 301 ash::internal::DisplayManager* display_manager = | 304 ash::internal::DisplayManager* display_manager = |
| 302 ash::Shell::GetInstance()->display_manager(); | 305 ash::Shell::GetInstance()->display_manager(); |
| 303 EXPECT_FALSE(display_manager->GetSelectedResolutionForDisplayId( | 306 DisplayMode mode; |
| 304 display.id(), &resolution)); | 307 EXPECT_TRUE( |
| 308 display_manager->GetSelectedModeForDisplayId(display.id(), &mode)); |
| 309 EXPECT_EQ("300x300", mode.size.ToString()); |
| 310 EXPECT_EQ(59.0f, mode.refresh_rate); |
| 305 } | 311 } |
| 306 | 312 |
| 307 TEST_F(ResolutionNotificationControllerTest, DisplayDisconnected) { | 313 TEST_F(ResolutionNotificationControllerTest, DisplayDisconnected) { |
| 308 if (!SupportsMultipleDisplays()) | 314 if (!SupportsMultipleDisplays()) |
| 309 return; | 315 return; |
| 310 | 316 |
| 311 UpdateDisplay("300x300#300x300|200x200,200x200#250x250|200x200|100x100"); | 317 UpdateDisplay("300x300#300x300%56|200x200%57," |
| 318 "200x200#250x250%58|200x200%59|100x100%60"); |
| 312 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); | 319 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); |
| 313 ash::internal::DisplayManager* display_manager = | 320 ash::internal::DisplayManager* display_manager = |
| 314 ash::Shell::GetInstance()->display_manager(); | 321 ash::Shell::GetInstance()->display_manager(); |
| 315 SetDisplayResolutionAndNotify( | 322 SetDisplayResolutionAndNotify( |
| 316 ScreenUtil::GetSecondaryDisplay(), gfx::Size(100, 100)); | 323 ScreenUtil::GetSecondaryDisplay(), gfx::Size(100, 100)); |
| 317 ASSERT_TRUE(IsNotificationVisible()); | 324 ASSERT_TRUE(IsNotificationVisible()); |
| 318 | 325 |
| 319 // Disconnects the secondary display and verifies it doesn't cause crashes. | 326 // Disconnects the secondary display and verifies it doesn't cause crashes. |
| 320 UpdateDisplay("300x300#300x300|200x200"); | 327 UpdateDisplay("300x300#300x300%56|200x200%57"); |
| 321 RunAllPendingInMessageLoop(); | 328 RunAllPendingInMessageLoop(); |
| 322 EXPECT_FALSE(IsNotificationVisible()); | 329 EXPECT_FALSE(IsNotificationVisible()); |
| 323 EXPECT_EQ(0, accept_count()); | 330 EXPECT_EQ(0, accept_count()); |
| 331 DisplayMode mode; |
| 332 EXPECT_TRUE(display_manager->GetSelectedModeForDisplayId(id2, &mode)); |
| 324 gfx::Size resolution; | 333 gfx::Size resolution; |
| 325 EXPECT_TRUE( | 334 EXPECT_EQ("200x200", mode.size.ToString()); |
| 326 display_manager->GetSelectedResolutionForDisplayId(id2, &resolution)); | 335 EXPECT_EQ(59.0f, mode.refresh_rate); |
| 327 EXPECT_EQ("200x200", resolution.ToString()); | |
| 328 } | 336 } |
| 329 | 337 |
| 330 TEST_F(ResolutionNotificationControllerTest, MultipleResolutionChange) { | 338 TEST_F(ResolutionNotificationControllerTest, MultipleResolutionChange) { |
| 331 if (!SupportsMultipleDisplays()) | 339 if (!SupportsMultipleDisplays()) |
| 332 return; | 340 return; |
| 333 | 341 |
| 334 UpdateDisplay("300x300#300x300|200x200,250x250#250x250|200x200"); | 342 UpdateDisplay("300x300#300x300%56|200x200%57," |
| 343 "250x250#250x250%58|200x200%59"); |
| 335 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); | 344 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); |
| 336 ash::internal::DisplayManager* display_manager = | 345 ash::internal::DisplayManager* display_manager = |
| 337 ash::Shell::GetInstance()->display_manager(); | 346 ash::Shell::GetInstance()->display_manager(); |
| 338 | 347 |
| 339 SetDisplayResolutionAndNotify( | 348 SetDisplayResolutionAndNotify( |
| 340 ScreenUtil::GetSecondaryDisplay(), gfx::Size(200, 200)); | 349 ScreenUtil::GetSecondaryDisplay(), gfx::Size(200, 200)); |
| 341 EXPECT_TRUE(IsNotificationVisible()); | 350 EXPECT_TRUE(IsNotificationVisible()); |
| 342 EXPECT_FALSE(controller()->DoesNotificationTimeout()); | 351 EXPECT_FALSE(controller()->DoesNotificationTimeout()); |
| 343 gfx::Size resolution; | 352 DisplayMode mode; |
| 344 EXPECT_TRUE( | 353 EXPECT_TRUE(display_manager->GetSelectedModeForDisplayId(id2, &mode)); |
| 345 display_manager->GetSelectedResolutionForDisplayId(id2, &resolution)); | 354 EXPECT_EQ("200x200", mode.size.ToString()); |
| 346 EXPECT_EQ("200x200", resolution.ToString()); | 355 EXPECT_EQ(59.0f, mode.refresh_rate); |
| 347 | 356 |
| 348 // Invokes SetDisplayResolutionAndNotify during the previous notification is | 357 // Invokes SetDisplayResolutionAndNotify during the previous notification is |
| 349 // visible. | 358 // visible. |
| 350 SetDisplayResolutionAndNotify( | 359 SetDisplayResolutionAndNotify( |
| 351 ScreenUtil::GetSecondaryDisplay(), gfx::Size(250, 250)); | 360 ScreenUtil::GetSecondaryDisplay(), gfx::Size(250, 250)); |
| 352 EXPECT_FALSE( | 361 EXPECT_TRUE(display_manager->GetSelectedModeForDisplayId(id2, &mode)); |
| 353 display_manager->GetSelectedResolutionForDisplayId(id2, &resolution)); | 362 EXPECT_EQ("250x250", mode.size.ToString()); |
| 363 EXPECT_EQ(58.0f, mode.refresh_rate); |
| 354 | 364 |
| 355 // Then, click the revert button. Although |old_resolution| for the second | 365 // Then, click the revert button. Although |old_resolution| for the second |
| 356 // SetDisplayResolutionAndNotify is 200x200, it should revert to the original | 366 // SetDisplayResolutionAndNotify is 200x200, it should revert to the original |
| 357 // size 150x150. | 367 // size 250x250. |
| 358 ClickOnNotificationButton(0); | 368 ClickOnNotificationButton(0); |
| 359 RunAllPendingInMessageLoop(); | 369 RunAllPendingInMessageLoop(); |
| 360 EXPECT_FALSE(IsNotificationVisible()); | 370 EXPECT_FALSE(IsNotificationVisible()); |
| 361 EXPECT_EQ(0, accept_count()); | 371 EXPECT_EQ(0, accept_count()); |
| 362 EXPECT_FALSE( | 372 EXPECT_TRUE(display_manager->GetSelectedModeForDisplayId(id2, &mode)); |
| 363 display_manager->GetSelectedResolutionForDisplayId(id2, &resolution)); | 373 EXPECT_EQ("250x250", mode.size.ToString()); |
| 374 EXPECT_EQ(58.0f, mode.refresh_rate); |
| 364 } | 375 } |
| 365 | 376 |
| 366 TEST_F(ResolutionNotificationControllerTest, Fallback) { | 377 TEST_F(ResolutionNotificationControllerTest, Fallback) { |
| 367 if (!SupportsMultipleDisplays()) | 378 if (!SupportsMultipleDisplays()) |
| 368 return; | 379 return; |
| 369 | 380 |
| 370 UpdateDisplay("300x300#300x300|200x200,250x250#250x250|220x220|200x200"); | 381 UpdateDisplay("300x300#300x300%56|200x200%57," |
| 382 "250x250#250x250%58|220x220%59|200x200%60"); |
| 371 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); | 383 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); |
| 372 ash::internal::DisplayManager* display_manager = | 384 ash::internal::DisplayManager* display_manager = |
| 373 ash::Shell::GetInstance()->display_manager(); | 385 ash::Shell::GetInstance()->display_manager(); |
| 374 ASSERT_EQ(0, accept_count()); | 386 ASSERT_EQ(0, accept_count()); |
| 375 EXPECT_FALSE(IsNotificationVisible()); | 387 EXPECT_FALSE(IsNotificationVisible()); |
| 376 | 388 |
| 377 // Changes the resolution and apply the result. | 389 // Changes the resolution and apply the result. |
| 378 SetDisplayResolutionAndNotifyWithResolution( | 390 SetDisplayResolutionAndNotifyWithResolution( |
| 379 ScreenUtil::GetSecondaryDisplay(), | 391 ScreenUtil::GetSecondaryDisplay(), |
| 380 gfx::Size(220, 220), | 392 gfx::Size(220, 220), |
| 381 gfx::Size(200, 200)); | 393 gfx::Size(200, 200)); |
| 382 EXPECT_TRUE(IsNotificationVisible()); | 394 EXPECT_TRUE(IsNotificationVisible()); |
| 383 EXPECT_FALSE(controller()->DoesNotificationTimeout()); | 395 EXPECT_FALSE(controller()->DoesNotificationTimeout()); |
| 384 EXPECT_EQ( | 396 EXPECT_EQ( |
| 385 ExpectedFallbackNotificationMessage( | 397 ExpectedFallbackNotificationMessage( |
| 386 id2, gfx::Size(220, 220), gfx::Size(200, 200)), | 398 id2, gfx::Size(220, 220), gfx::Size(200, 200)), |
| 387 GetNotificationMessage()); | 399 GetNotificationMessage()); |
| 388 gfx::Size resolution; | 400 DisplayMode mode; |
| 389 EXPECT_TRUE( | 401 EXPECT_TRUE(display_manager->GetSelectedModeForDisplayId(id2, &mode)); |
| 390 display_manager->GetSelectedResolutionForDisplayId(id2, &resolution)); | 402 EXPECT_EQ("200x200", mode.size.ToString()); |
| 391 EXPECT_EQ("200x200", resolution.ToString()); | 403 EXPECT_EQ(60.0f, mode.refresh_rate); |
| 392 | 404 |
| 393 // Click the revert button, which reverts to the best resolution. | 405 // Click the revert button, which reverts to the best resolution. |
| 394 ClickOnNotificationButton(0); | 406 ClickOnNotificationButton(0); |
| 395 RunAllPendingInMessageLoop(); | 407 RunAllPendingInMessageLoop(); |
| 396 EXPECT_FALSE(IsNotificationVisible()); | 408 EXPECT_FALSE(IsNotificationVisible()); |
| 397 EXPECT_EQ(0, accept_count()); | 409 EXPECT_EQ(0, accept_count()); |
| 398 EXPECT_FALSE( | 410 EXPECT_TRUE(display_manager->GetSelectedModeForDisplayId(id2, &mode)); |
| 399 display_manager->GetSelectedResolutionForDisplayId(id2, &resolution)); | 411 EXPECT_EQ("250x250", mode.size.ToString()); |
| 412 EXPECT_EQ(58.0f, mode.refresh_rate); |
| 400 } | 413 } |
| 401 | 414 |
| 402 } // namespace internal | 415 } // namespace internal |
| 403 } // namespace ash | 416 } // namespace ash |
| OLD | NEW |