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/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/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
12 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
| 13 #include "ui/aura/test/aura_test_utils.h" |
13 #include "ui/aura/test/event_generator.h" | 14 #include "ui/aura/test/event_generator.h" |
14 #include "ui/aura/window_tree_host.h" | 15 #include "ui/aura/window_tree_host.h" |
15 #include "ui/gfx/rect_conversions.h" | 16 #include "ui/gfx/rect_conversions.h" |
16 #include "ui/gfx/screen.h" | 17 #include "ui/gfx/screen.h" |
17 | 18 |
18 namespace ash { | 19 namespace ash { |
19 namespace { | 20 namespace { |
20 | 21 |
21 const int kRootHeight = 600; | 22 const int kRootHeight = 600; |
22 const int kRootWidth = 800; | 23 const int kRootWidth = 800; |
(...skipping 23 matching lines...) Expand all Loading... |
46 virtual void TearDown() OVERRIDE { | 47 virtual void TearDown() OVERRIDE { |
47 AshTestBase::TearDown(); | 48 AshTestBase::TearDown(); |
48 } | 49 } |
49 | 50 |
50 protected: | 51 protected: |
51 aura::Window* GetRootWindow() const { | 52 aura::Window* GetRootWindow() const { |
52 return Shell::GetPrimaryRootWindow(); | 53 return Shell::GetPrimaryRootWindow(); |
53 } | 54 } |
54 | 55 |
55 std::string GetHostMouseLocation() { | 56 std::string GetHostMouseLocation() { |
56 gfx::Point point; | 57 aura::WindowTreeHostTestApi host_test_api(GetRootWindow()->GetHost()); |
57 GetRootWindow()->GetHost()->QueryMouseLocation(&point); | 58 return host_test_api.last_cursor_request_position_in_host().ToString(); |
58 return point.ToString(); | |
59 } | 59 } |
60 | 60 |
61 ash::MagnificationController* GetMagnificationController() const { | 61 ash::MagnificationController* GetMagnificationController() const { |
62 return ash::Shell::GetInstance()->magnification_controller(); | 62 return ash::Shell::GetInstance()->magnification_controller(); |
63 } | 63 } |
64 | 64 |
65 gfx::Rect GetViewport() const { | 65 gfx::Rect GetViewport() const { |
66 gfx::RectF bounds(0, 0, kRootWidth, kRootHeight); | 66 gfx::RectF bounds(0, 0, kRootWidth, kRootHeight); |
67 GetRootWindow()->layer()->transform().TransformRectReverse(&bounds); | 67 GetRootWindow()->layer()->transform().TransformRectReverse(&bounds); |
68 return gfx::ToEnclosingRect(bounds); | 68 return gfx::ToEnclosingRect(bounds); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 | 432 |
433 scale *= kMagnificationScaleFactor; | 433 scale *= kMagnificationScaleFactor; |
434 GetMagnificationController()->SetScale(scale, false); | 434 GetMagnificationController()->SetScale(scale, false); |
435 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); | 435 EXPECT_FLOAT_EQ(4.f, GetMagnificationController()->GetScale()); |
436 generator.MoveMouseToInHost(gfx::Point(0, 300)); | 436 generator.MoveMouseToInHost(gfx::Point(0, 300)); |
437 EXPECT_EQ("139,298", env->last_mouse_location().ToString()); | 437 EXPECT_EQ("139,298", env->last_mouse_location().ToString()); |
438 EXPECT_EQ("100,300", GetHostMouseLocation()); | 438 EXPECT_EQ("100,300", GetHostMouseLocation()); |
439 } | 439 } |
440 | 440 |
441 } // namespace ash | 441 } // namespace ash |
OLD | NEW |