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/root_window_transformers.h" | 5 #include "ash/display/root_window_transformers.h" |
6 | 6 |
7 #include "ash/display/display_info.h" | 7 #include "ash/display/display_info.h" |
8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
9 #include "ash/host/root_window_transformer.h" | 9 #include "ash/host/root_window_transformer.h" |
10 #include "ash/magnifier/magnification_controller.h" | 10 #include "ash/magnifier/magnification_controller.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 float touch_radius_x_; | 100 float touch_radius_x_; |
101 float touch_radius_y_; | 101 float touch_radius_y_; |
102 float scroll_x_offset_; | 102 float scroll_x_offset_; |
103 float scroll_y_offset_; | 103 float scroll_y_offset_; |
104 float scroll_x_offset_ordinal_; | 104 float scroll_x_offset_ordinal_; |
105 float scroll_y_offset_ordinal_; | 105 float scroll_y_offset_ordinal_; |
106 | 106 |
107 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); | 107 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); |
108 }; | 108 }; |
109 | 109 |
110 gfx::Display::Rotation GetStoredRotation(int64 id) { | |
111 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).rotation(); | |
112 } | |
113 | |
114 float GetStoredUIScale(int64 id) { | 110 float GetStoredUIScale(int64 id) { |
115 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). | 111 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). |
116 GetEffectiveUIScale(); | 112 GetEffectiveUIScale(); |
117 } | 113 } |
118 | 114 |
119 } // namespace | 115 } // namespace |
120 | 116 |
121 typedef test::AshTestBase RootWindowTransformersTest; | 117 typedef test::AshTestBase RootWindowTransformersTest; |
122 | 118 |
123 #if defined(OS_WIN) | 119 #if defined(OS_WIN) |
(...skipping 27 matching lines...) Expand all Loading... |
151 magnifier->SetEnabled(true); | 147 magnifier->SetEnabled(true); |
152 EXPECT_EQ(2.0f, magnifier->GetScale()); | 148 EXPECT_EQ(2.0f, magnifier->GetScale()); |
153 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 149 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
154 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 150 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
155 EXPECT_EQ("120,0 150x200", | 151 EXPECT_EQ("120,0 150x200", |
156 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 152 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
157 generator1.MoveMouseToInHost(40, 80); | 153 generator1.MoveMouseToInHost(40, 80); |
158 EXPECT_EQ("50,90", event_handler.GetLocationAndReset()); | 154 EXPECT_EQ("50,90", event_handler.GetLocationAndReset()); |
159 EXPECT_EQ("50,90", | 155 EXPECT_EQ("50,90", |
160 aura::Env::GetInstance()->last_mouse_location().ToString()); | 156 aura::Env::GetInstance()->last_mouse_location().ToString()); |
161 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); | 157 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display1.id())); |
162 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); | 158 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); |
163 magnifier->SetEnabled(false); | 159 magnifier->SetEnabled(false); |
164 | 160 |
165 display_manager->SetDisplayRotation(display1.id(), | 161 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_90, |
166 gfx::Display::ROTATE_90); | 162 gfx::Display::ROTATION_SOURCE_ACTIVE); |
167 // Move the cursor to the center of the first root window. | 163 // Move the cursor to the center of the first root window. |
168 generator1.MoveMouseToInHost(59, 100); | 164 generator1.MoveMouseToInHost(59, 100); |
169 | 165 |
170 magnifier->SetEnabled(true); | 166 magnifier->SetEnabled(true); |
171 EXPECT_EQ(2.0f, magnifier->GetScale()); | 167 EXPECT_EQ(2.0f, magnifier->GetScale()); |
172 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 168 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
173 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 169 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
174 EXPECT_EQ("200,0 150x200", | 170 EXPECT_EQ("200,0 150x200", |
175 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 171 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
176 generator1.MoveMouseToInHost(39, 120); | 172 generator1.MoveMouseToInHost(39, 120); |
177 EXPECT_EQ("110,70", event_handler.GetLocationAndReset()); | 173 EXPECT_EQ("110,70", event_handler.GetLocationAndReset()); |
178 EXPECT_EQ("110,70", | 174 EXPECT_EQ("110,70", |
179 aura::Env::GetInstance()->last_mouse_location().ToString()); | 175 aura::Env::GetInstance()->last_mouse_location().ToString()); |
180 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); | 176 EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); |
181 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); | 177 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); |
182 magnifier->SetEnabled(false); | 178 magnifier->SetEnabled(false); |
183 | 179 |
184 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); | 180 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); |
185 display_manager->SetLayoutForCurrentDisplays(display_layout); | 181 display_manager->SetLayoutForCurrentDisplays(display_layout); |
186 EXPECT_EQ("50,120 150x200", | 182 EXPECT_EQ("50,120 150x200", |
187 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 183 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
188 | 184 |
189 display_manager->SetDisplayRotation(display2_id, | 185 display_manager->SetDisplayRotation(display2_id, gfx::Display::ROTATE_270, |
190 gfx::Display::ROTATE_270); | 186 gfx::Display::ROTATION_SOURCE_ACTIVE); |
191 // Move the cursor to the center of the second root window. | 187 // Move the cursor to the center of the second root window. |
192 generator2.MoveMouseToInHost(151, 199); | 188 generator2.MoveMouseToInHost(151, 199); |
193 | 189 |
194 magnifier->SetEnabled(true); | 190 magnifier->SetEnabled(true); |
195 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 191 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
196 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 192 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
197 EXPECT_EQ("50,120 200x150", | 193 EXPECT_EQ("50,120 200x150", |
198 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 194 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
199 generator2.MoveMouseToInHost(172, 219); | 195 generator2.MoveMouseToInHost(172, 219); |
200 EXPECT_EQ("95,80", event_handler.GetLocationAndReset()); | 196 EXPECT_EQ("95,80", event_handler.GetLocationAndReset()); |
201 EXPECT_EQ("145,200", | 197 EXPECT_EQ("145,200", |
202 aura::Env::GetInstance()->last_mouse_location().ToString()); | 198 aura::Env::GetInstance()->last_mouse_location().ToString()); |
203 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); | 199 EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); |
204 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); | 200 EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); |
205 magnifier->SetEnabled(false); | 201 magnifier->SetEnabled(false); |
206 | 202 |
207 display_manager->SetDisplayRotation(display1.id(), | 203 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_180, |
208 gfx::Display::ROTATE_180); | 204 gfx::Display::ROTATION_SOURCE_ACTIVE); |
209 // Move the cursor to the center of the first root window. | 205 // Move the cursor to the center of the first root window. |
210 generator1.MoveMouseToInHost(59, 99); | 206 generator1.MoveMouseToInHost(59, 99); |
211 | 207 |
212 magnifier->SetEnabled(true); | 208 magnifier->SetEnabled(true); |
213 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 209 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
214 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 210 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
215 // Dislay must share at least 100, so the x's offset becomes 20. | 211 // Dislay must share at least 100, so the x's offset becomes 20. |
216 EXPECT_EQ("20,200 200x150", | 212 EXPECT_EQ("20,200 200x150", |
217 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 213 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
218 generator1.MoveMouseToInHost(39, 59); | 214 generator1.MoveMouseToInHost(39, 59); |
219 EXPECT_EQ("70,120", event_handler.GetLocationAndReset()); | 215 EXPECT_EQ("70,120", event_handler.GetLocationAndReset()); |
220 EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id())); | 216 EXPECT_EQ(gfx::Display::ROTATE_180, GetActiveDisplayRotation(display1.id())); |
221 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); | 217 EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); |
222 magnifier->SetEnabled(false); | 218 magnifier->SetEnabled(false); |
223 | 219 |
224 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 220 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
225 } | 221 } |
226 | 222 |
227 TEST_F(RootWindowTransformersTest, ScaleAndMagnify) { | 223 TEST_F(RootWindowTransformersTest, ScaleAndMagnify) { |
228 if (!SupportsMultipleDisplays()) | 224 if (!SupportsMultipleDisplays()) |
229 return; | 225 return; |
230 | 226 |
231 TestEventHandler event_handler; | 227 TestEventHandler event_handler; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. | 400 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. |
405 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); | 401 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); |
406 | 402 |
407 UpdateDisplay("200x400,500x500"); | 403 UpdateDisplay("200x400,500x500"); |
408 // The aspect ratio is flipped, so X margin is now 125. | 404 // The aspect ratio is flipped, so X margin is now 125. |
409 transformer = test_api.CreateCurrentRootWindowTransformer(); | 405 transformer = test_api.CreateCurrentRootWindowTransformer(); |
410 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); | 406 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); |
411 } | 407 } |
412 | 408 |
413 } // namespace ash | 409 } // namespace ash |
OLD | NEW |