| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "services/ui/ws/test_utils.h" | 5 #include "services/ui/ws/test_utils.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
| 11 #include "services/shell/public/interfaces/connector.mojom.h" | 11 #include "services/shell/public/interfaces/connector.mojom.h" |
| 12 #include "services/ui/surfaces/surfaces_state.h" | 12 #include "services/ui/surfaces/surfaces_state.h" |
| 13 #include "services/ui/ws/display_binding.h" | 13 #include "services/ui/ws/display_binding.h" |
| 14 #include "services/ui/ws/display_manager.h" | 14 #include "services/ui/ws/display_manager.h" |
| 15 #include "services/ui/ws/platform_display_init_params.h" | 15 #include "services/ui/ws/platform_display_init_params.h" |
| 16 #include "services/ui/ws/server_window_surface_manager_test_api.h" | 16 #include "services/ui/ws/server_window_surface_manager_test_api.h" |
| 17 #include "services/ui/ws/window_manager_access_policy.h" | 17 #include "services/ui/ws/window_manager_access_policy.h" |
| 18 #include "services/ui/ws/window_manager_window_tree_factory.h" | 18 #include "services/ui/ws/window_manager_window_tree_factory.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace ui { | 21 namespace ui { |
| 22 namespace ws { | 22 namespace ws { |
| 23 namespace test { | 23 namespace test { |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // ----------------------------------------------------------------------------- | 26 // ----------------------------------------------------------------------------- |
| 27 // Empty implementation of PlatformDisplay. | 27 // Empty implementation of PlatformDisplay. |
| 28 class TestPlatformDisplay : public PlatformDisplay { | 28 class TestPlatformDisplay : public PlatformDisplay { |
| 29 public: | 29 public: |
| 30 explicit TestPlatformDisplay(int32_t* cursor_id_storage) | 30 explicit TestPlatformDisplay(int64_t id, int32_t* cursor_id_storage) |
| 31 : cursor_id_storage_(cursor_id_storage) { | 31 : id_(id), cursor_id_storage_(cursor_id_storage) { |
| 32 display_metrics_.bounds = gfx::Rect(0, 0, 400, 300); | 32 display_metrics_.bounds = gfx::Rect(0, 0, 400, 300); |
| 33 display_metrics_.device_scale_factor = 1.f; | 33 display_metrics_.device_scale_factor = 1.f; |
| 34 } | 34 } |
| 35 ~TestPlatformDisplay() override {} | 35 ~TestPlatformDisplay() override {} |
| 36 | 36 |
| 37 // PlatformDisplay: | 37 // PlatformDisplay: |
| 38 void Init(PlatformDisplayDelegate* delegate) override { | 38 void Init(PlatformDisplayDelegate* delegate) override { |
| 39 // It is necessary to tell the delegate about the ViewportMetrics to make | 39 // It is necessary to tell the delegate about the ViewportMetrics to make |
| 40 // sure that the DisplayBinding is correctly initialized (and a root-window | 40 // sure that the DisplayBinding is correctly initialized (and a root-window |
| 41 // is created). | 41 // is created). |
| 42 delegate->OnViewportMetricsChanged(ViewportMetrics(), display_metrics_); | 42 delegate->OnViewportMetricsChanged(ViewportMetrics(), display_metrics_); |
| 43 } | 43 } |
| 44 int64_t GetId() const override { return id_; } |
| 44 void SchedulePaint(const ServerWindow* window, | 45 void SchedulePaint(const ServerWindow* window, |
| 45 const gfx::Rect& bounds) override {} | 46 const gfx::Rect& bounds) override {} |
| 46 void SetViewportSize(const gfx::Size& size) override {} | 47 void SetViewportSize(const gfx::Size& size) override {} |
| 47 void SetTitle(const base::string16& title) override {} | 48 void SetTitle(const base::string16& title) override {} |
| 48 void SetCapture() override {} | 49 void SetCapture() override {} |
| 49 void ReleaseCapture() override {} | 50 void ReleaseCapture() override {} |
| 50 void SetCursorById(int32_t cursor) override { *cursor_id_storage_ = cursor; } | 51 void SetCursorById(int32_t cursor) override { *cursor_id_storage_ = cursor; } |
| 51 ::display::Display::Rotation GetRotation() override { | 52 ::display::Display::Rotation GetRotation() override { |
| 52 return ::display::Display::Rotation::ROTATE_0; | 53 return ::display::Display::Rotation::ROTATE_0; |
| 53 } | 54 } |
| 54 float GetDeviceScaleFactor() override { | 55 float GetDeviceScaleFactor() override { |
| 55 return display_metrics_.device_scale_factor; | 56 return display_metrics_.device_scale_factor; |
| 56 } | 57 } |
| 57 void UpdateTextInputState(const ui::TextInputState& state) override {} | 58 void UpdateTextInputState(const ui::TextInputState& state) override {} |
| 58 void SetImeVisibility(bool visible) override {} | 59 void SetImeVisibility(bool visible) override {} |
| 59 bool IsFramePending() const override { return false; } | 60 bool IsFramePending() const override { return false; } |
| 60 void RequestCopyOfOutput( | 61 void RequestCopyOfOutput( |
| 61 std::unique_ptr<cc::CopyOutputRequest> output_request) override {} | 62 std::unique_ptr<cc::CopyOutputRequest> output_request) override {} |
| 62 int64_t GetDisplayId() const override { return 1; } | |
| 63 gfx::Rect GetBounds() const override { return display_metrics_.bounds; } | 63 gfx::Rect GetBounds() const override { return display_metrics_.bounds; } |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 ViewportMetrics display_metrics_; | 66 ViewportMetrics display_metrics_; |
| 67 | 67 |
| 68 int64_t id_; |
| 68 int32_t* cursor_id_storage_; | 69 int32_t* cursor_id_storage_; |
| 69 | 70 |
| 70 DISALLOW_COPY_AND_ASSIGN(TestPlatformDisplay); | 71 DISALLOW_COPY_AND_ASSIGN(TestPlatformDisplay); |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 ClientWindowId NextUnusedClientWindowId(WindowTree* tree) { | 74 ClientWindowId NextUnusedClientWindowId(WindowTree* tree) { |
| 74 ClientWindowId client_id; | 75 ClientWindowId client_id; |
| 75 for (ClientSpecificId id = 1;; ++id) { | 76 for (ClientSpecificId id = 1;; ++id) { |
| 76 // Used the id of the client in the upper bits to simplify things. | 77 // Used the id of the client in the upper bits to simplify things. |
| 77 const ClientWindowId client_id = | 78 const ClientWindowId client_id = |
| (...skipping 25 matching lines...) Expand all Loading... |
| 103 | 104 |
| 104 // TestPlatformDisplayFactory ------------------------------------------------- | 105 // TestPlatformDisplayFactory ------------------------------------------------- |
| 105 | 106 |
| 106 TestPlatformDisplayFactory::TestPlatformDisplayFactory( | 107 TestPlatformDisplayFactory::TestPlatformDisplayFactory( |
| 107 int32_t* cursor_id_storage) | 108 int32_t* cursor_id_storage) |
| 108 : cursor_id_storage_(cursor_id_storage) {} | 109 : cursor_id_storage_(cursor_id_storage) {} |
| 109 | 110 |
| 110 TestPlatformDisplayFactory::~TestPlatformDisplayFactory() {} | 111 TestPlatformDisplayFactory::~TestPlatformDisplayFactory() {} |
| 111 | 112 |
| 112 PlatformDisplay* TestPlatformDisplayFactory::CreatePlatformDisplay() { | 113 PlatformDisplay* TestPlatformDisplayFactory::CreatePlatformDisplay() { |
| 113 return new TestPlatformDisplay(cursor_id_storage_); | 114 return new TestPlatformDisplay(next_display_id_++, cursor_id_storage_); |
| 114 } | 115 } |
| 115 | 116 |
| 116 // TestFrameGeneratorDelegate ------------------------------------------------- | 117 // TestFrameGeneratorDelegate ------------------------------------------------- |
| 117 | 118 |
| 118 TestFrameGeneratorDelegate::TestFrameGeneratorDelegate( | 119 TestFrameGeneratorDelegate::TestFrameGeneratorDelegate( |
| 119 std::unique_ptr<ServerWindow> root) | 120 std::unique_ptr<ServerWindow> root) |
| 120 : root_(std::move(root)) {} | 121 : root_(std::move(root)) {} |
| 121 | 122 |
| 122 TestFrameGeneratorDelegate::~TestFrameGeneratorDelegate() {} | 123 TestFrameGeneratorDelegate::~TestFrameGeneratorDelegate() {} |
| 123 | 124 |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 return nullptr; | 524 return nullptr; |
| 524 if (!tree->AddWindow(parent_client_id, client_window_id)) | 525 if (!tree->AddWindow(parent_client_id, client_window_id)) |
| 525 return nullptr; | 526 return nullptr; |
| 526 *client_id = client_window_id; | 527 *client_id = client_window_id; |
| 527 return tree->GetWindowByClientId(client_window_id); | 528 return tree->GetWindowByClientId(client_window_id); |
| 528 } | 529 } |
| 529 | 530 |
| 530 } // namespace test | 531 } // namespace test |
| 531 } // namespace ws | 532 } // namespace ws |
| 532 } // namespace ui | 533 } // namespace ui |
| OLD | NEW |