Home | History | Annotate | Download | only in test
      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 GetWindowAtCursorScreenPoint() OVERRIDE;
     51   virtual int GetNumDisplays() OVERRIDE;
     52   virtual gfx::Display GetDisplayNearestWindow(
     53       gfx::NativeView view) const OVERRIDE;
     54   virtual gfx::Display GetDisplayNearestPoint(
     55       const gfx::Point& point) const OVERRIDE;
     56   virtual gfx::Display GetDisplayMatching(
     57       const gfx::Rect& match_rect) const OVERRIDE;
     58   virtual gfx::Display GetPrimaryDisplay() const OVERRIDE;
     59   virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE;
     60   virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE;
     61 
     62  private:
     63   explicit TestScreen(const gfx::Rect& screen_bounds);
     64 
     65   aura::RootWindow* root_window_;
     66 
     67   gfx::Display display_;
     68 
     69   float ui_scale_;
     70 
     71   DISALLOW_COPY_AND_ASSIGN(TestScreen);
     72 };
     73 
     74 }  // namespace aura
     75 
     76 #endif  // UI_AURA_TEST_TEST_SCREEN_H_
     77