OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef UI_AURA_TEST_TEST_SCREEN_H_ | 5 #ifndef UI_AURA_TEST_TEST_SCREEN_H_ |
6 #define UI_AURA_TEST_TEST_SCREEN_H_ | 6 #define UI_AURA_TEST_TEST_SCREEN_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "ui/aura/window_observer.h" | 10 #include "ui/aura/window_observer.h" |
11 #include "ui/gfx/display.h" | 11 #include "ui/display/display.h" |
12 #include "ui/gfx/screen.h" | 12 #include "ui/display/screen.h" |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
15 class Insets; | 15 class Insets; |
16 class Rect; | 16 class Rect; |
17 class Transform; | 17 class Transform; |
18 } | 18 } |
19 | 19 |
20 namespace aura { | 20 namespace aura { |
21 class Window; | 21 class Window; |
22 class WindowTreeHost; | 22 class WindowTreeHost; |
23 | 23 |
24 // A minimal, testing Aura implementation of gfx::Screen. | 24 // A minimal, testing Aura implementation of display::Screen. |
25 // TODO(bruthig): Consider extending gfx::test::TestScreen. | 25 // TODO(bruthig): Consider extending gfx::test::TestScreen. |
26 class TestScreen : public gfx::Screen, | 26 class TestScreen : public display::Screen, public WindowObserver { |
27 public WindowObserver { | |
28 public: | 27 public: |
29 // Creates a gfx::Screen of the specified size. If no size is specified, then | 28 // Creates a display::Screen of the specified size. If no size is specified, |
30 // creates a 800x600 screen. |size| is in physical pixels. | 29 // then creates a 800x600 screen. |size| is in physical pixels. |
31 static TestScreen* Create(const gfx::Size& size); | 30 static TestScreen* Create(const gfx::Size& size); |
32 ~TestScreen() override; | 31 ~TestScreen() override; |
33 | 32 |
34 WindowTreeHost* CreateHostForPrimaryDisplay(); | 33 WindowTreeHost* CreateHostForPrimaryDisplay(); |
35 | 34 |
36 void SetDeviceScaleFactor(float device_scale_fator); | 35 void SetDeviceScaleFactor(float device_scale_fator); |
37 void SetDisplayRotation(gfx::Display::Rotation rotation); | 36 void SetDisplayRotation(display::Display::Rotation rotation); |
38 void SetUIScale(float ui_scale); | 37 void SetUIScale(float ui_scale); |
39 void SetWorkAreaInsets(const gfx::Insets& insets); | 38 void SetWorkAreaInsets(const gfx::Insets& insets); |
40 | 39 |
41 protected: | 40 protected: |
42 gfx::Transform GetRotationTransform() const; | 41 gfx::Transform GetRotationTransform() const; |
43 gfx::Transform GetUIScaleTransform() const; | 42 gfx::Transform GetUIScaleTransform() const; |
44 | 43 |
45 // WindowObserver overrides: | 44 // WindowObserver overrides: |
46 void OnWindowBoundsChanged(Window* window, | 45 void OnWindowBoundsChanged(Window* window, |
47 const gfx::Rect& old_bounds, | 46 const gfx::Rect& old_bounds, |
48 const gfx::Rect& new_bounds) override; | 47 const gfx::Rect& new_bounds) override; |
49 void OnWindowDestroying(Window* window) override; | 48 void OnWindowDestroying(Window* window) override; |
50 | 49 |
51 // gfx::Screen overrides: | 50 // display::Screen overrides: |
52 gfx::Point GetCursorScreenPoint() override; | 51 gfx::Point GetCursorScreenPoint() override; |
53 gfx::NativeWindow GetWindowUnderCursor() override; | 52 gfx::NativeWindow GetWindowUnderCursor() override; |
54 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override; | 53 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override; |
55 int GetNumDisplays() const override; | 54 int GetNumDisplays() const override; |
56 std::vector<gfx::Display> GetAllDisplays() const override; | 55 std::vector<display::Display> GetAllDisplays() const override; |
57 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override; | 56 display::Display GetDisplayNearestWindow(gfx::NativeView view) const override; |
58 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override; | 57 display::Display GetDisplayNearestPoint( |
59 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override; | 58 const gfx::Point& point) const override; |
60 gfx::Display GetPrimaryDisplay() const override; | 59 display::Display GetDisplayMatching( |
61 void AddObserver(gfx::DisplayObserver* observer) override; | 60 const gfx::Rect& match_rect) const override; |
62 void RemoveObserver(gfx::DisplayObserver* observer) override; | 61 display::Display GetPrimaryDisplay() const override; |
| 62 void AddObserver(display::DisplayObserver* observer) override; |
| 63 void RemoveObserver(display::DisplayObserver* observer) override; |
63 | 64 |
64 private: | 65 private: |
65 explicit TestScreen(const gfx::Rect& screen_bounds); | 66 explicit TestScreen(const gfx::Rect& screen_bounds); |
66 | 67 |
67 aura::WindowTreeHost* host_; | 68 aura::WindowTreeHost* host_; |
68 | 69 |
69 gfx::Display display_; | 70 display::Display display_; |
70 | 71 |
71 float ui_scale_; | 72 float ui_scale_; |
72 | 73 |
73 DISALLOW_COPY_AND_ASSIGN(TestScreen); | 74 DISALLOW_COPY_AND_ASSIGN(TestScreen); |
74 }; | 75 }; |
75 | 76 |
76 } // namespace aura | 77 } // namespace aura |
77 | 78 |
78 #endif // UI_AURA_TEST_TEST_SCREEN_H_ | 79 #endif // UI_AURA_TEST_TEST_SCREEN_H_ |
OLD | NEW |