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