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/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
8 #include "ash/display/display_manager.h" | |
9 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
10 #include "ash/shell.h" | 9 #include "ash/shell.h" |
11 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
12 #include "ash/test/display_manager_test_api.h" | |
13 #include "ash/touch/touch_hud_debug.h" | 11 #include "ash/touch/touch_hud_debug.h" |
14 #include "ash/touch/touch_hud_projection.h" | 12 #include "ash/touch/touch_hud_projection.h" |
15 #include "ash/touch_hud/touch_hud_renderer.h" | 13 #include "ash/touch_hud/touch_hud_renderer.h" |
16 #include "base/command_line.h" | 14 #include "base/command_line.h" |
17 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
18 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
19 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 18 #include "ui/display/manager/display_manager.h" |
| 19 #include "ui/display/test/display_manager_test_api.h" |
20 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
21 | 21 |
22 namespace ash { | 22 namespace ash { |
23 | 23 |
24 class TouchHudTestBase : public test::AshTestBase { | 24 class TouchHudTestBase : public test::AshTestBase { |
25 public: | 25 public: |
26 TouchHudTestBase() {} | 26 TouchHudTestBase() {} |
27 ~TouchHudTestBase() override {} | 27 ~TouchHudTestBase() override {} |
28 | 28 |
29 void SetUp() override { | 29 void SetUp() override { |
30 test::AshTestBase::SetUp(); | 30 test::AshTestBase::SetUp(); |
31 | 31 |
32 // Initialize display infos. They should be initialized after Ash | 32 // Initialize display infos. They should be initialized after Ash |
33 // environment is set up, i.e., after test::AshTestBase::SetUp(). | 33 // environment is set up, i.e., after test::AshTestBase::SetUp(). |
34 internal_display_id_ = | 34 internal_display_id_ = display::test::DisplayManagerTestApi( |
35 test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) | 35 Shell::GetInstance()->display_manager()) |
36 .SetFirstDisplayAsInternalDisplay(); | 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 void SetupSingleDisplay() { | 52 void SetupSingleDisplay() { |
53 display_info_list_.clear(); | 53 display_info_list_.clear(); |
54 display_info_list_.push_back(internal_display_info_); | 54 display_info_list_.push_back(internal_display_info_); |
55 GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_); | 55 display_manager()->OnNativeDisplaysChanged(display_info_list_); |
56 } | 56 } |
57 | 57 |
58 void SetupDualDisplays() { | 58 void SetupDualDisplays() { |
59 display_info_list_.clear(); | 59 display_info_list_.clear(); |
60 display_info_list_.push_back(internal_display_info_); | 60 display_info_list_.push_back(internal_display_info_); |
61 display_info_list_.push_back(external_display_info_); | 61 display_info_list_.push_back(external_display_info_); |
62 GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_); | 62 display_manager()->OnNativeDisplaysChanged(display_info_list_); |
63 } | 63 } |
64 | 64 |
65 void SetInternalAsPrimary() { | 65 void SetInternalAsPrimary() { |
66 GetWindowTreeHostManager()->SetPrimaryDisplayId(internal_display_id_); | 66 GetWindowTreeHostManager()->SetPrimaryDisplayId(internal_display_id_); |
67 } | 67 } |
68 | 68 |
69 void SetExternalAsPrimary() { | 69 void SetExternalAsPrimary() { |
70 GetWindowTreeHostManager()->SetPrimaryDisplayId(external_display_id_); | 70 GetWindowTreeHostManager()->SetPrimaryDisplayId(external_display_id_); |
71 } | 71 } |
72 | 72 |
73 void MirrorDisplays() { | 73 void MirrorDisplays() { |
74 DCHECK_EQ(2U, display_info_list_.size()); | 74 DCHECK_EQ(2U, display_info_list_.size()); |
75 DCHECK_EQ(internal_display_id_, display_info_list_[0].id()); | 75 DCHECK_EQ(internal_display_id_, display_info_list_[0].id()); |
76 DCHECK_EQ(external_display_id_, display_info_list_[1].id()); | 76 DCHECK_EQ(external_display_id_, display_info_list_[1].id()); |
77 display_info_list_[1] = mirrored_display_info_; | 77 display_info_list_[1] = mirrored_display_info_; |
78 GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_); | 78 display_manager()->OnNativeDisplaysChanged(display_info_list_); |
79 } | 79 } |
80 | 80 |
81 void UnmirrorDisplays() { | 81 void UnmirrorDisplays() { |
82 DCHECK_EQ(2U, display_info_list_.size()); | 82 DCHECK_EQ(2U, display_info_list_.size()); |
83 DCHECK_EQ(internal_display_id_, display_info_list_[0].id()); | 83 DCHECK_EQ(internal_display_id_, display_info_list_[0].id()); |
84 DCHECK_EQ(mirrored_display_id_, display_info_list_[1].id()); | 84 DCHECK_EQ(mirrored_display_id_, display_info_list_[1].id()); |
85 display_info_list_[1] = external_display_info_; | 85 display_info_list_[1] = external_display_info_; |
86 GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_); | 86 display_manager()->OnNativeDisplaysChanged(display_info_list_); |
87 } | 87 } |
88 | 88 |
89 void RemoveInternalDisplay() { | 89 void RemoveInternalDisplay() { |
90 DCHECK_LT(0U, display_info_list_.size()); | 90 DCHECK_LT(0U, display_info_list_.size()); |
91 DCHECK_EQ(internal_display_id_, display_info_list_[0].id()); | 91 DCHECK_EQ(internal_display_id_, display_info_list_[0].id()); |
92 display_info_list_.erase(display_info_list_.begin()); | 92 display_info_list_.erase(display_info_list_.begin()); |
93 GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_); | 93 display_manager()->OnNativeDisplaysChanged(display_info_list_); |
94 } | 94 } |
95 | 95 |
96 void RemoveExternalDisplay() { | 96 void RemoveExternalDisplay() { |
97 DCHECK_EQ(2U, display_info_list_.size()); | 97 DCHECK_EQ(2U, display_info_list_.size()); |
98 display_info_list_.pop_back(); | 98 display_info_list_.pop_back(); |
99 GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_); | 99 display_manager()->OnNativeDisplaysChanged(display_info_list_); |
100 } | 100 } |
101 | 101 |
102 void AddInternalDisplay() { | 102 void AddInternalDisplay() { |
103 DCHECK_EQ(0U, display_info_list_.size()); | 103 DCHECK_EQ(0U, display_info_list_.size()); |
104 display_info_list_.push_back(internal_display_info_); | 104 display_info_list_.push_back(internal_display_info_); |
105 GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_); | 105 display_manager()->OnNativeDisplaysChanged(display_info_list_); |
106 } | 106 } |
107 | 107 |
108 void AddExternalDisplay() { | 108 void AddExternalDisplay() { |
109 DCHECK_EQ(1U, display_info_list_.size()); | 109 DCHECK_EQ(1U, display_info_list_.size()); |
110 display_info_list_.push_back(external_display_info_); | 110 display_info_list_.push_back(external_display_info_); |
111 GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_); | 111 display_manager()->OnNativeDisplaysChanged(display_info_list_); |
112 } | 112 } |
113 | 113 |
114 int64_t internal_display_id() const { return internal_display_id_; } | 114 int64_t internal_display_id() const { return internal_display_id_; } |
115 | 115 |
116 int64_t external_display_id() const { return external_display_id_; } | 116 int64_t external_display_id() const { return external_display_id_; } |
117 | 117 |
118 protected: | 118 protected: |
119 DisplayManager* GetDisplayManager() { | |
120 return Shell::GetInstance()->display_manager(); | |
121 } | |
122 | 119 |
123 WindowTreeHostManager* GetWindowTreeHostManager() { | 120 WindowTreeHostManager* GetWindowTreeHostManager() { |
124 return Shell::GetInstance()->window_tree_host_manager(); | 121 return Shell::GetInstance()->window_tree_host_manager(); |
125 } | 122 } |
126 | 123 |
127 const display::Display& GetInternalDisplay() { | 124 const display::Display& GetInternalDisplay() { |
128 return GetDisplayManager()->GetDisplayForId(internal_display_id_); | 125 return display_manager()->GetDisplayForId(internal_display_id_); |
129 } | 126 } |
130 | 127 |
131 const display::Display& GetExternalDisplay() { | 128 const display::Display& GetExternalDisplay() { |
132 return GetDisplayManager()->GetDisplayForId(external_display_id_); | 129 return display_manager()->GetDisplayForId(external_display_id_); |
133 } | 130 } |
134 | 131 |
135 aura::Window* GetInternalRootWindow() { | 132 aura::Window* GetInternalRootWindow() { |
136 return GetWindowTreeHostManager()->GetRootWindowForDisplayId( | 133 return GetWindowTreeHostManager()->GetRootWindowForDisplayId( |
137 internal_display_id_); | 134 internal_display_id_); |
138 } | 135 } |
139 | 136 |
140 aura::Window* GetExternalRootWindow() { | 137 aura::Window* GetExternalRootWindow() { |
141 return GetWindowTreeHostManager()->GetRootWindowForDisplayId( | 138 return GetWindowTreeHostManager()->GetRootWindowForDisplayId( |
142 external_display_id_); | 139 external_display_id_); |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 | 614 |
618 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1); | 615 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1); |
619 EXPECT_EQ(1, GetInternalTouchPointsCount()); | 616 EXPECT_EQ(1, GetInternalTouchPointsCount()); |
620 | 617 |
621 // Disabling projection touch HUD shoud remove it without crashing. | 618 // Disabling projection touch HUD shoud remove it without crashing. |
622 DisableTouchHudProjection(); | 619 DisableTouchHudProjection(); |
623 EXPECT_EQ(NULL, GetInternalTouchHudProjection()); | 620 EXPECT_EQ(NULL, GetInternalTouchHudProjection()); |
624 } | 621 } |
625 | 622 |
626 } // namespace ash | 623 } // namespace ash |
OLD | NEW |