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