| 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(int64_t id, int32_t* cursor_id_storage) | 30 explicit TestPlatformDisplay(int64_t id, |
| 31 : id_(id), cursor_id_storage_(cursor_id_storage) { | 31 bool is_primary, |
| 32 int32_t* cursor_id_storage) |
| 33 : id_(id), |
| 34 is_primary_(is_primary), |
| 35 cursor_id_storage_(cursor_id_storage) { |
| 32 display_metrics_.bounds = gfx::Rect(0, 0, 400, 300); | 36 display_metrics_.bounds = gfx::Rect(0, 0, 400, 300); |
| 33 display_metrics_.device_scale_factor = 1.f; | 37 display_metrics_.device_scale_factor = 1.f; |
| 34 } | 38 } |
| 35 ~TestPlatformDisplay() override {} | 39 ~TestPlatformDisplay() override {} |
| 36 | 40 |
| 37 // PlatformDisplay: | 41 // PlatformDisplay: |
| 38 void Init(PlatformDisplayDelegate* delegate) override { | 42 void Init(PlatformDisplayDelegate* delegate) override { |
| 39 // It is necessary to tell the delegate about the ViewportMetrics to make | 43 // It is necessary to tell the delegate about the ViewportMetrics to make |
| 40 // sure that the DisplayBinding is correctly initialized (and a root-window | 44 // sure that the DisplayBinding is correctly initialized (and a root-window |
| 41 // is created). | 45 // is created). |
| (...skipping 12 matching lines...) Expand all Loading... |
| 54 } | 58 } |
| 55 float GetDeviceScaleFactor() override { | 59 float GetDeviceScaleFactor() override { |
| 56 return display_metrics_.device_scale_factor; | 60 return display_metrics_.device_scale_factor; |
| 57 } | 61 } |
| 58 void UpdateTextInputState(const ui::TextInputState& state) override {} | 62 void UpdateTextInputState(const ui::TextInputState& state) override {} |
| 59 void SetImeVisibility(bool visible) override {} | 63 void SetImeVisibility(bool visible) override {} |
| 60 bool IsFramePending() const override { return false; } | 64 bool IsFramePending() const override { return false; } |
| 61 void RequestCopyOfOutput( | 65 void RequestCopyOfOutput( |
| 62 std::unique_ptr<cc::CopyOutputRequest> output_request) override {} | 66 std::unique_ptr<cc::CopyOutputRequest> output_request) override {} |
| 63 gfx::Rect GetBounds() const override { return display_metrics_.bounds; } | 67 gfx::Rect GetBounds() const override { return display_metrics_.bounds; } |
| 68 bool IsPrimaryDisplay() const override { return is_primary_; } |
| 64 | 69 |
| 65 private: | 70 private: |
| 66 ViewportMetrics display_metrics_; | 71 ViewportMetrics display_metrics_; |
| 67 | 72 |
| 68 int64_t id_; | 73 int64_t id_; |
| 74 bool is_primary_; |
| 69 int32_t* cursor_id_storage_; | 75 int32_t* cursor_id_storage_; |
| 70 | 76 |
| 71 DISALLOW_COPY_AND_ASSIGN(TestPlatformDisplay); | 77 DISALLOW_COPY_AND_ASSIGN(TestPlatformDisplay); |
| 72 }; | 78 }; |
| 73 | 79 |
| 74 ClientWindowId NextUnusedClientWindowId(WindowTree* tree) { | 80 ClientWindowId NextUnusedClientWindowId(WindowTree* tree) { |
| 75 ClientWindowId client_id; | 81 ClientWindowId client_id; |
| 76 for (ClientSpecificId id = 1;; ++id) { | 82 for (ClientSpecificId id = 1;; ++id) { |
| 77 // Used the id of the client in the upper bits to simplify things. | 83 // Used the id of the client in the upper bits to simplify things. |
| 78 const ClientWindowId client_id = | 84 const ClientWindowId client_id = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 97 ~WindowManagerWindowTreeFactorySetTestApi() {} | 103 ~WindowManagerWindowTreeFactorySetTestApi() {} |
| 98 | 104 |
| 99 void WindowManagerWindowTreeFactorySetTestApi::Add(const UserId& user_id) { | 105 void WindowManagerWindowTreeFactorySetTestApi::Add(const UserId& user_id) { |
| 100 WindowManagerWindowTreeFactory* factory = | 106 WindowManagerWindowTreeFactory* factory = |
| 101 window_manager_window_tree_factory_set_->Add(user_id, nullptr); | 107 window_manager_window_tree_factory_set_->Add(user_id, nullptr); |
| 102 factory->CreateWindowTree(nullptr, nullptr); | 108 factory->CreateWindowTree(nullptr, nullptr); |
| 103 } | 109 } |
| 104 | 110 |
| 105 // TestPlatformDisplayFactory ------------------------------------------------- | 111 // TestPlatformDisplayFactory ------------------------------------------------- |
| 106 | 112 |
| 113 const int64_t TestPlatformDisplayFactory::kFirstDisplayId = 1; |
| 114 |
| 107 TestPlatformDisplayFactory::TestPlatformDisplayFactory( | 115 TestPlatformDisplayFactory::TestPlatformDisplayFactory( |
| 108 int32_t* cursor_id_storage) | 116 int32_t* cursor_id_storage) |
| 109 : cursor_id_storage_(cursor_id_storage) {} | 117 : cursor_id_storage_(cursor_id_storage), |
| 118 next_display_id_(kFirstDisplayId) {} |
| 110 | 119 |
| 111 TestPlatformDisplayFactory::~TestPlatformDisplayFactory() {} | 120 TestPlatformDisplayFactory::~TestPlatformDisplayFactory() {} |
| 112 | 121 |
| 113 PlatformDisplay* TestPlatformDisplayFactory::CreatePlatformDisplay() { | 122 PlatformDisplay* TestPlatformDisplayFactory::CreatePlatformDisplay() { |
| 114 return new TestPlatformDisplay(next_display_id_++, cursor_id_storage_); | 123 bool is_primary = (next_display_id_ == kFirstDisplayId); |
| 124 return new TestPlatformDisplay(next_display_id_++, is_primary, |
| 125 cursor_id_storage_); |
| 115 } | 126 } |
| 116 | 127 |
| 117 // TestFrameGeneratorDelegate ------------------------------------------------- | 128 // TestFrameGeneratorDelegate ------------------------------------------------- |
| 118 | 129 |
| 119 TestFrameGeneratorDelegate::TestFrameGeneratorDelegate( | 130 TestFrameGeneratorDelegate::TestFrameGeneratorDelegate( |
| 120 std::unique_ptr<ServerWindow> root) | 131 std::unique_ptr<ServerWindow> root) |
| 121 : root_(std::move(root)) {} | 132 : root_(std::move(root)) {} |
| 122 | 133 |
| 123 TestFrameGeneratorDelegate::~TestFrameGeneratorDelegate() {} | 134 TestFrameGeneratorDelegate::~TestFrameGeneratorDelegate() {} |
| 124 | 135 |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 return nullptr; | 540 return nullptr; |
| 530 if (!tree->AddWindow(parent_client_id, client_window_id)) | 541 if (!tree->AddWindow(parent_client_id, client_window_id)) |
| 531 return nullptr; | 542 return nullptr; |
| 532 *client_id = client_window_id; | 543 *client_id = client_window_id; |
| 533 return tree->GetWindowByClientId(client_window_id); | 544 return tree->GetWindowByClientId(client_window_id); |
| 534 } | 545 } |
| 535 | 546 |
| 536 } // namespace test | 547 } // namespace test |
| 537 } // namespace ws | 548 } // namespace ws |
| 538 } // namespace ui | 549 } // namespace ui |
| OLD | NEW |