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.
5 #ifndef UI_AURA_TEST_TEST_SCREEN_H_
6 #define UI_AURA_TEST_TEST_SCREEN_H_
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"
23 // A minimal, testing Aura implementation of gfx::Screen.
24 class TestScreen
: public gfx::Screen
,
25 public WindowObserver
{
27 // Creates a gfx::Screen of the specified size. If no size is specified, then
28 // creates a 800x600 screen. |size| is in physical pixels.
29 static TestScreen
* Create(const gfx::Size
& size
);
30 // Creates a TestScreen that uses fullscreen for the display.
31 static TestScreen
* CreateFullscreen();
32 virtual ~TestScreen();
34 WindowTreeHost
* CreateHostForPrimaryDisplay();
36 void SetDeviceScaleFactor(float device_scale_fator
);
37 void SetDisplayRotation(gfx::Display::Rotation rotation
);
38 void SetUIScale(float ui_scale
);
39 void SetWorkAreaInsets(const gfx::Insets
& insets
);
42 gfx::Transform
GetRotationTransform() const;
43 gfx::Transform
GetUIScaleTransform() const;
45 // WindowObserver overrides:
46 virtual void OnWindowBoundsChanged(Window
* window
,
47 const gfx::Rect
& old_bounds
,
48 const gfx::Rect
& new_bounds
) OVERRIDE
;
49 virtual void OnWindowDestroying(Window
* window
) OVERRIDE
;
51 // gfx::Screen overrides:
52 virtual bool IsDIPEnabled() OVERRIDE
;
53 virtual gfx::Point
GetCursorScreenPoint() OVERRIDE
;
54 virtual gfx::NativeWindow
GetWindowUnderCursor() OVERRIDE
;
55 virtual gfx::NativeWindow
GetWindowAtScreenPoint(const gfx::Point
& point
)
57 virtual int GetNumDisplays() const OVERRIDE
;
58 virtual std::vector
<gfx::Display
> GetAllDisplays() const OVERRIDE
;
59 virtual gfx::Display
GetDisplayNearestWindow(
60 gfx::NativeView view
) const OVERRIDE
;
61 virtual gfx::Display
GetDisplayNearestPoint(
62 const gfx::Point
& point
) const OVERRIDE
;
63 virtual gfx::Display
GetDisplayMatching(
64 const gfx::Rect
& match_rect
) const OVERRIDE
;
65 virtual gfx::Display
GetPrimaryDisplay() const OVERRIDE
;
66 virtual void AddObserver(gfx::DisplayObserver
* observer
) OVERRIDE
;
67 virtual void RemoveObserver(gfx::DisplayObserver
* observer
) OVERRIDE
;
70 explicit TestScreen(const gfx::Rect
& screen_bounds
);
72 aura::WindowTreeHost
* host_
;
74 gfx::Display display_
;
78 DISALLOW_COPY_AND_ASSIGN(TestScreen
);
83 #endif // UI_AURA_TEST_TEST_SCREEN_H_