MD Downloads: prevent search text from overlapping with the cancel search (X)
[chromium-blink-merge.git] / ui / aura / test / test_screen.h
blobf137cd883b8721b83724e352f47f12349517133b
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"
13 namespace gfx {
14 class Insets;
15 class Rect;
16 class Transform;
19 namespace aura {
20 class Window;
21 class WindowTreeHost;
23 // A minimal, testing Aura implementation of gfx::Screen.
24 // TODO(bruthig): Consider extending gfx::test::TestScreen.
25 class TestScreen : public gfx::Screen,
26 public WindowObserver {
27 public:
28 // Creates a gfx::Screen of the specified size. If no size is specified, then
29 // creates a 800x600 screen. |size| is in physical pixels.
30 static TestScreen* Create(const gfx::Size& size);
31 // Creates a TestScreen that uses fullscreen for the display.
32 static TestScreen* CreateFullscreen();
33 ~TestScreen() override;
35 WindowTreeHost* CreateHostForPrimaryDisplay();
37 void SetDeviceScaleFactor(float device_scale_fator);
38 void SetDisplayRotation(gfx::Display::Rotation rotation);
39 void SetUIScale(float ui_scale);
40 void SetWorkAreaInsets(const gfx::Insets& insets);
42 protected:
43 gfx::Transform GetRotationTransform() const;
44 gfx::Transform GetUIScaleTransform() const;
46 // WindowObserver overrides:
47 void OnWindowBoundsChanged(Window* window,
48 const gfx::Rect& old_bounds,
49 const gfx::Rect& new_bounds) override;
50 void OnWindowDestroying(Window* window) override;
52 // gfx::Screen overrides:
53 gfx::Point GetCursorScreenPoint() override;
54 gfx::NativeWindow GetWindowUnderCursor() override;
55 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override;
56 int GetNumDisplays() const override;
57 std::vector<gfx::Display> GetAllDisplays() const override;
58 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override;
59 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override;
60 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override;
61 gfx::Display GetPrimaryDisplay() const override;
62 void AddObserver(gfx::DisplayObserver* observer) override;
63 void RemoveObserver(gfx::DisplayObserver* observer) override;
65 private:
66 explicit TestScreen(const gfx::Rect& screen_bounds);
68 aura::WindowTreeHost* host_;
70 gfx::Display display_;
72 float ui_scale_;
74 DISALLOW_COPY_AND_ASSIGN(TestScreen);
77 } // namespace aura
79 #endif // UI_AURA_TEST_TEST_SCREEN_H_