| 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/magnifier/magnification_controller.h" | 5 #include "ash/magnifier/magnification_controller.h" |
| 6 | 6 |
| 7 #include "ash/common/accessibility_types.h" | 7 #include "ash/common/accessibility_types.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); | 452 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); |
| 453 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); | 453 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); |
| 454 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | 454 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
| 455 | 455 |
| 456 float scale = 2.f; | 456 float scale = 2.f; |
| 457 | 457 |
| 458 // Enables magnifier and confirm the viewport is at center. | 458 // Enables magnifier and confirm the viewport is at center. |
| 459 GetMagnificationController()->SetEnabled(true); | 459 GetMagnificationController()->SetEnabled(true); |
| 460 EXPECT_FLOAT_EQ(2.f, GetMagnificationController()->GetScale()); | 460 EXPECT_FLOAT_EQ(2.f, GetMagnificationController()->GetScale()); |
| 461 | 461 |
| 462 scale *= ui::kMagnificationScaleFactor; | 462 scale *= kMagnificationScaleFactor; |
| 463 GetMagnificationController()->SetScale(scale, false); | 463 GetMagnificationController()->SetScale(scale, false); |
| 464 EXPECT_FLOAT_EQ(2.3784142, GetMagnificationController()->GetScale()); | 464 EXPECT_FLOAT_EQ(2.3784142, GetMagnificationController()->GetScale()); |
| 465 GetEventGenerator().MoveMouseToInHost(gfx::Point(400, 300)); | 465 GetEventGenerator().MoveMouseToInHost(gfx::Point(400, 300)); |
| 466 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | 466 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
| 467 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300)); | 467 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300)); |
| 468 EXPECT_EQ("566,299", env->last_mouse_location().ToString()); | 468 EXPECT_EQ("566,299", env->last_mouse_location().ToString()); |
| 469 EXPECT_EQ("705,300", GetHostMouseLocation()); | 469 EXPECT_EQ("705,300", GetHostMouseLocation()); |
| 470 | 470 |
| 471 scale *= ui::kMagnificationScaleFactor; | 471 scale *= kMagnificationScaleFactor; |
| 472 GetMagnificationController()->SetScale(scale, false); | 472 GetMagnificationController()->SetScale(scale, false); |
| 473 EXPECT_FLOAT_EQ(2.8284268, GetMagnificationController()->GetScale()); | 473 EXPECT_FLOAT_EQ(2.8284268, GetMagnificationController()->GetScale()); |
| 474 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300)); | 474 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300)); |
| 475 EXPECT_EQ("599,299", env->last_mouse_location().ToString()); | 475 EXPECT_EQ("599,299", env->last_mouse_location().ToString()); |
| 476 EXPECT_EQ("702,300", GetHostMouseLocation()); | 476 EXPECT_EQ("702,300", GetHostMouseLocation()); |
| 477 | 477 |
| 478 scale *= ui::kMagnificationScaleFactor; | 478 scale *= kMagnificationScaleFactor; |
| 479 GetMagnificationController()->SetScale(scale, false); | 479 GetMagnificationController()->SetScale(scale, false); |
| 480 EXPECT_FLOAT_EQ(3.3635852, GetMagnificationController()->GetScale()); | 480 EXPECT_FLOAT_EQ(3.3635852, GetMagnificationController()->GetScale()); |
| 481 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300)); | 481 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300)); |
| 482 EXPECT_EQ("627,298", env->last_mouse_location().ToString()); | 482 EXPECT_EQ("627,298", env->last_mouse_location().ToString()); |
| 483 EXPECT_EQ("707,300", GetHostMouseLocation()); | 483 EXPECT_EQ("707,300", GetHostMouseLocation()); |
| 484 | 484 |
| 485 scale *= ui::kMagnificationScaleFactor; | 485 scale *= kMagnificationScaleFactor; |
| 486 GetMagnificationController()->SetScale(scale, false); | 486 GetMagnificationController()->SetScale(scale, false); |
| 487 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); | 487 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); |
| 488 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300)); | 488 GetEventGenerator().MoveMouseToInHost(gfx::Point(799, 300)); |
| 489 EXPECT_EQ("649,298", env->last_mouse_location().ToString()); | 489 EXPECT_EQ("649,298", env->last_mouse_location().ToString()); |
| 490 EXPECT_EQ("704,300", GetHostMouseLocation()); | 490 EXPECT_EQ("704,300", GetHostMouseLocation()); |
| 491 } | 491 } |
| 492 | 492 |
| 493 TEST_F(MagnificationControllerTest, PanWindowToLeft) { | 493 TEST_F(MagnificationControllerTest, PanWindowToLeft) { |
| 494 const aura::Env* env = aura::Env::GetInstance(); | 494 const aura::Env* env = aura::Env::GetInstance(); |
| 495 | 495 |
| 496 GetEventGenerator().MoveMouseToInHost(gfx::Point(400, 300)); | 496 GetEventGenerator().MoveMouseToInHost(gfx::Point(400, 300)); |
| 497 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); | 497 EXPECT_EQ(1.f, GetMagnificationController()->GetScale()); |
| 498 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); | 498 EXPECT_EQ("0,0 800x600", GetViewport().ToString()); |
| 499 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | 499 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
| 500 | 500 |
| 501 float scale = 2.f; | 501 float scale = 2.f; |
| 502 | 502 |
| 503 // Enables magnifier and confirm the viewport is at center. | 503 // Enables magnifier and confirm the viewport is at center. |
| 504 GetMagnificationController()->SetEnabled(true); | 504 GetMagnificationController()->SetEnabled(true); |
| 505 EXPECT_FLOAT_EQ(2.f, GetMagnificationController()->GetScale()); | 505 EXPECT_FLOAT_EQ(2.f, GetMagnificationController()->GetScale()); |
| 506 | 506 |
| 507 scale *= ui::kMagnificationScaleFactor; | 507 scale *= kMagnificationScaleFactor; |
| 508 GetMagnificationController()->SetScale(scale, false); | 508 GetMagnificationController()->SetScale(scale, false); |
| 509 EXPECT_FLOAT_EQ(2.3784142, GetMagnificationController()->GetScale()); | 509 EXPECT_FLOAT_EQ(2.3784142, GetMagnificationController()->GetScale()); |
| 510 GetEventGenerator().MoveMouseToInHost(gfx::Point(400, 300)); | 510 GetEventGenerator().MoveMouseToInHost(gfx::Point(400, 300)); |
| 511 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); | 511 EXPECT_EQ("400,300", env->last_mouse_location().ToString()); |
| 512 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 300)); | 512 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 300)); |
| 513 EXPECT_EQ("231,299", env->last_mouse_location().ToString()); | 513 EXPECT_EQ("231,299", env->last_mouse_location().ToString()); |
| 514 EXPECT_EQ("100,300", GetHostMouseLocation()); | 514 EXPECT_EQ("100,300", GetHostMouseLocation()); |
| 515 | 515 |
| 516 scale *= ui::kMagnificationScaleFactor; | 516 scale *= kMagnificationScaleFactor; |
| 517 GetMagnificationController()->SetScale(scale, false); | 517 GetMagnificationController()->SetScale(scale, false); |
| 518 EXPECT_FLOAT_EQ(2.8284268, GetMagnificationController()->GetScale()); | 518 EXPECT_FLOAT_EQ(2.8284268, GetMagnificationController()->GetScale()); |
| 519 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 300)); | 519 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 300)); |
| 520 EXPECT_EQ("194,299", env->last_mouse_location().ToString()); | 520 EXPECT_EQ("194,299", env->last_mouse_location().ToString()); |
| 521 EXPECT_EQ("99,300", GetHostMouseLocation()); | 521 EXPECT_EQ("99,300", GetHostMouseLocation()); |
| 522 | 522 |
| 523 scale *= ui::kMagnificationScaleFactor; | 523 scale *= kMagnificationScaleFactor; |
| 524 GetMagnificationController()->SetScale(scale, false); | 524 GetMagnificationController()->SetScale(scale, false); |
| 525 EXPECT_FLOAT_EQ(3.3635852, GetMagnificationController()->GetScale()); | 525 EXPECT_FLOAT_EQ(3.3635852, GetMagnificationController()->GetScale()); |
| 526 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 300)); | 526 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 300)); |
| 527 EXPECT_EQ("164,298", env->last_mouse_location().ToString()); | 527 EXPECT_EQ("164,298", env->last_mouse_location().ToString()); |
| 528 EXPECT_EQ("98,300", GetHostMouseLocation()); | 528 EXPECT_EQ("98,300", GetHostMouseLocation()); |
| 529 | 529 |
| 530 scale *= ui::kMagnificationScaleFactor; | 530 scale *= kMagnificationScaleFactor; |
| 531 GetMagnificationController()->SetScale(scale, false); | 531 GetMagnificationController()->SetScale(scale, false); |
| 532 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); | 532 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); |
| 533 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 300)); | 533 GetEventGenerator().MoveMouseToInHost(gfx::Point(0, 300)); |
| 534 EXPECT_EQ("139,298", env->last_mouse_location().ToString()); | 534 EXPECT_EQ("139,298", env->last_mouse_location().ToString()); |
| 535 EXPECT_EQ("100,300", GetHostMouseLocation()); | 535 EXPECT_EQ("100,300", GetHostMouseLocation()); |
| 536 } | 536 } |
| 537 | 537 |
| 538 TEST_F(MagnificationControllerTest, FollowTextInputFieldFocus) { | 538 TEST_F(MagnificationControllerTest, FollowTextInputFieldFocus) { |
| 539 CreateAndShowTextInputView(gfx::Rect(500, 300, 80, 80)); | 539 CreateAndShowTextInputView(gfx::Rect(500, 300, 80, 80)); |
| 540 gfx::Rect text_input_bounds = GetTextInputViewBounds(); | 540 gfx::Rect text_input_bounds = GetTextInputViewBounds(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 UpdateDisplay("500x500"); | 710 UpdateDisplay("500x500"); |
| 711 EXPECT_EQ("0,0 500x500", screen->GetPrimaryDisplay().bounds().ToString()); | 711 EXPECT_EQ("0,0 500x500", screen->GetPrimaryDisplay().bounds().ToString()); |
| 712 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale()); | 712 EXPECT_EQ(2.0f, GetMagnificationController()->GetScale()); |
| 713 | 713 |
| 714 GetMagnificationController()->SetEnabled(false); | 714 GetMagnificationController()->SetEnabled(false); |
| 715 EXPECT_EQ("0,0 500x500", screen->GetPrimaryDisplay().bounds().ToString()); | 715 EXPECT_EQ("0,0 500x500", screen->GetPrimaryDisplay().bounds().ToString()); |
| 716 EXPECT_EQ(1.0f, GetMagnificationController()->GetScale()); | 716 EXPECT_EQ(1.0f, GetMagnificationController()->GetScale()); |
| 717 } | 717 } |
| 718 | 718 |
| 719 } // namespace ash | 719 } // namespace ash |
| OLD | NEW |