| 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/magnifier/magnifier_constants.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 virtual void TearDown() OVERRIDE { | 47 virtual void TearDown() OVERRIDE { |
| 48 AshTestBase::TearDown(); | 48 AshTestBase::TearDown(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 protected: | 51 protected: |
| 52 aura::RootWindow* GetRootWindow() const { | 52 aura::RootWindow* GetRootWindow() const { |
| 53 return Shell::GetPrimaryRootWindow(); | 53 return Shell::GetPrimaryRootWindow(); |
| 54 } | 54 } |
| 55 | 55 |
| 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() { | 56 std::string GetHostMouseLocation() { |
| 63 gfx::Point point; | 57 gfx::Point point; |
| 64 GetRootWindow()->QueryMouseLocationForTest(&point); | 58 GetRootWindow()->QueryMouseLocationForTest(&point); |
| 65 return point.ToString(); | 59 return point.ToString(); |
| 66 } | 60 } |
| 67 | 61 |
| 68 ash::MagnificationController* GetMagnificationController() const { | 62 ash::MagnificationController* GetMagnificationController() const { |
| 69 return ash::Shell::GetInstance()->magnification_controller(); | 63 return ash::Shell::GetInstance()->magnification_controller(); |
| 70 } | 64 } |
| 71 | 65 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 EXPECT_EQ("0,300 400x300", GetViewport().ToString()); | 165 EXPECT_EQ("0,300 400x300", GetViewport().ToString()); |
| 172 | 166 |
| 173 GetMagnificationController()->MoveWindow(200, 400, false); | 167 GetMagnificationController()->MoveWindow(200, 400, false); |
| 174 EXPECT_EQ("200,300 400x300", GetViewport().ToString()); | 168 EXPECT_EQ("200,300 400x300", GetViewport().ToString()); |
| 175 | 169 |
| 176 GetMagnificationController()->MoveWindow(1000, 1000, false); | 170 GetMagnificationController()->MoveWindow(1000, 1000, false); |
| 177 EXPECT_EQ("400,300 400x300", GetViewport().ToString()); | 171 EXPECT_EQ("400,300 400x300", GetViewport().ToString()); |
| 178 } | 172 } |
| 179 | 173 |
| 180 TEST_F(MagnificationControllerTest, PointOfInterest) { | 174 TEST_F(MagnificationControllerTest, PointOfInterest) { |
| 181 MoveCursorWithEvent(gfx::Point(0, 0)); | 175 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 176 |
| 177 generator.MoveMouseToInHost(gfx::Point(0, 0)); |
| 182 EXPECT_EQ("0,0", CurrentPointOfInterest()); | 178 EXPECT_EQ("0,0", CurrentPointOfInterest()); |
| 183 | 179 |
| 184 MoveCursorWithEvent(gfx::Point(799, 599)); | 180 generator.MoveMouseToInHost(gfx::Point(799, 599)); |
| 185 EXPECT_EQ("799,599", CurrentPointOfInterest()); | 181 EXPECT_EQ("799,599", CurrentPointOfInterest()); |
| 186 | 182 |
| 187 MoveCursorWithEvent(gfx::Point(400, 300)); | 183 generator.MoveMouseToInHost(gfx::Point(400, 300)); |
| 188 EXPECT_EQ("400,300", CurrentPointOfInterest()); | 184 EXPECT_EQ("400,300", CurrentPointOfInterest()); |
| 189 | 185 |
| 190 GetMagnificationController()->SetEnabled(true); | 186 GetMagnificationController()->SetEnabled(true); |
| 191 EXPECT_EQ("400,300", CurrentPointOfInterest()); | 187 EXPECT_EQ("400,300", CurrentPointOfInterest()); |
| 192 | 188 |
| 193 MoveCursorWithEvent(gfx::Point(500, 400)); | 189 generator.MoveMouseToInHost(gfx::Point(500, 400)); |
| 194 EXPECT_EQ("450,350", CurrentPointOfInterest()); | 190 EXPECT_EQ("450,350", CurrentPointOfInterest()); |
| 195 } | 191 } |
| 196 | 192 |
| 197 TEST_F(MagnificationControllerTest, PanWindow2xLeftToRight) { | 193 TEST_F(MagnificationControllerTest, PanWindow2xLeftToRight) { |
| 198 const aura::Env* env = aura::Env::GetInstance(); | 194 const aura::Env* env = aura::Env::GetInstance(); |
| 195 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 199 | 196 |
| 200 MoveCursorWithEvent(gfx::Point(0, 0)); | 197 generator.MoveMouseToInHost(gfx::Point(0, 0)); |
| 201 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); | 198 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); |
| 202 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); | 199 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); |
| 203 EXPECT_EQ("0,0", env->last_mouse_location().ToString()); | 200 EXPECT_EQ("0,0", env->last_mouse_location().ToString()); |
| 204 | 201 |
| 205 // Enables magnifier and confirm the viewport is at center. | 202 // Enables magnifier and confirm the viewport is at center. |
| 206 GetMagnificationController()->SetEnabled(true); | 203 GetMagnificationController()->SetEnabled(true); |
| 207 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale()); | 204 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale()); |
| 208 | 205 |
| 209 GetMagnificationController()->MoveWindow(0, 0, false); | 206 GetMagnificationController()->MoveWindow(0, 0, false); |
| 210 MoveCursorWithEvent(gfx::Point(0, 0)); | 207 generator.MoveMouseToInHost(gfx::Point(0, 0)); |
| 211 EXPECT_EQ("0,0", env->last_mouse_location().ToString()); | 208 EXPECT_EQ("0,0", env->last_mouse_location().ToString()); |
| 212 EXPECT_EQ("0,0 400x300", GetViewport().ToString()); | 209 EXPECT_EQ("0,0 400x300", GetViewport().ToString()); |
| 213 | 210 |
| 214 MoveCursorWithEvent(gfx::Point(300, 150)); | 211 generator.MoveMouseToInHost(gfx::Point(300, 150)); |
| 215 EXPECT_EQ("150,75", env->last_mouse_location().ToString()); | 212 EXPECT_EQ("150,75", env->last_mouse_location().ToString()); |
| 216 EXPECT_EQ("0,0 400x300", GetViewport().ToString()); | 213 EXPECT_EQ("0,0 400x300", GetViewport().ToString()); |
| 217 | 214 |
| 218 MoveCursorWithEvent(gfx::Point(700, 150)); | 215 generator.MoveMouseToInHost(gfx::Point(700, 150)); |
| 219 EXPECT_EQ("350,75", env->last_mouse_location().ToString()); | 216 EXPECT_EQ("350,75", env->last_mouse_location().ToString()); |
| 220 EXPECT_EQ("0,0 400x300", GetViewport().ToString()); | 217 EXPECT_EQ("0,0 400x300", GetViewport().ToString()); |
| 221 | 218 |
| 222 MoveCursorWithEvent(gfx::Point(701, 150)); | 219 generator.MoveMouseToInHost(gfx::Point(701, 150)); |
| 223 EXPECT_EQ("350,75", env->last_mouse_location().ToString()); | 220 EXPECT_EQ("350,75", env->last_mouse_location().ToString()); |
| 224 EXPECT_EQ("0,0 400x300", GetViewport().ToString()); | 221 EXPECT_EQ("0,0 400x300", GetViewport().ToString()); |
| 225 | 222 |
| 226 MoveCursorWithEvent(gfx::Point(702, 150)); | 223 generator.MoveMouseToInHost(gfx::Point(702, 150)); |
| 227 EXPECT_EQ("351,75", env->last_mouse_location().ToString()); | 224 EXPECT_EQ("351,75", env->last_mouse_location().ToString()); |
| 228 EXPECT_EQ("1,0 400x300", GetViewport().ToString()); | 225 EXPECT_EQ("1,0 400x300", GetViewport().ToString()); |
| 229 | 226 |
| 230 MoveCursorWithEvent(gfx::Point(703, 150)); | 227 generator.MoveMouseToInHost(gfx::Point(703, 150)); |
| 231 EXPECT_EQ("352,75", env->last_mouse_location().ToString()); | 228 EXPECT_EQ("352,75", env->last_mouse_location().ToString()); |
| 232 EXPECT_EQ("2,0 400x300", GetViewport().ToString()); | 229 EXPECT_EQ("2,0 400x300", GetViewport().ToString()); |
| 233 | 230 |
| 234 MoveCursorWithEvent(gfx::Point(704, 150)); | 231 generator.MoveMouseToInHost(gfx::Point(704, 150)); |
| 235 EXPECT_EQ("354,75", env->last_mouse_location().ToString()); | 232 EXPECT_EQ("354,75", env->last_mouse_location().ToString()); |
| 236 EXPECT_EQ("4,0 400x300", GetViewport().ToString()); | 233 EXPECT_EQ("4,0 400x300", GetViewport().ToString()); |
| 237 | 234 |
| 238 MoveCursorWithEvent(gfx::Point(712, 150)); | 235 generator.MoveMouseToInHost(gfx::Point(712, 150)); |
| 239 EXPECT_EQ("360,75", env->last_mouse_location().ToString()); | 236 EXPECT_EQ("360,75", env->last_mouse_location().ToString()); |
| 240 EXPECT_EQ("10,0 400x300", GetViewport().ToString()); | 237 EXPECT_EQ("10,0 400x300", GetViewport().ToString()); |
| 241 | 238 |
| 242 MoveCursorWithEvent(gfx::Point(600, 150)); | 239 generator.MoveMouseToInHost(gfx::Point(600, 150)); |
| 243 EXPECT_EQ("310,75", env->last_mouse_location().ToString()); | 240 EXPECT_EQ("310,75", env->last_mouse_location().ToString()); |
| 244 EXPECT_EQ("10,0 400x300", GetViewport().ToString()); | 241 EXPECT_EQ("10,0 400x300", GetViewport().ToString()); |
| 245 | 242 |
| 246 MoveCursorWithEvent(gfx::Point(720, 150)); | 243 generator.MoveMouseToInHost(gfx::Point(720, 150)); |
| 247 EXPECT_EQ("370,75", env->last_mouse_location().ToString()); | 244 EXPECT_EQ("370,75", env->last_mouse_location().ToString()); |
| 248 EXPECT_EQ("20,0 400x300", GetViewport().ToString()); | 245 EXPECT_EQ("20,0 400x300", GetViewport().ToString()); |
| 249 | 246 |
| 250 MoveCursorWithEvent(gfx::Point(780, 150)); | 247 generator.MoveMouseToInHost(gfx::Point(780, 150)); |
| 251 EXPECT_EQ("410,75", env->last_mouse_location().ToString()); | 248 EXPECT_EQ("410,75", env->last_mouse_location().ToString()); |
| 252 EXPECT_EQ("410,75", CurrentPointOfInterest()); | 249 EXPECT_EQ("410,75", CurrentPointOfInterest()); |
| 253 EXPECT_EQ("60,0 400x300", GetViewport().ToString()); | 250 EXPECT_EQ("60,0 400x300", GetViewport().ToString()); |
| 254 | 251 |
| 255 MoveCursorWithEvent(gfx::Point(799, 150)); | 252 generator.MoveMouseToInHost(gfx::Point(799, 150)); |
| 256 EXPECT_EQ("459,75", env->last_mouse_location().ToString()); | 253 EXPECT_EQ("459,75", env->last_mouse_location().ToString()); |
| 257 EXPECT_EQ("109,0 400x300", GetViewport().ToString()); | 254 EXPECT_EQ("109,0 400x300", GetViewport().ToString()); |
| 258 | 255 |
| 259 MoveCursorWithEvent(gfx::Point(702, 150)); | 256 generator.MoveMouseToInHost(gfx::Point(702, 150)); |
| 260 EXPECT_EQ("460,75", env->last_mouse_location().ToString()); | 257 EXPECT_EQ("460,75", env->last_mouse_location().ToString()); |
| 261 EXPECT_EQ("110,0 400x300", GetViewport().ToString()); | 258 EXPECT_EQ("110,0 400x300", GetViewport().ToString()); |
| 262 | 259 |
| 263 MoveCursorWithEvent(gfx::Point(780, 150)); | 260 generator.MoveMouseToInHost(gfx::Point(780, 150)); |
| 264 EXPECT_EQ("500,75", env->last_mouse_location().ToString()); | 261 EXPECT_EQ("500,75", env->last_mouse_location().ToString()); |
| 265 EXPECT_EQ("150,0 400x300", GetViewport().ToString()); | 262 EXPECT_EQ("150,0 400x300", GetViewport().ToString()); |
| 266 | 263 |
| 267 MoveCursorWithEvent(gfx::Point(780, 150)); | 264 generator.MoveMouseToInHost(gfx::Point(780, 150)); |
| 268 EXPECT_EQ("540,75", env->last_mouse_location().ToString()); | 265 EXPECT_EQ("540,75", env->last_mouse_location().ToString()); |
| 269 EXPECT_EQ("190,0 400x300", GetViewport().ToString()); | 266 EXPECT_EQ("190,0 400x300", GetViewport().ToString()); |
| 270 | 267 |
| 271 MoveCursorWithEvent(gfx::Point(780, 150)); | 268 generator.MoveMouseToInHost(gfx::Point(780, 150)); |
| 272 EXPECT_EQ("580,75", env->last_mouse_location().ToString()); | 269 EXPECT_EQ("580,75", env->last_mouse_location().ToString()); |
| 273 EXPECT_EQ("230,0 400x300", GetViewport().ToString()); | 270 EXPECT_EQ("230,0 400x300", GetViewport().ToString()); |
| 274 | 271 |
| 275 MoveCursorWithEvent(gfx::Point(780, 150)); | 272 generator.MoveMouseToInHost(gfx::Point(780, 150)); |
| 276 EXPECT_EQ("620,75", env->last_mouse_location().ToString()); | 273 EXPECT_EQ("620,75", env->last_mouse_location().ToString()); |
| 277 EXPECT_EQ("270,0 400x300", GetViewport().ToString()); | 274 EXPECT_EQ("270,0 400x300", GetViewport().ToString()); |
| 278 | 275 |
| 279 MoveCursorWithEvent(gfx::Point(780, 150)); | 276 generator.MoveMouseToInHost(gfx::Point(780, 150)); |
| 280 EXPECT_EQ("660,75", env->last_mouse_location().ToString()); | 277 EXPECT_EQ("660,75", env->last_mouse_location().ToString()); |
| 281 EXPECT_EQ("310,0 400x300", GetViewport().ToString()); | 278 EXPECT_EQ("310,0 400x300", GetViewport().ToString()); |
| 282 | 279 |
| 283 MoveCursorWithEvent(gfx::Point(780, 150)); | 280 generator.MoveMouseToInHost(gfx::Point(780, 150)); |
| 284 EXPECT_EQ("700,75", env->last_mouse_location().ToString()); | 281 EXPECT_EQ("700,75", env->last_mouse_location().ToString()); |
| 285 EXPECT_EQ("350,0 400x300", GetViewport().ToString()); | 282 EXPECT_EQ("350,0 400x300", GetViewport().ToString()); |
| 286 | 283 |
| 287 MoveCursorWithEvent(gfx::Point(780, 150)); | 284 generator.MoveMouseToInHost(gfx::Point(780, 150)); |
| 288 EXPECT_EQ("740,75", env->last_mouse_location().ToString()); | 285 EXPECT_EQ("740,75", env->last_mouse_location().ToString()); |
| 289 EXPECT_EQ("390,0 400x300", GetViewport().ToString()); | 286 EXPECT_EQ("390,0 400x300", GetViewport().ToString()); |
| 290 | 287 |
| 291 MoveCursorWithEvent(gfx::Point(780, 150)); | 288 generator.MoveMouseToInHost(gfx::Point(780, 150)); |
| 292 EXPECT_EQ("780,75", env->last_mouse_location().ToString()); | 289 EXPECT_EQ("780,75", env->last_mouse_location().ToString()); |
| 293 EXPECT_EQ("400,0 400x300", GetViewport().ToString()); | 290 EXPECT_EQ("400,0 400x300", GetViewport().ToString()); |
| 294 | 291 |
| 295 MoveCursorWithEvent(gfx::Point(799, 150)); | 292 generator.MoveMouseToInHost(gfx::Point(799, 150)); |
| 296 EXPECT_EQ("799,75", env->last_mouse_location().ToString()); | 293 EXPECT_EQ("799,75", env->last_mouse_location().ToString()); |
| 297 EXPECT_EQ("400,0 400x300", GetViewport().ToString()); | 294 EXPECT_EQ("400,0 400x300", GetViewport().ToString()); |
| 298 } | 295 } |
| 299 | 296 |
| 300 TEST_F(MagnificationControllerTest, PanWindow2xRightToLeft) { | 297 TEST_F(MagnificationControllerTest, PanWindow2xRightToLeft) { |
| 301 const aura::Env* env = aura::Env::GetInstance(); | 298 const aura::Env* env = aura::Env::GetInstance(); |
| 299 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 302 | 300 |
| 303 MoveCursorWithEvent(gfx::Point(799, 300)); | 301 generator.MoveMouseToInHost(gfx::Point(799, 300)); |
| 304 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); | 302 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); |
| 305 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); | 303 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); |
| 306 EXPECT_EQ("799,300", env->last_mouse_location().ToString()); | 304 EXPECT_EQ("799,300", env->last_mouse_location().ToString()); |
| 307 | 305 |
| 308 // Enables magnifier and confirm the viewport is at center. | 306 // Enables magnifier and confirm the viewport is at center. |
| 309 GetMagnificationController()->SetEnabled(true); | 307 GetMagnificationController()->SetEnabled(true); |
| 310 | 308 |
| 311 MoveCursorWithEvent(gfx::Point(799, 300)); | 309 generator.MoveMouseToInHost(gfx::Point(799, 300)); |
| 312 EXPECT_EQ("798,300", env->last_mouse_location().ToString()); | 310 EXPECT_EQ("798,300", env->last_mouse_location().ToString()); |
| 313 EXPECT_EQ("400,150 400x300", GetViewport().ToString()); | 311 EXPECT_EQ("400,150 400x300", GetViewport().ToString()); |
| 314 | 312 |
| 315 MoveCursorWithEvent(gfx::Point(0, 300)); | 313 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
| 316 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | 314 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
| 317 EXPECT_EQ("350,150 400x300", GetViewport().ToString()); | 315 EXPECT_EQ("350,150 400x300", GetViewport().ToString()); |
| 318 | 316 |
| 319 MoveCursorWithEvent(gfx::Point(0, 300)); | 317 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
| 320 EXPECT_EQ("350,300", env->last_mouse_location().ToString()); | 318 EXPECT_EQ("350,300", env->last_mouse_location().ToString()); |
| 321 EXPECT_EQ("300,150 400x300", GetViewport().ToString()); | 319 EXPECT_EQ("300,150 400x300", GetViewport().ToString()); |
| 322 | 320 |
| 323 MoveCursorWithEvent(gfx::Point(0, 300)); | 321 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
| 324 EXPECT_EQ("300,300", env->last_mouse_location().ToString()); | 322 EXPECT_EQ("300,300", env->last_mouse_location().ToString()); |
| 325 EXPECT_EQ("250,150 400x300", GetViewport().ToString()); | 323 EXPECT_EQ("250,150 400x300", GetViewport().ToString()); |
| 326 | 324 |
| 327 MoveCursorWithEvent(gfx::Point(0, 300)); | 325 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
| 328 EXPECT_EQ("250,300", env->last_mouse_location().ToString()); | 326 EXPECT_EQ("250,300", env->last_mouse_location().ToString()); |
| 329 EXPECT_EQ("200,150 400x300", GetViewport().ToString()); | 327 EXPECT_EQ("200,150 400x300", GetViewport().ToString()); |
| 330 | 328 |
| 331 MoveCursorWithEvent(gfx::Point(0, 300)); | 329 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
| 332 EXPECT_EQ("200,300", env->last_mouse_location().ToString()); | 330 EXPECT_EQ("200,300", env->last_mouse_location().ToString()); |
| 333 EXPECT_EQ("150,150 400x300", GetViewport().ToString()); | 331 EXPECT_EQ("150,150 400x300", GetViewport().ToString()); |
| 334 | 332 |
| 335 MoveCursorWithEvent(gfx::Point(0, 300)); | 333 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
| 336 EXPECT_EQ("150,300", env->last_mouse_location().ToString()); | 334 EXPECT_EQ("150,300", env->last_mouse_location().ToString()); |
| 337 EXPECT_EQ("100,150 400x300", GetViewport().ToString()); | 335 EXPECT_EQ("100,150 400x300", GetViewport().ToString()); |
| 338 | 336 |
| 339 MoveCursorWithEvent(gfx::Point(0, 300)); | 337 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
| 340 EXPECT_EQ("100,300", env->last_mouse_location().ToString()); | 338 EXPECT_EQ("100,300", env->last_mouse_location().ToString()); |
| 341 EXPECT_EQ("50,150 400x300", GetViewport().ToString()); | 339 EXPECT_EQ("50,150 400x300", GetViewport().ToString()); |
| 342 | 340 |
| 343 MoveCursorWithEvent(gfx::Point(0, 300)); | 341 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
| 344 EXPECT_EQ("50,300", env->last_mouse_location().ToString()); | 342 EXPECT_EQ("50,300", env->last_mouse_location().ToString()); |
| 345 EXPECT_EQ("0,150 400x300", GetViewport().ToString()); | 343 EXPECT_EQ("0,150 400x300", GetViewport().ToString()); |
| 346 | 344 |
| 347 MoveCursorWithEvent(gfx::Point(0, 300)); | 345 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
| 348 EXPECT_EQ("0,300", env->last_mouse_location().ToString()); | 346 EXPECT_EQ("0,300", env->last_mouse_location().ToString()); |
| 349 EXPECT_EQ("0,150 400x300", GetViewport().ToString()); | 347 EXPECT_EQ("0,150 400x300", GetViewport().ToString()); |
| 350 } | 348 } |
| 351 | 349 |
| 352 TEST_F(MagnificationControllerTest, PanWindowToRight) { | 350 TEST_F(MagnificationControllerTest, PanWindowToRight) { |
| 353 const aura::Env* env = aura::Env::GetInstance(); | 351 const aura::Env* env = aura::Env::GetInstance(); |
| 352 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 354 | 353 |
| 355 MoveCursorWithEvent(gfx::Point(400, 300)); | 354 generator.MoveMouseToInHost(gfx::Point(400, 300)); |
| 356 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); | 355 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); |
| 357 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); | 356 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); |
| 358 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | 357 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
| 359 | 358 |
| 360 float scale = 2.f; | 359 float scale = 2.f; |
| 361 | 360 |
| 362 // Enables magnifier and confirm the viewport is at center. | 361 // Enables magnifier and confirm the viewport is at center. |
| 363 GetMagnificationController()->SetEnabled(true); | 362 GetMagnificationController()->SetEnabled(true); |
| 364 EXPECT_FLOAT_EQ(2.f, GetMagnificationController()->GetScale()); | 363 EXPECT_FLOAT_EQ(2.f, GetMagnificationController()->GetScale()); |
| 365 | 364 |
| 366 scale *= kMagnificationScaleFactor; | 365 scale *= kMagnificationScaleFactor; |
| 367 GetMagnificationController()->SetScale(scale, false); | 366 GetMagnificationController()->SetScale(scale, false); |
| 368 EXPECT_FLOAT_EQ(2.3784142, GetMagnificationController()->GetScale()); | 367 EXPECT_FLOAT_EQ(2.3784142, GetMagnificationController()->GetScale()); |
| 369 MoveCursorWithEvent(gfx::Point(400, 300)); | 368 generator.MoveMouseToInHost(gfx::Point(400, 300)); |
| 370 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | 369 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
| 371 MoveCursorWithEvent(gfx::Point(799, 300)); | 370 generator.MoveMouseToInHost(gfx::Point(799, 300)); |
| 372 EXPECT_EQ("566,299", env->last_mouse_location().ToString()); | 371 EXPECT_EQ("566,299", env->last_mouse_location().ToString()); |
| 373 EXPECT_EQ("705,300", GetHostMouseLocation()); | 372 EXPECT_EQ("705,300", GetHostMouseLocation()); |
| 374 | 373 |
| 375 scale *= kMagnificationScaleFactor; | 374 scale *= kMagnificationScaleFactor; |
| 376 GetMagnificationController()->SetScale(scale, false); | 375 GetMagnificationController()->SetScale(scale, false); |
| 377 EXPECT_FLOAT_EQ(2.8284268, GetMagnificationController()->GetScale()); | 376 EXPECT_FLOAT_EQ(2.8284268, GetMagnificationController()->GetScale()); |
| 378 MoveCursorWithEvent(gfx::Point(799, 300)); | 377 generator.MoveMouseToInHost(gfx::Point(799, 300)); |
| 379 EXPECT_EQ("599,299", env->last_mouse_location().ToString()); | 378 EXPECT_EQ("599,299", env->last_mouse_location().ToString()); |
| 380 EXPECT_EQ("702,300", GetHostMouseLocation()); | 379 EXPECT_EQ("702,300", GetHostMouseLocation()); |
| 381 | 380 |
| 382 scale *= kMagnificationScaleFactor; | 381 scale *= kMagnificationScaleFactor; |
| 383 GetMagnificationController()->SetScale(scale, false); | 382 GetMagnificationController()->SetScale(scale, false); |
| 384 EXPECT_FLOAT_EQ(3.3635852, GetMagnificationController()->GetScale()); | 383 EXPECT_FLOAT_EQ(3.3635852, GetMagnificationController()->GetScale()); |
| 385 MoveCursorWithEvent(gfx::Point(799, 300)); | 384 generator.MoveMouseToInHost(gfx::Point(799, 300)); |
| 386 EXPECT_EQ("627,298", env->last_mouse_location().ToString()); | 385 EXPECT_EQ("627,298", env->last_mouse_location().ToString()); |
| 387 EXPECT_EQ("707,300", GetHostMouseLocation()); | 386 EXPECT_EQ("707,300", GetHostMouseLocation()); |
| 388 | 387 |
| 389 scale *= kMagnificationScaleFactor; | 388 scale *= kMagnificationScaleFactor; |
| 390 GetMagnificationController()->SetScale(scale, false); | 389 GetMagnificationController()->SetScale(scale, false); |
| 391 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); | 390 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); |
| 392 MoveCursorWithEvent(gfx::Point(799, 300)); | 391 generator.MoveMouseToInHost(gfx::Point(799, 300)); |
| 393 EXPECT_EQ("649,298", env->last_mouse_location().ToString()); | 392 EXPECT_EQ("649,298", env->last_mouse_location().ToString()); |
| 394 EXPECT_EQ("704,300", GetHostMouseLocation()); | 393 EXPECT_EQ("704,300", GetHostMouseLocation()); |
| 395 } | 394 } |
| 396 | 395 |
| 397 TEST_F(MagnificationControllerTest, PanWindowToLeft) { | 396 TEST_F(MagnificationControllerTest, PanWindowToLeft) { |
| 398 const aura::Env* env = aura::Env::GetInstance(); | 397 const aura::Env* env = aura::Env::GetInstance(); |
| 398 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 399 | 399 |
| 400 MoveCursorWithEvent(gfx::Point(400, 300)); | 400 generator.MoveMouseToInHost(gfx::Point(400, 300)); |
| 401 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); | 401 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); |
| 402 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); | 402 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); |
| 403 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | 403 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
| 404 | 404 |
| 405 float scale = 2.f; | 405 float scale = 2.f; |
| 406 | 406 |
| 407 // Enables magnifier and confirm the viewport is at center. | 407 // Enables magnifier and confirm the viewport is at center. |
| 408 GetMagnificationController()->SetEnabled(true); | 408 GetMagnificationController()->SetEnabled(true); |
| 409 EXPECT_FLOAT_EQ(2.f, GetMagnificationController()->GetScale()); | 409 EXPECT_FLOAT_EQ(2.f, GetMagnificationController()->GetScale()); |
| 410 | 410 |
| 411 scale *= kMagnificationScaleFactor; | 411 scale *= kMagnificationScaleFactor; |
| 412 GetMagnificationController()->SetScale(scale, false); | 412 GetMagnificationController()->SetScale(scale, false); |
| 413 EXPECT_FLOAT_EQ(2.3784142, GetMagnificationController()->GetScale()); | 413 EXPECT_FLOAT_EQ(2.3784142, GetMagnificationController()->GetScale()); |
| 414 MoveCursorWithEvent(gfx::Point(400, 300)); | 414 generator.MoveMouseToInHost(gfx::Point(400, 300)); |
| 415 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | 415 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
| 416 MoveCursorWithEvent(gfx::Point(0, 300)); | 416 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
| 417 EXPECT_EQ("231,299", env->last_mouse_location().ToString()); | 417 EXPECT_EQ("231,299", env->last_mouse_location().ToString()); |
| 418 EXPECT_EQ("100,300", GetHostMouseLocation()); | 418 EXPECT_EQ("100,300", GetHostMouseLocation()); |
| 419 | 419 |
| 420 scale *= kMagnificationScaleFactor; | 420 scale *= kMagnificationScaleFactor; |
| 421 GetMagnificationController()->SetScale(scale, false); | 421 GetMagnificationController()->SetScale(scale, false); |
| 422 EXPECT_FLOAT_EQ(2.8284268, GetMagnificationController()->GetScale()); | 422 EXPECT_FLOAT_EQ(2.8284268, GetMagnificationController()->GetScale()); |
| 423 MoveCursorWithEvent(gfx::Point(0, 300)); | 423 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
| 424 EXPECT_EQ("195,299", env->last_mouse_location().ToString()); | 424 EXPECT_EQ("195,299", env->last_mouse_location().ToString()); |
| 425 EXPECT_EQ("99,300", GetHostMouseLocation()); | 425 EXPECT_EQ("99,300", GetHostMouseLocation()); |
| 426 | 426 |
| 427 scale *= kMagnificationScaleFactor; | 427 scale *= kMagnificationScaleFactor; |
| 428 GetMagnificationController()->SetScale(scale, false); | 428 GetMagnificationController()->SetScale(scale, false); |
| 429 EXPECT_FLOAT_EQ(3.3635852, GetMagnificationController()->GetScale()); | 429 EXPECT_FLOAT_EQ(3.3635852, GetMagnificationController()->GetScale()); |
| 430 MoveCursorWithEvent(gfx::Point(0, 300)); | 430 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
| 431 EXPECT_EQ("165,298", env->last_mouse_location().ToString()); | 431 EXPECT_EQ("165,298", env->last_mouse_location().ToString()); |
| 432 EXPECT_EQ("98,300", GetHostMouseLocation()); | 432 EXPECT_EQ("98,300", GetHostMouseLocation()); |
| 433 | 433 |
| 434 scale *= kMagnificationScaleFactor; | 434 scale *= kMagnificationScaleFactor; |
| 435 GetMagnificationController()->SetScale(scale, false); | 435 GetMagnificationController()->SetScale(scale, false); |
| 436 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); | 436 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); |
| 437 MoveCursorWithEvent(gfx::Point(0, 300)); | 437 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
| 438 EXPECT_EQ("140,298", env->last_mouse_location().ToString()); | 438 EXPECT_EQ("140,298", env->last_mouse_location().ToString()); |
| 439 EXPECT_EQ("100,300", GetHostMouseLocation()); | 439 EXPECT_EQ("100,300", GetHostMouseLocation()); |
| 440 } | 440 } |
| 441 | 441 |
| 442 } // namespace internal | 442 } // namespace internal |
| 443 } // namespace ash | 443 } // namespace ash |
| OLD | NEW |