test_screen.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2015 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. #ifndef UI_DISPLAY_TEST_TEST_SCREEN_H_
  5. #define UI_DISPLAY_TEST_TEST_SCREEN_H_
  6. #include "ui/display/display.h"
  7. #include "ui/display/screen_base.h"
  8. namespace display {
  9. namespace test {
  10. // A dummy implementation of Screen that contains a single
  11. // Display only. The contained Display can be accessed and modified via
  12. // TestScreen::display().
  13. //
  14. // NOTE: Adding and removing DisplayOberver's are no-ops and observers
  15. // will NOT be notified ever.
  16. class TestScreen : public ScreenBase {
  17. public:
  18. static constexpr gfx::Rect kDefaultScreenBounds = gfx::Rect(0, 0, 800, 600);
  19. static TestScreen* Get();
  20. // TODO(weili): Split this into a protected no-argument constructor for
  21. // subclass uses and the public one with gfx::Size argument.
  22. explicit TestScreen(bool create_display = true);
  23. TestScreen(const TestScreen&) = delete;
  24. TestScreen& operator=(const TestScreen&) = delete;
  25. ~TestScreen() override;
  26. // Sets the fake cursor location for the TestScreen.
  27. void set_cursor_screen_point(const gfx::Point& point);
  28. // ScreenBase:
  29. gfx::Point GetCursorScreenPoint() override;
  30. bool IsWindowUnderCursor(gfx::NativeWindow window) override;
  31. gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override;
  32. Display GetDisplayNearestWindow(gfx::NativeWindow window) const override;
  33. void SetCursorScreenPointForTesting(const gfx::Point& point) override;
  34. private:
  35. gfx::Point cursor_screen_point_;
  36. };
  37. } // namespace test
  38. } // namespace display
  39. #endif // UI_DISPLAY_TEST_TEST_SCREEN_H_