OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 #include "ui/android/screen_android_for_tests.h" |
| 6 #include "ui/display/display.h" |
| 7 #include "ui/display/screen.h" |
| 8 |
| 9 namespace ui { |
| 10 |
| 11 using display::Display; |
| 12 using display::DisplayObserver; |
| 13 |
| 14 // A Screen for Android unit tests that do not talk to Java. The class contains |
| 15 // one primary display with default Display configuration and 256x512 dip size. |
| 16 class DummyScreenAndroid : public display::Screen { |
| 17 public: |
| 18 DummyScreenAndroid() {} |
| 19 ~DummyScreenAndroid() override {} |
| 20 |
| 21 // Screen interface. |
| 22 |
| 23 gfx::Point GetCursorScreenPoint() override { return gfx::Point(); } |
| 24 |
| 25 bool IsWindowUnderCursor(gfx::NativeWindow window) override { return false; } |
| 26 |
| 27 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override { |
| 28 return NULL; |
| 29 } |
| 30 |
| 31 int GetNumDisplays() const override { return 1; } |
| 32 |
| 33 std::vector<Display> GetAllDisplays() const override { |
| 34 return std::vector<Display>(1, GetPrimaryDisplay()); |
| 35 } |
| 36 |
| 37 Display GetDisplayNearestWindow(gfx::NativeView view) const override { |
| 38 return GetPrimaryDisplay(); |
| 39 } |
| 40 |
| 41 Display GetDisplayNearestPoint(const gfx::Point& point) const override { |
| 42 return GetPrimaryDisplay(); |
| 43 } |
| 44 |
| 45 Display GetDisplayMatching(const gfx::Rect& match_rect) const override { |
| 46 return GetPrimaryDisplay(); |
| 47 } |
| 48 |
| 49 Display GetPrimaryDisplay() const override { |
| 50 const int display_id = 0; |
| 51 const gfx::Rect bounds_in_dip(256, 512); |
| 52 return display::Display(display_id, bounds_in_dip); |
| 53 } |
| 54 |
| 55 void AddObserver(DisplayObserver* observer) override {} |
| 56 void RemoveObserver(DisplayObserver* observer) override {} |
| 57 }; |
| 58 |
| 59 display::Screen* CreateScreenAndroidForTests() { |
| 60 return new DummyScreenAndroid; |
| 61 } |
| 62 |
| 63 } // namespace ui |
OLD | NEW |