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