Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ash/touch/touch_observer_hud_unittest.cc

Issue 2355063002: Separate ash::test::DisplayManagerTestApi from ash (Closed)
Patch Set: review comment Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/test/display_manager_test_api.cc ('k') | ash/touch/touchscreen_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/ash_switches.h" 7 #include "ash/common/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/screen_util.h"
11 #include "ash/shell.h" 10 #include "ash/shell.h"
12 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
13 #include "ash/test/display_manager_test_api.h" 12 #include "ash/test/display_manager_test_api.h"
14 #include "ash/touch/touch_hud_debug.h" 13 #include "ash/touch/touch_hud_debug.h"
15 #include "ash/touch/touch_hud_projection.h" 14 #include "ash/touch/touch_hud_projection.h"
16 #include "ash/touch_hud/touch_hud_renderer.h" 15 #include "ash/touch_hud/touch_hud_renderer.h"
17 #include "base/command_line.h" 16 #include "base/command_line.h"
18 #include "base/format_macros.h" 17 #include "base/format_macros.h"
19 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
20 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
21 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
22 21
23 namespace ash { 22 namespace ash {
24 23
25 class TouchHudTestBase : public test::AshTestBase { 24 class TouchHudTestBase : public test::AshTestBase {
26 public: 25 public:
27 TouchHudTestBase() {} 26 TouchHudTestBase() {}
28 ~TouchHudTestBase() override {} 27 ~TouchHudTestBase() override {}
29 28
30 void SetUp() override { 29 void SetUp() override {
31 test::AshTestBase::SetUp(); 30 test::AshTestBase::SetUp();
32 31
33 // Initialize display infos. They should be initialized after Ash 32 // Initialize display infos. They should be initialized after Ash
34 // environment is set up, i.e., after test::AshTestBase::SetUp(). 33 // environment is set up, i.e., after test::AshTestBase::SetUp().
35 internal_display_id_ = 34 internal_display_id_ =
36 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); 35 test::DisplayManagerTestApi(Shell::GetInstance()->display_manager())
36 .SetFirstDisplayAsInternalDisplay();
37 external_display_id_ = 10; 37 external_display_id_ = 10;
38 mirrored_display_id_ = 11; 38 mirrored_display_id_ = 11;
39 39
40 internal_display_info_ = 40 internal_display_info_ =
41 CreateDisplayInfo(internal_display_id_, gfx::Rect(0, 0, 500, 500)); 41 CreateDisplayInfo(internal_display_id_, gfx::Rect(0, 0, 500, 500));
42 external_display_info_ = 42 external_display_info_ =
43 CreateDisplayInfo(external_display_id_, gfx::Rect(1, 1, 100, 100)); 43 CreateDisplayInfo(external_display_id_, gfx::Rect(1, 1, 100, 100));
44 mirrored_display_info_ = 44 mirrored_display_info_ =
45 CreateDisplayInfo(mirrored_display_id_, gfx::Rect(0, 0, 100, 100)); 45 CreateDisplayInfo(mirrored_display_id_, gfx::Rect(0, 0, 100, 100));
46 } 46 }
47 47
48 display::Display GetPrimaryDisplay() { 48 display::Display GetPrimaryDisplay() {
49 return display::Screen::GetScreen()->GetPrimaryDisplay(); 49 return display::Screen::GetScreen()->GetPrimaryDisplay();
50 } 50 }
51 51
52 const display::Display& GetSecondaryDisplay() {
53 return ScreenUtil::GetSecondaryDisplay();
54 }
55
56 void SetupSingleDisplay() { 52 void SetupSingleDisplay() {
57 display_info_list_.clear(); 53 display_info_list_.clear();
58 display_info_list_.push_back(internal_display_info_); 54 display_info_list_.push_back(internal_display_info_);
59 GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_); 55 GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_);
60 } 56 }
61 57
62 void SetupDualDisplays() { 58 void SetupDualDisplays() {
63 display_info_list_.clear(); 59 display_info_list_.clear();
64 display_info_list_.push_back(internal_display_info_); 60 display_info_list_.push_back(internal_display_info_);
65 display_info_list_.push_back(external_display_info_); 61 display_info_list_.push_back(external_display_info_);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return GetWindowTreeHostManager()->GetRootWindowForDisplayId( 141 return GetWindowTreeHostManager()->GetRootWindowForDisplayId(
146 external_display_id_); 142 external_display_id_);
147 } 143 }
148 144
149 aura::Window* GetPrimaryRootWindow() { 145 aura::Window* GetPrimaryRootWindow() {
150 const display::Display& display = GetPrimaryDisplay(); 146 const display::Display& display = GetPrimaryDisplay();
151 return GetWindowTreeHostManager()->GetRootWindowForDisplayId(display.id()); 147 return GetWindowTreeHostManager()->GetRootWindowForDisplayId(display.id());
152 } 148 }
153 149
154 aura::Window* GetSecondaryRootWindow() { 150 aura::Window* GetSecondaryRootWindow() {
155 const display::Display& display = GetSecondaryDisplay(); 151 const display::Display& display = display_manager()->GetSecondaryDisplay();
156 return GetWindowTreeHostManager()->GetRootWindowForDisplayId(display.id()); 152 return GetWindowTreeHostManager()->GetRootWindowForDisplayId(display.id());
157 } 153 }
158 154
159 RootWindowController* GetInternalRootController() { 155 RootWindowController* GetInternalRootController() {
160 aura::Window* root = GetInternalRootWindow(); 156 aura::Window* root = GetInternalRootWindow();
161 return GetRootWindowController(root); 157 return GetRootWindowController(root);
162 } 158 }
163 159
164 RootWindowController* GetExternalRootController() { 160 RootWindowController* GetExternalRootController() {
165 aura::Window* root = GetExternalRootWindow(); 161 aura::Window* root = GetExternalRootWindow();
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 return; 338 return;
343 339
344 // Setup a dual display setting. 340 // Setup a dual display setting.
345 SetupDualDisplays(); 341 SetupDualDisplays();
346 342
347 // Set the primary display to the external one. 343 // Set the primary display to the external one.
348 SetExternalAsPrimary(); 344 SetExternalAsPrimary();
349 345
350 // Check if displays' touch HUDs are not swapped as root windows are. 346 // Check if displays' touch HUDs are not swapped as root windows are.
351 EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id()); 347 EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id());
352 EXPECT_EQ(internal_display_id(), GetSecondaryDisplay().id()); 348 EXPECT_EQ(internal_display_id(),
349 display_manager()->GetSecondaryDisplay().id());
353 CheckInternalDisplay(); 350 CheckInternalDisplay();
354 CheckExternalDisplay(); 351 CheckExternalDisplay();
355 352
356 // Set the primary display back to the internal one. 353 // Set the primary display back to the internal one.
357 SetInternalAsPrimary(); 354 SetInternalAsPrimary();
358 355
359 // Check if displays' touch HUDs are not swapped back as root windows are. 356 // Check if displays' touch HUDs are not swapped back as root windows are.
360 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); 357 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
361 EXPECT_EQ(external_display_id(), GetSecondaryDisplay().id()); 358 EXPECT_EQ(external_display_id(),
359 display_manager()->GetSecondaryDisplay().id());
362 CheckInternalDisplay(); 360 CheckInternalDisplay();
363 CheckExternalDisplay(); 361 CheckExternalDisplay();
364 } 362 }
365 363
366 // Checks if debug touch HUDs are correctly handled when displays are mirrored. 364 // Checks if debug touch HUDs are correctly handled when displays are mirrored.
367 TEST_F(TouchHudDebugTest, MirrorDisplays) { 365 TEST_F(TouchHudDebugTest, MirrorDisplays) {
368 if (!SupportsMultipleDisplays()) 366 if (!SupportsMultipleDisplays())
369 return; 367 return;
370 368
371 // Setup a dual display setting. 369 // Setup a dual display setting.
372 SetupDualDisplays(); 370 SetupDualDisplays();
373 371
374 // Mirror displays. 372 // Mirror displays.
375 MirrorDisplays(); 373 MirrorDisplays();
376 374
377 // Check if the internal display is intact. 375 // Check if the internal display is intact.
378 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); 376 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
379 CheckInternalDisplay(); 377 CheckInternalDisplay();
380 378
381 // Unmirror displays. 379 // Unmirror displays.
382 UnmirrorDisplays(); 380 UnmirrorDisplays();
383 381
384 // Check if external display is added back correctly. 382 // Check if external display is added back correctly.
385 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); 383 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
386 EXPECT_EQ(external_display_id(), GetSecondaryDisplay().id()); 384 EXPECT_EQ(external_display_id(),
385 display_manager()->GetSecondaryDisplay().id());
387 CheckInternalDisplay(); 386 CheckInternalDisplay();
388 CheckExternalDisplay(); 387 CheckExternalDisplay();
389 } 388 }
390 389
391 // Checks if debug touch HUDs are correctly handled when displays are mirrored 390 // Checks if debug touch HUDs are correctly handled when displays are mirrored
392 // after setting the external display as the primary one. 391 // after setting the external display as the primary one.
393 TEST_F(TouchHudDebugTest, SwapPrimaryThenMirrorDisplays) { 392 TEST_F(TouchHudDebugTest, SwapPrimaryThenMirrorDisplays) {
394 if (!SupportsMultipleDisplays()) 393 if (!SupportsMultipleDisplays())
395 return; 394 return;
396 395
397 // Setup a dual display setting. 396 // Setup a dual display setting.
398 SetupDualDisplays(); 397 SetupDualDisplays();
399 398
400 // Set the primary display to the external one. 399 // Set the primary display to the external one.
401 SetExternalAsPrimary(); 400 SetExternalAsPrimary();
402 401
403 // Mirror displays. 402 // Mirror displays.
404 MirrorDisplays(); 403 MirrorDisplays();
405 404
406 // Check if the internal display is set as the primary one. 405 // Check if the internal display is set as the primary one.
407 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); 406 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
408 CheckInternalDisplay(); 407 CheckInternalDisplay();
409 408
410 // Unmirror displays. 409 // Unmirror displays.
411 UnmirrorDisplays(); 410 UnmirrorDisplays();
412 411
413 // Check if the external display is added back as the primary display and 412 // Check if the external display is added back as the primary display and
414 // touch HUDs are set correctly. 413 // touch HUDs are set correctly.
415 EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id()); 414 EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id());
416 EXPECT_EQ(internal_display_id(), GetSecondaryDisplay().id()); 415 EXPECT_EQ(internal_display_id(),
416 display_manager()->GetSecondaryDisplay().id());
417 CheckInternalDisplay(); 417 CheckInternalDisplay();
418 CheckExternalDisplay(); 418 CheckExternalDisplay();
419 } 419 }
420 420
421 // Checks if debug touch HUDs are correctly handled when the external display, 421 // Checks if debug touch HUDs are correctly handled when the external display,
422 // which is the secondary one, is removed. 422 // which is the secondary one, is removed.
423 TEST_F(TouchHudDebugTest, RemoveSecondaryDisplay) { 423 TEST_F(TouchHudDebugTest, RemoveSecondaryDisplay) {
424 if (!SupportsMultipleDisplays()) 424 if (!SupportsMultipleDisplays())
425 return; 425 return;
426 426
427 // Setup a dual display setting. 427 // Setup a dual display setting.
428 SetupDualDisplays(); 428 SetupDualDisplays();
429 429
430 // Remove external display which is the secondary one. 430 // Remove external display which is the secondary one.
431 RemoveExternalDisplay(); 431 RemoveExternalDisplay();
432 432
433 // Check if the internal display is intact. 433 // Check if the internal display is intact.
434 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); 434 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
435 CheckInternalDisplay(); 435 CheckInternalDisplay();
436 436
437 // Add external display back. 437 // Add external display back.
438 AddExternalDisplay(); 438 AddExternalDisplay();
439 439
440 // Check if displays' touch HUDs are set correctly. 440 // Check if displays' touch HUDs are set correctly.
441 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); 441 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
442 EXPECT_EQ(external_display_id(), GetSecondaryDisplay().id()); 442 EXPECT_EQ(external_display_id(),
443 display_manager()->GetSecondaryDisplay().id());
443 CheckInternalDisplay(); 444 CheckInternalDisplay();
444 CheckExternalDisplay(); 445 CheckExternalDisplay();
445 } 446 }
446 447
447 // Checks if debug touch HUDs are correctly handled when the external display, 448 // Checks if debug touch HUDs are correctly handled when the external display,
448 // which is set as the primary display, is removed. 449 // which is set as the primary display, is removed.
449 TEST_F(TouchHudDebugTest, RemovePrimaryDisplay) { 450 TEST_F(TouchHudDebugTest, RemovePrimaryDisplay) {
450 if (!SupportsMultipleDisplays()) 451 if (!SupportsMultipleDisplays())
451 return; 452 return;
452 453
453 // Setup a dual display setting. 454 // Setup a dual display setting.
454 SetupDualDisplays(); 455 SetupDualDisplays();
455 456
456 // Set the primary display to the external one. 457 // Set the primary display to the external one.
457 SetExternalAsPrimary(); 458 SetExternalAsPrimary();
458 459
459 // Remove the external display which is the primary display. 460 // Remove the external display which is the primary display.
460 RemoveExternalDisplay(); 461 RemoveExternalDisplay();
461 462
462 // Check if the internal display is set as the primary one. 463 // Check if the internal display is set as the primary one.
463 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id()); 464 EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
464 CheckInternalDisplay(); 465 CheckInternalDisplay();
465 466
466 // Add the external display back. 467 // Add the external display back.
467 AddExternalDisplay(); 468 AddExternalDisplay();
468 469
469 // Check if the external display is set as primary and touch HUDs are set 470 // Check if the external display is set as primary and touch HUDs are set
470 // correctly. 471 // correctly.
471 EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id()); 472 EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id());
472 EXPECT_EQ(internal_display_id(), GetSecondaryDisplay().id()); 473 EXPECT_EQ(internal_display_id(),
474 display_manager()->GetSecondaryDisplay().id());
473 CheckInternalDisplay(); 475 CheckInternalDisplay();
474 CheckExternalDisplay(); 476 CheckExternalDisplay();
475 } 477 }
476 478
477 // Checks if debug touch HUDs are correctly handled when all displays are 479 // Checks if debug touch HUDs are correctly handled when all displays are
478 // removed. 480 // removed.
479 TEST_F(TouchHudDebugTest, Headless) { 481 TEST_F(TouchHudDebugTest, Headless) {
480 if (!SupportsMultipleDisplays()) 482 if (!SupportsMultipleDisplays())
481 return; 483 return;
482 484
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 617
616 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1); 618 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
617 EXPECT_EQ(1, GetInternalTouchPointsCount()); 619 EXPECT_EQ(1, GetInternalTouchPointsCount());
618 620
619 // Disabling projection touch HUD shoud remove it without crashing. 621 // Disabling projection touch HUD shoud remove it without crashing.
620 DisableTouchHudProjection(); 622 DisableTouchHudProjection();
621 EXPECT_EQ(NULL, GetInternalTouchHudProjection()); 623 EXPECT_EQ(NULL, GetInternalTouchHudProjection());
622 } 624 }
623 625
624 } // namespace ash 626 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/display_manager_test_api.cc ('k') | ash/touch/touchscreen_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698