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