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