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/display/display_controller.h" | 5 #include "ash/display/display_controller.h" |
6 #include "ash/magnifier/magnification_controller.h" | 6 #include "ash/magnifier/magnification_controller.h" |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
11 #include "ui/aura/env.h" | |
11 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
13 #include "ui/aura/test/event_generator.h" | |
12 #include "ui/gfx/rect_conversions.h" | 14 #include "ui/gfx/rect_conversions.h" |
13 #include "ui/gfx/screen.h" | 15 #include "ui/gfx/screen.h" |
14 | 16 |
15 namespace ash { | 17 namespace ash { |
16 namespace internal { | 18 namespace internal { |
17 namespace { | 19 namespace { |
18 | 20 |
19 const int kRootHeight = 600; | 21 const int kRootHeight = 600; |
20 const int kRootWidth = 800; | 22 const int kRootWidth = 800; |
21 | 23 |
24 const float kMagnificationFactor = 1.18920712f; | |
oshima
2013/04/24 20:36:04
The significand of a floating value only has 7 dig
yoshiki
2013/04/24 23:30:23
This was the same value used in magnifier. I move
| |
25 | |
22 } // namespace | 26 } // namespace |
23 | 27 |
24 class MagnificationControllerTest: public test::AshTestBase { | 28 class MagnificationControllerTest: public test::AshTestBase { |
25 public: | 29 public: |
26 MagnificationControllerTest() {} | 30 MagnificationControllerTest() {} |
27 virtual ~MagnificationControllerTest() {} | 31 virtual ~MagnificationControllerTest() {} |
28 | 32 |
29 virtual void SetUp() OVERRIDE { | 33 virtual void SetUp() OVERRIDE { |
30 AshTestBase::SetUp(); | 34 AshTestBase::SetUp(); |
31 UpdateDisplay(base::StringPrintf("%dx%d", kRootWidth, kRootHeight)); | 35 UpdateDisplay(base::StringPrintf("%dx%d", kRootWidth, kRootHeight)); |
32 | 36 |
33 aura::RootWindow* root = GetRootWindow(); | 37 aura::RootWindow* root = GetRootWindow(); |
34 gfx::Rect root_bounds(root->bounds()); | 38 gfx::Rect root_bounds(root->bounds()); |
35 | 39 |
36 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
37 // RootWindow and Display can't resize on Windows Ash. | 41 // RootWindow and Display can't resize on Windows Ash. |
38 // http://crbug.com/165962 | 42 // http://crbug.com/165962 |
39 EXPECT_EQ(kRootHeight, root_bounds.height()); | 43 EXPECT_EQ(kRootHeight, root_bounds.height()); |
40 EXPECT_EQ(kRootWidth, root_bounds.width()); | 44 EXPECT_EQ(kRootWidth, root_bounds.width()); |
41 #endif | 45 #endif |
42 } | 46 } |
43 | 47 |
44 virtual void TearDown() OVERRIDE { | 48 virtual void TearDown() OVERRIDE { |
45 AshTestBase::TearDown(); | 49 AshTestBase::TearDown(); |
46 } | 50 } |
47 | 51 |
48 protected: | 52 protected: |
49 aura::RootWindow* GetRootWindow() { | 53 aura::RootWindow* GetRootWindow() { |
oshima
2013/04/24 20:36:04
can this (and other accessors) be constlike
const
yoshiki
2013/04/24 23:30:23
Done.
| |
50 return Shell::GetPrimaryRootWindow(); | 54 return Shell::GetPrimaryRootWindow(); |
51 } | 55 } |
52 | 56 |
57 | |
58 void MoveCursorWithEvent(gfx::Point point) { | |
oshima
2013/04/24 20:36:04
const gfx::Point& point
yoshiki
2013/04/24 23:30:23
Done.
| |
59 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | |
60 generator.MoveMouseTo(point.x(), point.y()); | |
61 } | |
62 | |
63 std::string GetHostMouseLocation() { | |
64 gfx::Point point; | |
65 GetRootWindow()->QueryMouseLocationForTest(&point); | |
66 return point.ToString(); | |
67 } | |
68 | |
53 ash::MagnificationController* GetMagnificationController() { | 69 ash::MagnificationController* GetMagnificationController() { |
54 return ash::Shell::GetInstance()->magnification_controller(); | 70 return ash::Shell::GetInstance()->magnification_controller(); |
55 } | 71 } |
56 | 72 |
57 gfx::Rect GetViewport() { | 73 gfx::Rect GetViewport() { |
58 gfx::RectF bounds(0, 0, kRootWidth, kRootHeight); | 74 gfx::RectF bounds(0, 0, kRootWidth, kRootHeight); |
59 GetRootWindow()->layer()->transform().TransformRectReverse(&bounds); | 75 GetRootWindow()->layer()->transform().TransformRectReverse(&bounds); |
60 return gfx::ToEnclosingRect(bounds); | 76 return gfx::ToEnclosingRect(bounds); |
61 } | 77 } |
62 | 78 |
79 std::string CurrentPointOfInterest() { | |
80 return GetMagnificationController()-> | |
81 GetPointOfInterestForTesting().ToString(); | |
82 } | |
83 | |
63 private: | 84 private: |
64 DISALLOW_COPY_AND_ASSIGN(MagnificationControllerTest); | 85 DISALLOW_COPY_AND_ASSIGN(MagnificationControllerTest); |
65 }; | 86 }; |
66 | 87 |
67 TEST_F(MagnificationControllerTest, EnableAndDisable) { | 88 TEST_F(MagnificationControllerTest, EnableAndDisable) { |
68 // Confirms the magnifier is disabled. | 89 // Confirms the magnifier is disabled. |
69 EXPECT_TRUE(GetRootWindow()->layer()->transform().IsIdentity()); | 90 EXPECT_TRUE(GetRootWindow()->layer()->transform().IsIdentity()); |
70 EXPECT_EQ(1.0f, GetMagnificationController()->GetScale()); | 91 EXPECT_EQ(1.0f, GetMagnificationController()->GetScale()); |
71 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); | 92 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); |
72 | 93 |
(...skipping 15 matching lines...) Expand all Loading... | |
88 EXPECT_EQ(1.0f, GetMagnificationController()->GetScale()); | 109 EXPECT_EQ(1.0f, GetMagnificationController()->GetScale()); |
89 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); | 110 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); |
90 } | 111 } |
91 | 112 |
92 TEST_F(MagnificationControllerTest, MagnifyAndUnmagnify) { | 113 TEST_F(MagnificationControllerTest, MagnifyAndUnmagnify) { |
93 // Enables magnifier and confirms the default scale is 2.0x. | 114 // Enables magnifier and confirms the default scale is 2.0x. |
94 GetMagnificationController()->SetEnabled(true); | 115 GetMagnificationController()->SetEnabled(true); |
95 EXPECT_FALSE(GetRootWindow()->layer()->transform().IsIdentity()); | 116 EXPECT_FALSE(GetRootWindow()->layer()->transform().IsIdentity()); |
96 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale()); | 117 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale()); |
97 EXPECT_EQ("200,150 400x300", GetViewport().ToString()); | 118 EXPECT_EQ("200,150 400x300", GetViewport().ToString()); |
119 EXPECT_EQ("400,300", CurrentPointOfInterest()); | |
98 | 120 |
99 // Changes the scale. | 121 // Changes the scale. |
100 GetMagnificationController()->SetScale(4.0f, false); | 122 GetMagnificationController()->SetScale(4.0f, false); |
101 EXPECT_EQ(4.0f, GetMagnificationController()->GetScale()); | 123 EXPECT_EQ(4.0f, GetMagnificationController()->GetScale()); |
102 EXPECT_EQ("300,225 200x150", GetViewport().ToString()); | 124 EXPECT_EQ("300,225 200x150", GetViewport().ToString()); |
125 EXPECT_EQ("400,300", CurrentPointOfInterest()); | |
103 | 126 |
104 GetMagnificationController()->SetScale(1.0f, false); | 127 GetMagnificationController()->SetScale(1.0f, false); |
105 EXPECT_EQ(1.0f, GetMagnificationController()->GetScale()); | 128 EXPECT_EQ(1.0f, GetMagnificationController()->GetScale()); |
106 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); | 129 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); |
130 EXPECT_EQ("400,300", CurrentPointOfInterest()); | |
107 | 131 |
108 GetMagnificationController()->SetScale(3.0f, false); | 132 GetMagnificationController()->SetScale(3.0f, false); |
109 EXPECT_EQ(3.0f, GetMagnificationController()->GetScale()); | 133 EXPECT_EQ(3.0f, GetMagnificationController()->GetScale()); |
110 EXPECT_EQ("266,200 268x200", GetViewport().ToString()); | 134 EXPECT_EQ("266,200 268x200", GetViewport().ToString()); |
135 EXPECT_EQ("400,300", CurrentPointOfInterest()); | |
111 } | 136 } |
112 | 137 |
113 TEST_F(MagnificationControllerTest, MoveWindow) { | 138 TEST_F(MagnificationControllerTest, MoveWindow) { |
114 // Enables magnifier and confirm the viewport is at center. | 139 // Enables magnifier and confirm the viewport is at center. |
115 GetMagnificationController()->SetEnabled(true); | 140 GetMagnificationController()->SetEnabled(true); |
116 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale()); | 141 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale()); |
117 EXPECT_EQ("200,150 400x300", GetViewport().ToString()); | 142 EXPECT_EQ("200,150 400x300", GetViewport().ToString()); |
118 | 143 |
119 // Move the viewport. | 144 // Move the viewport. |
120 GetMagnificationController()->MoveWindow(0, 0, false); | 145 GetMagnificationController()->MoveWindow(0, 0, false); |
(...skipping 25 matching lines...) Expand all Loading... | |
146 GetMagnificationController()->MoveWindow(0, 400, false); | 171 GetMagnificationController()->MoveWindow(0, 400, false); |
147 EXPECT_EQ("0,300 400x300", GetViewport().ToString()); | 172 EXPECT_EQ("0,300 400x300", GetViewport().ToString()); |
148 | 173 |
149 GetMagnificationController()->MoveWindow(200, 400, false); | 174 GetMagnificationController()->MoveWindow(200, 400, false); |
150 EXPECT_EQ("200,300 400x300", GetViewport().ToString()); | 175 EXPECT_EQ("200,300 400x300", GetViewport().ToString()); |
151 | 176 |
152 GetMagnificationController()->MoveWindow(1000, 1000, false); | 177 GetMagnificationController()->MoveWindow(1000, 1000, false); |
153 EXPECT_EQ("400,300 400x300", GetViewport().ToString()); | 178 EXPECT_EQ("400,300 400x300", GetViewport().ToString()); |
154 } | 179 } |
155 | 180 |
181 TEST_F(MagnificationControllerTest, PointOfInterest) { | |
182 MoveCursorWithEvent(gfx::Point(0, 0)); | |
183 EXPECT_EQ("0,0", CurrentPointOfInterest()); | |
184 | |
185 MoveCursorWithEvent(gfx::Point(799, 599)); | |
186 EXPECT_EQ("799,599", CurrentPointOfInterest()); | |
187 | |
188 MoveCursorWithEvent(gfx::Point(400, 300)); | |
189 EXPECT_EQ("400,300", CurrentPointOfInterest()); | |
190 | |
191 GetMagnificationController()->SetEnabled(true); | |
192 EXPECT_EQ("400,300", CurrentPointOfInterest()); | |
193 | |
194 MoveCursorWithEvent(gfx::Point(500, 400)); | |
195 EXPECT_EQ("450,350", CurrentPointOfInterest()); | |
196 } | |
197 | |
198 TEST_F(MagnificationControllerTest, PanWindow2xLeftToRight) { | |
199 aura::Env* env = aura::Env::GetInstance(); | |
oshima
2013/04/24 20:36:04
const
same for other places
yoshiki
2013/04/24 23:30:23
Done.
| |
200 | |
201 MoveCursorWithEvent(gfx::Point(0, 0)); | |
202 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); | |
203 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); | |
204 EXPECT_EQ("0,0", env->last_mouse_location().ToString()); | |
205 | |
206 // Enables magnifier and confirm the viewport is at center. | |
207 GetMagnificationController()->SetEnabled(true); | |
208 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale()); | |
209 | |
210 GetMagnificationController()->MoveWindow(0, 0, false); | |
211 MoveCursorWithEvent(gfx::Point(0, 0)); | |
212 EXPECT_EQ("0,0", env->last_mouse_location().ToString()); | |
213 EXPECT_EQ("0,0 400x300", GetViewport().ToString()); | |
214 | |
215 MoveCursorWithEvent(gfx::Point(300, 150)); | |
216 EXPECT_EQ("150,75", env->last_mouse_location().ToString()); | |
217 EXPECT_EQ("0,0 400x300", GetViewport().ToString()); | |
218 | |
219 MoveCursorWithEvent(gfx::Point(700, 150)); | |
220 EXPECT_EQ("350,75", env->last_mouse_location().ToString()); | |
221 EXPECT_EQ("0,0 400x300", GetViewport().ToString()); | |
222 | |
223 MoveCursorWithEvent(gfx::Point(701, 150)); | |
224 EXPECT_EQ("350,75", env->last_mouse_location().ToString()); | |
225 EXPECT_EQ("0,0 400x300", GetViewport().ToString()); | |
226 | |
227 MoveCursorWithEvent(gfx::Point(702, 150)); | |
228 EXPECT_EQ("351,75", env->last_mouse_location().ToString()); | |
229 EXPECT_EQ("1,0 400x300", GetViewport().ToString()); | |
230 | |
231 MoveCursorWithEvent(gfx::Point(703, 150)); | |
232 EXPECT_EQ("352,75", env->last_mouse_location().ToString()); | |
233 EXPECT_EQ("2,0 400x300", GetViewport().ToString()); | |
234 | |
235 MoveCursorWithEvent(gfx::Point(704, 150)); | |
236 EXPECT_EQ("354,75", env->last_mouse_location().ToString()); | |
237 EXPECT_EQ("4,0 400x300", GetViewport().ToString()); | |
238 | |
239 MoveCursorWithEvent(gfx::Point(712, 150)); | |
240 EXPECT_EQ("360,75", env->last_mouse_location().ToString()); | |
241 EXPECT_EQ("10,0 400x300", GetViewport().ToString()); | |
242 | |
243 MoveCursorWithEvent(gfx::Point(600, 150)); | |
244 EXPECT_EQ("310,75", env->last_mouse_location().ToString()); | |
245 EXPECT_EQ("10,0 400x300", GetViewport().ToString()); | |
246 | |
247 MoveCursorWithEvent(gfx::Point(720, 150)); | |
248 EXPECT_EQ("370,75", env->last_mouse_location().ToString()); | |
249 EXPECT_EQ("20,0 400x300", GetViewport().ToString()); | |
250 | |
251 MoveCursorWithEvent(gfx::Point(780, 150)); | |
252 EXPECT_EQ("410,75", env->last_mouse_location().ToString()); | |
253 EXPECT_EQ("410,75", CurrentPointOfInterest()); | |
254 EXPECT_EQ("60,0 400x300", GetViewport().ToString()); | |
255 | |
256 MoveCursorWithEvent(gfx::Point(799, 150)); | |
257 EXPECT_EQ("459,75", env->last_mouse_location().ToString()); | |
258 EXPECT_EQ("109,0 400x300", GetViewport().ToString()); | |
259 | |
260 MoveCursorWithEvent(gfx::Point(702, 150)); | |
261 EXPECT_EQ("460,75", env->last_mouse_location().ToString()); | |
262 EXPECT_EQ("110,0 400x300", GetViewport().ToString()); | |
263 | |
264 MoveCursorWithEvent(gfx::Point(780, 150)); | |
265 EXPECT_EQ("500,75", env->last_mouse_location().ToString()); | |
266 EXPECT_EQ("150,0 400x300", GetViewport().ToString()); | |
267 | |
268 MoveCursorWithEvent(gfx::Point(780, 150)); | |
269 EXPECT_EQ("540,75", env->last_mouse_location().ToString()); | |
270 EXPECT_EQ("190,0 400x300", GetViewport().ToString()); | |
271 | |
272 MoveCursorWithEvent(gfx::Point(780, 150)); | |
273 EXPECT_EQ("580,75", env->last_mouse_location().ToString()); | |
274 EXPECT_EQ("230,0 400x300", GetViewport().ToString()); | |
275 | |
276 MoveCursorWithEvent(gfx::Point(780, 150)); | |
277 EXPECT_EQ("620,75", env->last_mouse_location().ToString()); | |
278 EXPECT_EQ("270,0 400x300", GetViewport().ToString()); | |
279 | |
280 MoveCursorWithEvent(gfx::Point(780, 150)); | |
281 EXPECT_EQ("660,75", env->last_mouse_location().ToString()); | |
282 EXPECT_EQ("310,0 400x300", GetViewport().ToString()); | |
283 | |
284 MoveCursorWithEvent(gfx::Point(780, 150)); | |
285 EXPECT_EQ("700,75", env->last_mouse_location().ToString()); | |
286 EXPECT_EQ("350,0 400x300", GetViewport().ToString()); | |
287 | |
288 MoveCursorWithEvent(gfx::Point(780, 150)); | |
289 EXPECT_EQ("740,75", env->last_mouse_location().ToString()); | |
290 EXPECT_EQ("390,0 400x300", GetViewport().ToString()); | |
291 | |
292 MoveCursorWithEvent(gfx::Point(780, 150)); | |
293 EXPECT_EQ("780,75", env->last_mouse_location().ToString()); | |
294 EXPECT_EQ("400,0 400x300", GetViewport().ToString()); | |
295 | |
296 MoveCursorWithEvent(gfx::Point(799, 150)); | |
297 EXPECT_EQ("799,75", env->last_mouse_location().ToString()); | |
298 EXPECT_EQ("400,0 400x300", GetViewport().ToString()); | |
299 } | |
300 | |
301 TEST_F(MagnificationControllerTest, PanWindow2xRightToLeft) { | |
302 aura::Env* env = aura::Env::GetInstance(); | |
303 | |
304 MoveCursorWithEvent(gfx::Point(799, 300)); | |
305 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); | |
306 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); | |
307 EXPECT_EQ("799,300", env->last_mouse_location().ToString()); | |
308 | |
309 // Enables magnifier and confirm the viewport is at center. | |
310 GetMagnificationController()->SetEnabled(true); | |
311 | |
312 MoveCursorWithEvent(gfx::Point(799, 300)); | |
313 EXPECT_EQ("798,300", env->last_mouse_location().ToString()); | |
314 EXPECT_EQ("400,150 400x300", GetViewport().ToString()); | |
315 | |
316 MoveCursorWithEvent(gfx::Point(0, 300)); | |
317 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | |
318 EXPECT_EQ("350,150 400x300", GetViewport().ToString()); | |
319 | |
320 MoveCursorWithEvent(gfx::Point(0, 300)); | |
321 EXPECT_EQ("350,300", env->last_mouse_location().ToString()); | |
322 EXPECT_EQ("300,150 400x300", GetViewport().ToString()); | |
323 | |
324 MoveCursorWithEvent(gfx::Point(0, 300)); | |
325 EXPECT_EQ("300,300", env->last_mouse_location().ToString()); | |
326 EXPECT_EQ("250,150 400x300", GetViewport().ToString()); | |
327 | |
328 MoveCursorWithEvent(gfx::Point(0, 300)); | |
329 EXPECT_EQ("250,300", env->last_mouse_location().ToString()); | |
330 EXPECT_EQ("200,150 400x300", GetViewport().ToString()); | |
331 | |
332 MoveCursorWithEvent(gfx::Point(0, 300)); | |
333 EXPECT_EQ("200,300", env->last_mouse_location().ToString()); | |
334 EXPECT_EQ("150,150 400x300", GetViewport().ToString()); | |
335 | |
336 MoveCursorWithEvent(gfx::Point(0, 300)); | |
337 EXPECT_EQ("150,300", env->last_mouse_location().ToString()); | |
338 EXPECT_EQ("100,150 400x300", GetViewport().ToString()); | |
339 | |
340 MoveCursorWithEvent(gfx::Point(0, 300)); | |
341 EXPECT_EQ("100,300", env->last_mouse_location().ToString()); | |
342 EXPECT_EQ("50,150 400x300", GetViewport().ToString()); | |
343 | |
344 MoveCursorWithEvent(gfx::Point(0, 300)); | |
345 EXPECT_EQ("50,300", env->last_mouse_location().ToString()); | |
346 EXPECT_EQ("0,150 400x300", GetViewport().ToString()); | |
347 | |
348 MoveCursorWithEvent(gfx::Point(0, 300)); | |
349 EXPECT_EQ("0,300", env->last_mouse_location().ToString()); | |
350 EXPECT_EQ("0,150 400x300", GetViewport().ToString()); | |
351 } | |
352 | |
353 TEST_F(MagnificationControllerTest, PanWindowToRight) { | |
354 aura::Env* env = aura::Env::GetInstance(); | |
355 | |
356 MoveCursorWithEvent(gfx::Point(400, 300)); | |
357 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); | |
358 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); | |
359 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | |
360 | |
361 float scale = 2.f; | |
362 | |
363 // Enables magnifier and confirm the viewport is at center. | |
364 GetMagnificationController()->SetEnabled(true); | |
365 EXPECT_FLOAT_EQ(2.f, GetMagnificationController()->GetScale()); | |
366 | |
367 scale *= kMagnificationFactor; | |
368 GetMagnificationController()->SetScale(scale, false); | |
369 EXPECT_FLOAT_EQ(2.3784142, GetMagnificationController()->GetScale()); | |
370 MoveCursorWithEvent(gfx::Point(400, 300)); | |
371 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | |
372 MoveCursorWithEvent(gfx::Point(799, 300)); | |
373 EXPECT_EQ("566,299", env->last_mouse_location().ToString()); | |
374 EXPECT_EQ("705,300", GetHostMouseLocation()); | |
375 | |
376 scale *= kMagnificationFactor; | |
377 GetMagnificationController()->SetScale(scale, false); | |
378 EXPECT_FLOAT_EQ(2.8284268, GetMagnificationController()->GetScale()); | |
379 MoveCursorWithEvent(gfx::Point(799, 300)); | |
380 EXPECT_EQ("599,299", env->last_mouse_location().ToString()); | |
381 EXPECT_EQ("702,300", GetHostMouseLocation()); | |
382 | |
383 scale *= kMagnificationFactor; | |
384 GetMagnificationController()->SetScale(scale, false); | |
385 EXPECT_FLOAT_EQ(3.3635852, GetMagnificationController()->GetScale()); | |
386 MoveCursorWithEvent(gfx::Point(799, 300)); | |
387 EXPECT_EQ("627,298", env->last_mouse_location().ToString()); | |
388 EXPECT_EQ("707,300", GetHostMouseLocation()); | |
389 | |
390 scale *= kMagnificationFactor; | |
391 GetMagnificationController()->SetScale(scale, false); | |
392 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); | |
393 MoveCursorWithEvent(gfx::Point(799, 300)); | |
394 EXPECT_EQ("649,298", env->last_mouse_location().ToString()); | |
395 EXPECT_EQ("704,300", GetHostMouseLocation()); | |
396 } | |
397 | |
398 TEST_F(MagnificationControllerTest, PanWindowToLeft) { | |
399 aura::Env* env = aura::Env::GetInstance(); | |
400 | |
401 MoveCursorWithEvent(gfx::Point(400, 300)); | |
402 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); | |
403 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); | |
404 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | |
405 | |
406 float scale = 2.f; | |
407 | |
408 // Enables magnifier and confirm the viewport is at center. | |
409 GetMagnificationController()->SetEnabled(true); | |
410 EXPECT_FLOAT_EQ(2.f, GetMagnificationController()->GetScale()); | |
411 | |
412 scale *= kMagnificationFactor; | |
413 GetMagnificationController()->SetScale(scale, false); | |
414 EXPECT_FLOAT_EQ(2.3784142, GetMagnificationController()->GetScale()); | |
415 MoveCursorWithEvent(gfx::Point(400, 300)); | |
416 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | |
417 MoveCursorWithEvent(gfx::Point(0, 300)); | |
418 EXPECT_EQ("231,299", env->last_mouse_location().ToString()); | |
419 EXPECT_EQ("100,300", GetHostMouseLocation()); | |
420 | |
421 scale *= kMagnificationFactor; | |
422 GetMagnificationController()->SetScale(scale, false); | |
423 EXPECT_FLOAT_EQ(2.8284268, GetMagnificationController()->GetScale()); | |
424 MoveCursorWithEvent(gfx::Point(0, 300)); | |
425 EXPECT_EQ("195,299", env->last_mouse_location().ToString()); | |
426 EXPECT_EQ("99,300", GetHostMouseLocation()); | |
427 | |
428 scale *= kMagnificationFactor; | |
429 GetMagnificationController()->SetScale(scale, false); | |
430 EXPECT_FLOAT_EQ(3.3635852, GetMagnificationController()->GetScale()); | |
431 MoveCursorWithEvent(gfx::Point(0, 300)); | |
432 EXPECT_EQ("165,298", env->last_mouse_location().ToString()); | |
433 EXPECT_EQ("98,300", GetHostMouseLocation()); | |
434 | |
435 scale *= kMagnificationFactor; | |
436 GetMagnificationController()->SetScale(scale, false); | |
437 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); | |
438 MoveCursorWithEvent(gfx::Point(0, 300)); | |
439 EXPECT_EQ("140,298", env->last_mouse_location().ToString()); | |
440 EXPECT_EQ("100,300", GetHostMouseLocation()); | |
441 } | |
442 | |
156 } // namespace internal | 443 } // namespace internal |
157 } // namespace ash | 444 } // namespace ash |
OLD | NEW |