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