| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/touch/touch_observer_hud.h" | 5 #include "ash/touch/touch_observer_hud.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 DisplayInfo external_display_info_; | 236 DisplayInfo external_display_info_; |
| 237 DisplayInfo mirrored_display_info_; | 237 DisplayInfo mirrored_display_info_; |
| 238 | 238 |
| 239 std::vector<DisplayInfo> display_info_list_; | 239 std::vector<DisplayInfo> display_info_list_; |
| 240 | 240 |
| 241 DISALLOW_COPY_AND_ASSIGN(TouchHudTest); | 241 DISALLOW_COPY_AND_ASSIGN(TouchHudTest); |
| 242 }; | 242 }; |
| 243 | 243 |
| 244 // Checks if touch HUDs are correctly initialized for displays. | 244 // Checks if touch HUDs are correctly initialized for displays. |
| 245 TEST_F(TouchHudTest, Basic) { | 245 TEST_F(TouchHudTest, Basic) { |
| 246 if (!SupportsMultipleDisplays()) |
| 247 return; |
| 248 |
| 246 // Setup a dual display setting. | 249 // Setup a dual display setting. |
| 247 SetupDualDisplays(); | 250 SetupDualDisplays(); |
| 248 | 251 |
| 249 // Check if touch HUDs are set correctly and associated with appropriate | 252 // Check if touch HUDs are set correctly and associated with appropriate |
| 250 // displays. | 253 // displays. |
| 251 CheckInternalDisplay(); | 254 CheckInternalDisplay(); |
| 252 CheckExternalDisplay(); | 255 CheckExternalDisplay(); |
| 253 } | 256 } |
| 254 | 257 |
| 255 // Checks if touch HUDs are correctly handled when primary display is changed. | 258 // Checks if touch HUDs are correctly handled when primary display is changed. |
| 256 TEST_F(TouchHudTest, SwapPrimaryDisplay) { | 259 TEST_F(TouchHudTest, SwapPrimaryDisplay) { |
| 260 if (!SupportsMultipleDisplays()) |
| 261 return; |
| 262 |
| 257 // Setup a dual display setting. | 263 // Setup a dual display setting. |
| 258 SetupDualDisplays(); | 264 SetupDualDisplays(); |
| 259 | 265 |
| 260 // Set the primary display to the external one. | 266 // Set the primary display to the external one. |
| 261 SetExternalAsPrimary(); | 267 SetExternalAsPrimary(); |
| 262 | 268 |
| 263 // Check if displays' touch HUDs are not swapped as root windows are. | 269 // Check if displays' touch HUDs are not swapped as root windows are. |
| 264 EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id()); | 270 EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id()); |
| 265 EXPECT_EQ(internal_display_id(), GetSecondaryDisplay().id()); | 271 EXPECT_EQ(internal_display_id(), GetSecondaryDisplay().id()); |
| 266 CheckInternalDisplay(); | 272 CheckInternalDisplay(); |
| 267 CheckExternalDisplay(); | 273 CheckExternalDisplay(); |
| 268 | 274 |
| 269 // Set the primary display back to the internal one. | 275 // Set the primary display back to the internal one. |
| 270 SetInternalAsPrimary(); | 276 SetInternalAsPrimary(); |
| 271 | 277 |
| 272 // Check if displays' touch HUDs are not swapped back as root windows are. | 278 // Check if displays' touch HUDs are not swapped back as root windows are. |
| 273 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); | 279 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); |
| 274 EXPECT_EQ(external_display_id(), GetSecondaryDisplay().id()); | 280 EXPECT_EQ(external_display_id(), GetSecondaryDisplay().id()); |
| 275 CheckInternalDisplay(); | 281 CheckInternalDisplay(); |
| 276 CheckExternalDisplay(); | 282 CheckExternalDisplay(); |
| 277 } | 283 } |
| 278 | 284 |
| 279 // Checks if touch HUDs are correctly handled when displays are mirrored. | 285 // Checks if touch HUDs are correctly handled when displays are mirrored. |
| 280 TEST_F(TouchHudTest, MirrorDisplays) { | 286 TEST_F(TouchHudTest, MirrorDisplays) { |
| 287 if (!SupportsMultipleDisplays()) |
| 288 return; |
| 289 |
| 281 // Setup a dual display setting. | 290 // Setup a dual display setting. |
| 282 SetupDualDisplays(); | 291 SetupDualDisplays(); |
| 283 | 292 |
| 284 // Mirror displays. | 293 // Mirror displays. |
| 285 MirrorDisplays(); | 294 MirrorDisplays(); |
| 286 | 295 |
| 287 // Check if the internal display is intact. | 296 // Check if the internal display is intact. |
| 288 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); | 297 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); |
| 289 CheckInternalDisplay(); | 298 CheckInternalDisplay(); |
| 290 | 299 |
| 291 // Unmirror displays. | 300 // Unmirror displays. |
| 292 UnmirrorDisplays(); | 301 UnmirrorDisplays(); |
| 293 | 302 |
| 294 // Check if external display is added back correctly. | 303 // Check if external display is added back correctly. |
| 295 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); | 304 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); |
| 296 EXPECT_EQ(external_display_id(), GetSecondaryDisplay().id()); | 305 EXPECT_EQ(external_display_id(), GetSecondaryDisplay().id()); |
| 297 CheckInternalDisplay(); | 306 CheckInternalDisplay(); |
| 298 CheckExternalDisplay(); | 307 CheckExternalDisplay(); |
| 299 } | 308 } |
| 300 | 309 |
| 301 // Checks if touch HUDs are correctly handled when displays are mirrored after | 310 // Checks if touch HUDs are correctly handled when displays are mirrored after |
| 302 // setting the external display as the primary one. | 311 // setting the external display as the primary one. |
| 303 TEST_F(TouchHudTest, SwapPrimaryThenMirrorDisplays) { | 312 TEST_F(TouchHudTest, SwapPrimaryThenMirrorDisplays) { |
| 313 if (!SupportsMultipleDisplays()) |
| 314 return; |
| 315 |
| 304 // Setup a dual display setting. | 316 // Setup a dual display setting. |
| 305 SetupDualDisplays(); | 317 SetupDualDisplays(); |
| 306 | 318 |
| 307 // Set the primary display to the external one. | 319 // Set the primary display to the external one. |
| 308 SetExternalAsPrimary(); | 320 SetExternalAsPrimary(); |
| 309 | 321 |
| 310 // Mirror displays. | 322 // Mirror displays. |
| 311 MirrorDisplays(); | 323 MirrorDisplays(); |
| 312 | 324 |
| 313 // Check if the internal display is set as the primary one. | 325 // Check if the internal display is set as the primary one. |
| 314 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); | 326 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); |
| 315 CheckInternalDisplay(); | 327 CheckInternalDisplay(); |
| 316 | 328 |
| 317 // Unmirror displays. | 329 // Unmirror displays. |
| 318 UnmirrorDisplays(); | 330 UnmirrorDisplays(); |
| 319 | 331 |
| 320 // Check if the external display is added back as the primary display and | 332 // Check if the external display is added back as the primary display and |
| 321 // touch HUDs are set correctly. | 333 // touch HUDs are set correctly. |
| 322 EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id()); | 334 EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id()); |
| 323 EXPECT_EQ(internal_display_id(), GetSecondaryDisplay().id()); | 335 EXPECT_EQ(internal_display_id(), GetSecondaryDisplay().id()); |
| 324 CheckInternalDisplay(); | 336 CheckInternalDisplay(); |
| 325 CheckExternalDisplay(); | 337 CheckExternalDisplay(); |
| 326 } | 338 } |
| 327 | 339 |
| 328 // Checks if touch HUDs are correctly handled when the external display, which | 340 // Checks if touch HUDs are correctly handled when the external display, which |
| 329 // is the secondary one, is removed. | 341 // is the secondary one, is removed. |
| 330 TEST_F(TouchHudTest, RemoveSecondaryDisplay) { | 342 TEST_F(TouchHudTest, RemoveSecondaryDisplay) { |
| 343 if (!SupportsMultipleDisplays()) |
| 344 return; |
| 345 |
| 331 // Setup a dual display setting. | 346 // Setup a dual display setting. |
| 332 SetupDualDisplays(); | 347 SetupDualDisplays(); |
| 333 | 348 |
| 334 // Remove external display which is the secondary one. | 349 // Remove external display which is the secondary one. |
| 335 RemoveExternalDisplay(); | 350 RemoveExternalDisplay(); |
| 336 | 351 |
| 337 // Check if the internal display is intact. | 352 // Check if the internal display is intact. |
| 338 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); | 353 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); |
| 339 CheckInternalDisplay(); | 354 CheckInternalDisplay(); |
| 340 | 355 |
| 341 // Add external display back. | 356 // Add external display back. |
| 342 AddExternalDisplay(); | 357 AddExternalDisplay(); |
| 343 | 358 |
| 344 // Check if displays' touch HUDs are set correctly. | 359 // Check if displays' touch HUDs are set correctly. |
| 345 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); | 360 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); |
| 346 EXPECT_EQ(external_display_id(), GetSecondaryDisplay().id()); | 361 EXPECT_EQ(external_display_id(), GetSecondaryDisplay().id()); |
| 347 CheckInternalDisplay(); | 362 CheckInternalDisplay(); |
| 348 CheckExternalDisplay(); | 363 CheckExternalDisplay(); |
| 349 } | 364 } |
| 350 | 365 |
| 351 // Checks if touch HUDs are correctly handled when the external display, which | 366 // Checks if touch HUDs are correctly handled when the external display, which |
| 352 // is set as the primary display, is removed. | 367 // is set as the primary display, is removed. |
| 353 TEST_F(TouchHudTest, RemovePrimaryDisplay) { | 368 TEST_F(TouchHudTest, RemovePrimaryDisplay) { |
| 369 if (!SupportsMultipleDisplays()) |
| 370 return; |
| 371 |
| 354 // Setup a dual display setting. | 372 // Setup a dual display setting. |
| 355 SetupDualDisplays(); | 373 SetupDualDisplays(); |
| 356 | 374 |
| 357 // Set the primary display to the external one. | 375 // Set the primary display to the external one. |
| 358 SetExternalAsPrimary(); | 376 SetExternalAsPrimary(); |
| 359 | 377 |
| 360 // Remove the external display which is the primary display. | 378 // Remove the external display which is the primary display. |
| 361 RemoveExternalDisplay(); | 379 RemoveExternalDisplay(); |
| 362 | 380 |
| 363 // Check if the internal display is set as the primary one. | 381 // Check if the internal display is set as the primary one. |
| 364 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); | 382 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); |
| 365 CheckInternalDisplay(); | 383 CheckInternalDisplay(); |
| 366 | 384 |
| 367 // Add the external display back. | 385 // Add the external display back. |
| 368 AddExternalDisplay(); | 386 AddExternalDisplay(); |
| 369 | 387 |
| 370 // Check if the external display is set as primary and touch HUDs are set | 388 // Check if the external display is set as primary and touch HUDs are set |
| 371 // correctly. | 389 // correctly. |
| 372 EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id()); | 390 EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id()); |
| 373 EXPECT_EQ(internal_display_id(), GetSecondaryDisplay().id()); | 391 EXPECT_EQ(internal_display_id(), GetSecondaryDisplay().id()); |
| 374 CheckInternalDisplay(); | 392 CheckInternalDisplay(); |
| 375 CheckExternalDisplay(); | 393 CheckExternalDisplay(); |
| 376 } | 394 } |
| 377 | 395 |
| 378 // Checks if touch HUDs are correctly handled when all displays are removed. | 396 // Checks if touch HUDs are correctly handled when all displays are removed. |
| 379 TEST_F(TouchHudTest, Headless) { | 397 TEST_F(TouchHudTest, Headless) { |
| 398 if (!SupportsMultipleDisplays()) |
| 399 return; |
| 400 |
| 380 // Setup a single display setting. | 401 // Setup a single display setting. |
| 381 SetupSingleDisplay(); | 402 SetupSingleDisplay(); |
| 382 | 403 |
| 383 // Remove the only display which is the internal one. | 404 // Remove the only display which is the internal one. |
| 384 RemoveInternalDisplay(); | 405 RemoveInternalDisplay(); |
| 385 | 406 |
| 386 // Add the internal display back. | 407 // Add the internal display back. |
| 387 AddInternalDisplay(); | 408 AddInternalDisplay(); |
| 388 | 409 |
| 389 // Check if the display's touch HUD is set correctly. | 410 // Check if the display's touch HUD is set correctly. |
| 390 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); | 411 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); |
| 391 CheckInternalDisplay(); | 412 CheckInternalDisplay(); |
| 392 } | 413 } |
| 393 | 414 |
| 394 } // namespace internal | 415 } // namespace internal |
| 395 } // namespace ash | 416 } // namespace ash |
| OLD | NEW |