display_manager_test_api.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #ifndef UI_DISPLAY_TEST_DISPLAY_MANAGER_TEST_API_H_
  5. #define UI_DISPLAY_TEST_DISPLAY_MANAGER_TEST_API_H_
  6. #include <stdint.h>
  7. #include <memory>
  8. #include <string>
  9. #include <vector>
  10. #include "ui/display/display.h"
  11. #include "ui/display/display_export.h"
  12. #include "ui/display/display_layout.h"
  13. #include "ui/display/types/display_constants.h"
  14. namespace gfx {
  15. class Size;
  16. }
  17. namespace display {
  18. class DisplayManager;
  19. class ManagedDisplayInfo;
  20. namespace test {
  21. class DISPLAY_EXPORT DisplayManagerTestApi {
  22. public:
  23. explicit DisplayManagerTestApi(DisplayManager* display_manager);
  24. DisplayManagerTestApi(const DisplayManagerTestApi&) = delete;
  25. DisplayManagerTestApi& operator=(const DisplayManagerTestApi&) = delete;
  26. virtual ~DisplayManagerTestApi();
  27. void set_maximum_display(size_t maximum_display_num) {
  28. maximum_support_display_ = maximum_display_num;
  29. }
  30. void ResetMaximumDisplay();
  31. // Update the display configuration as given in |display_specs|. The format of
  32. // |display_spec| is a list of comma separated spec for each displays. Please
  33. // refer to the comment in |display::ManagedDisplayInfo::CreateFromSpec| for
  34. // the format of the display spec.
  35. void UpdateDisplay(const std::string& display_specs);
  36. // Set the 1st display as an internal display and returns the display Id for
  37. // the internal display.
  38. int64_t SetFirstDisplayAsInternalDisplay();
  39. // Don't update the display when the root window's size was changed.
  40. void DisableChangeDisplayUponHostResize();
  41. // Gets the internal ManagedDisplayInfo for a specific display id.
  42. const ManagedDisplayInfo& GetInternalManagedDisplayInfo(int64_t display_id);
  43. // Sets the touch support for |display_id|.
  44. void SetTouchSupport(int64_t display_id, Display::TouchSupport touch_support);
  45. // Returns a Display object for a secondary display. If multiple displays
  46. // exist, returns a Display object that is next to the current primary
  47. // display in active_display_list_
  48. const Display& GetSecondaryDisplay() const;
  49. private:
  50. friend class ScopedSetInternalDisplayId;
  51. // Sets the display id for internal display and
  52. // update the display mode list if necessary.
  53. void SetInternalDisplayId(int64_t id);
  54. // Indicate the maximum number of displays that chrome device can support.
  55. static size_t maximum_support_display_;
  56. DisplayManager* display_manager_; // not owned
  57. };
  58. class DISPLAY_EXPORT ScopedSetInternalDisplayId {
  59. public:
  60. ScopedSetInternalDisplayId(DisplayManager* test_api, int64_t id);
  61. ScopedSetInternalDisplayId(const ScopedSetInternalDisplayId&) = delete;
  62. ScopedSetInternalDisplayId& operator=(const ScopedSetInternalDisplayId&) =
  63. delete;
  64. ~ScopedSetInternalDisplayId();
  65. };
  66. // Sets the display mode that matches the |resolution| for |display_id|.
  67. DISPLAY_EXPORT bool SetDisplayResolution(DisplayManager* display_manager,
  68. int64_t display_id,
  69. const gfx::Size& resolution);
  70. // Creates the dislpay layout from position and offset for the current
  71. // display list. If you simply want to create a new layout that is
  72. // independent of current displays, use DisplayLayoutBuilder or simply
  73. // create a new DisplayLayout and set display id fields (primary, ids
  74. // in placement) manually.
  75. DISPLAY_EXPORT std::unique_ptr<DisplayLayout> CreateDisplayLayout(
  76. DisplayManager* display_manager,
  77. DisplayPlacement::Position position,
  78. int offset);
  79. // Creates the DisplayIdList from ints.
  80. DISPLAY_EXPORT DisplayIdList CreateDisplayIdList2(int64_t id1, int64_t id2);
  81. // Create the N number of DisplayIdList starting from |start_id},
  82. DISPLAY_EXPORT DisplayIdList CreateDisplayIdListN(int64_t start_id, size_t N);
  83. } // namespace test
  84. } // namespace display
  85. #endif // UI_DISPLAY_TEST_DISPLAY_MANAGER_TEST_API_H_