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 3 // found in the LICENSE file. 4 5 #ifndef UI_AURA_TEST_TEST_SCREEN_H_ 6 #define UI_AURA_TEST_TEST_SCREEN_H_ 7 8 #include "base/compiler_specific.h" 9 #include "ui/aura/window_observer.h" 10 #include "ui/gfx/display.h" 11 #include "ui/gfx/screen.h" 12 13 namespace gfx { 14 class Rect; 15 class Transform; 16 } 17 18 namespace aura { 19 class RootWindow; 20 class Window; 21 22 // A minimal, testing Aura implementation of gfx::Screen. 23 class TestScreen : public gfx::Screen, 24 public WindowObserver { 25 public: 26 static TestScreen* Create(); 27 // Creates a TestScreen that uses fullscreen for the display. 28 static TestScreen* CreateFullscreen(); 29 virtual ~TestScreen(); 30 31 RootWindow* CreateRootWindowForPrimaryDisplay(); 32 33 void SetDeviceScaleFactor(float device_scale_fator); 34 void SetDisplayRotation(gfx::Display::Rotation rotation); 35 void SetUIScale(float ui_scale); 36 37 protected: 38 gfx::Transform GetRotationTransform() const; 39 gfx::Transform GetUIScaleTransform() const; 40 41 // WindowObserver overrides: 42 virtual void OnWindowBoundsChanged(Window* window, 43 const gfx::Rect& old_bounds, 44 const gfx::Rect& new_bounds) OVERRIDE; 45 virtual void OnWindowDestroying(Window* window) OVERRIDE; 46 47 // gfx::Screen overrides: 48 virtual bool IsDIPEnabled() OVERRIDE; 49 virtual gfx::Point GetCursorScreenPoint() OVERRIDE; 50 virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE; 51 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) 52 OVERRIDE; 53 virtual int GetNumDisplays() const OVERRIDE; 54 virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE; 55 virtual gfx::Display GetDisplayNearestWindow( 56 gfx::NativeView view) const OVERRIDE; 57 virtual gfx::Display GetDisplayNearestPoint( 58 const gfx::Point& point) const OVERRIDE; 59 virtual gfx::Display GetDisplayMatching( 60 const gfx::Rect& match_rect) const OVERRIDE; 61 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE; 62 virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE; 63 virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE; 64 65 private: 66 explicit TestScreen(const gfx::Rect& screen_bounds); 67 68 aura::RootWindow* root_window_; 69 70 gfx::Display display_; 71 72 float ui_scale_; 73 74 DISALLOW_COPY_AND_ASSIGN(TestScreen); 75 }; 76 77 } // namespace aura 78 79 #endif // UI_AURA_TEST_TEST_SCREEN_H_ 80