| Index: services/ui/ws/test_utils.h
|
| diff --git a/services/ui/ws/test_utils.h b/services/ui/ws/test_utils.h
|
| index 2a7fcad8114214bf9ca5c810e79f3038b9a1ae54..0d9082db70d62084d40e5c1f390306f6b6dbe3d6 100644
|
| --- a/services/ui/ws/test_utils.h
|
| +++ b/services/ui/ws/test_utils.h
|
| @@ -8,10 +8,13 @@
|
| #include <stdint.h>
|
|
|
| #include <memory>
|
| +#include <set>
|
| #include <vector>
|
|
|
| #include "base/memory/ptr_util.h"
|
| #include "base/message_loop/message_loop.h"
|
| +#include "services/ui/display/platform_screen.h"
|
| +#include "services/ui/display/viewport_metrics.h"
|
| #include "services/ui/public/interfaces/display_manager.mojom.h"
|
| #include "services/ui/public/interfaces/window_tree.mojom.h"
|
| #include "services/ui/ws/display.h"
|
| @@ -30,6 +33,7 @@
|
| #include "services/ui/ws/window_server_delegate.h"
|
| #include "services/ui/ws/window_tree.h"
|
| #include "services/ui/ws/window_tree_binding.h"
|
| +#include "ui/display/display.h"
|
|
|
| namespace ui {
|
| namespace ws {
|
| @@ -37,6 +41,45 @@ namespace test {
|
|
|
| // Collection of utilities useful in creating mus tests.
|
|
|
| +// Test PlatformDisplay instance that allows adding/modifying/removing displays.
|
| +// Tracks display ids to perform some basic verification that no duplicates are
|
| +// added and display was added before being modified or removed. Display ids
|
| +// reset when Init() is called.
|
| +class TestPlatformScreen : public display::PlatformScreen {
|
| + public:
|
| + TestPlatformScreen();
|
| + ~TestPlatformScreen() override;
|
| +
|
| + // Adds a new display with default metrics, generates a unique display id and
|
| + // returns it. Calls OnDisplayAdded() on delegate.
|
| + int64_t AddDisplay();
|
| +
|
| + // Adds a new display with provided |metrics|, generates a unique display id
|
| + // and returns it. Calls OnDisplayAdded() on delegate.
|
| + int64_t AddDisplay(const display::ViewportMetrics& metrics);
|
| +
|
| + // Calls OnDisplayModified() on delegate.
|
| + void ModifyDisplay(int64_t id, const display::ViewportMetrics& metrics);
|
| +
|
| + // Calls OnDisplayRemoved() on delegate.
|
| + void RemoveDisplay(int64_t id);
|
| +
|
| + // display::PlatformScreen:
|
| + void AddInterfaces(service_manager::InterfaceRegistry* registry) override {}
|
| + void Init(display::PlatformScreenDelegate* delegate) override;
|
| + void RequestCloseDisplay(int64_t display_id) override {}
|
| + int64_t GetPrimaryDisplayId() const override;
|
| +
|
| + private:
|
| + display::PlatformScreenDelegate* delegate_;
|
| + int64_t primary_display_id_ = display::Display::kInvalidDisplayID;
|
| + std::set<int64_t> display_ids_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TestPlatformScreen);
|
| +};
|
| +
|
| +// -----------------------------------------------------------------------------
|
| +
|
| class UserDisplayManagerTestApi {
|
| public:
|
| explicit UserDisplayManagerTestApi(UserDisplayManager* udm) : udm_(udm) {}
|
| @@ -243,17 +286,15 @@ class TestDisplayBinding : public DisplayBinding {
|
| // Factory that dispenses TestPlatformDisplays.
|
| class TestPlatformDisplayFactory : public PlatformDisplayFactory {
|
| public:
|
| - static const int64_t kFirstDisplayId;
|
| -
|
| explicit TestPlatformDisplayFactory(mojom::Cursor* cursor_storage);
|
| ~TestPlatformDisplayFactory();
|
|
|
| // PlatformDisplayFactory:
|
| - std::unique_ptr<PlatformDisplay> CreatePlatformDisplay() override;
|
| + std::unique_ptr<PlatformDisplay> CreatePlatformDisplay(
|
| + const PlatformDisplayInitParams& init_params) override;
|
|
|
| private:
|
| mojom::Cursor* cursor_storage_;
|
| - int64_t next_display_id_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(TestPlatformDisplayFactory);
|
| };
|
| @@ -517,11 +558,6 @@ class TestWindowServerDelegate : public WindowServerDelegate {
|
|
|
| bool got_on_no_more_displays() const { return got_on_no_more_displays_; }
|
|
|
| - // Creates |num_displays| displays.
|
| - void CreateDisplays(int num_displays);
|
| -
|
| - Display* AddDisplay();
|
| -
|
| // WindowServerDelegate:
|
| void StartDisplayInit() override;
|
| void OnNoMoreDisplays() override;
|
| @@ -627,6 +663,15 @@ class WindowEventTargetingHelper {
|
| // WindowManagerWindowTreeFactory and associated WindowTree for the WM.
|
| void AddWindowManager(WindowServer* window_server, const UserId& user_id);
|
|
|
| +// Create a new ViewportMetrics object with specified bounds, size and
|
| +// scale factor. Bounds origin, |origin_x| and |origin_y|, are in DIP and bounds
|
| +// size is computed.
|
| +display::ViewportMetrics MakeViewportMetrics(int origin_x,
|
| + int origin_y,
|
| + int width_pixels,
|
| + int height_pixels,
|
| + float scale_factor);
|
| +
|
| // Returns the first and only root of |tree|. If |tree| has zero or more than
|
| // one root returns null.
|
| ServerWindow* FirstRoot(WindowTree* tree);
|
|
|