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" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // Used the id of the client in the upper bits to simplify things. | 79 // Used the id of the client in the upper bits to simplify things. |
80 const ClientWindowId client_id = | 80 const ClientWindowId client_id = |
81 ClientWindowId(WindowIdToTransportId(WindowId(tree->id(), id))); | 81 ClientWindowId(WindowIdToTransportId(WindowId(tree->id(), id))); |
82 if (!tree->GetWindowByClientId(client_id)) | 82 if (!tree->GetWindowByClientId(client_id)) |
83 return client_id; | 83 return client_id; |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 } // namespace | 87 } // namespace |
88 | 88 |
89 // TestPlatformScreen ------------------------------------------------- | 89 // TestScreenManager ------------------------------------------------- |
90 | 90 |
91 TestPlatformScreen::TestPlatformScreen() {} | 91 TestScreenManager::TestScreenManager() {} |
92 | 92 |
93 TestPlatformScreen::~TestPlatformScreen() {} | 93 TestScreenManager::~TestScreenManager() {} |
94 | 94 |
95 int64_t TestPlatformScreen::AddDisplay() { | 95 int64_t TestScreenManager::AddDisplay() { |
96 return AddDisplay(MakeViewportMetrics(0, 0, 100, 100, 1.0f)); | 96 return AddDisplay(MakeViewportMetrics(0, 0, 100, 100, 1.0f)); |
97 } | 97 } |
98 | 98 |
99 int64_t TestPlatformScreen::AddDisplay( | 99 int64_t TestScreenManager::AddDisplay(const display::ViewportMetrics& metrics) { |
100 const display::ViewportMetrics& metrics) { | |
101 // Generate a unique display id. | 100 // Generate a unique display id. |
102 int64_t display_id = display_ids_.empty() ? 1 : *display_ids_.rbegin() + 1; | 101 int64_t display_id = display_ids_.empty() ? 1 : *display_ids_.rbegin() + 1; |
103 display_ids_.insert(display_id); | 102 display_ids_.insert(display_id); |
104 | 103 |
105 delegate_->OnDisplayAdded(display_id, metrics); | 104 delegate_->OnDisplayAdded(display_id, metrics); |
106 | 105 |
107 // First display added will be the primary display. | 106 // First display added will be the primary display. |
108 if (primary_display_id_ == display::kInvalidDisplayId) { | 107 if (primary_display_id_ == display::kInvalidDisplayId) { |
109 primary_display_id_ = display_id; | 108 primary_display_id_ = display_id; |
110 delegate_->OnPrimaryDisplayChanged(display_id); | 109 delegate_->OnPrimaryDisplayChanged(display_id); |
111 } | 110 } |
112 | 111 |
113 return display_id; | 112 return display_id; |
114 } | 113 } |
115 | 114 |
116 void TestPlatformScreen::ModifyDisplay( | 115 void TestScreenManager::ModifyDisplay(int64_t id, |
117 int64_t id, | 116 const display::ViewportMetrics& metrics) { |
118 const display::ViewportMetrics& metrics) { | |
119 DCHECK(display_ids_.count(id) == 1); | 117 DCHECK(display_ids_.count(id) == 1); |
120 delegate_->OnDisplayModified(id, metrics); | 118 delegate_->OnDisplayModified(id, metrics); |
121 } | 119 } |
122 | 120 |
123 void TestPlatformScreen::RemoveDisplay(int64_t id) { | 121 void TestScreenManager::RemoveDisplay(int64_t id) { |
124 DCHECK(display_ids_.count(id) == 1); | 122 DCHECK(display_ids_.count(id) == 1); |
125 delegate_->OnDisplayRemoved(id); | 123 delegate_->OnDisplayRemoved(id); |
126 display_ids_.erase(id); | 124 display_ids_.erase(id); |
127 } | 125 } |
128 | 126 |
129 void TestPlatformScreen::Init(display::PlatformScreenDelegate* delegate) { | 127 void TestScreenManager::Init(display::ScreenManagerDelegate* delegate) { |
130 // Reset | 128 // Reset |
131 delegate_ = delegate; | 129 delegate_ = delegate; |
132 display_ids_.clear(); | 130 display_ids_.clear(); |
133 primary_display_id_ = display::kInvalidDisplayId; | 131 primary_display_id_ = display::kInvalidDisplayId; |
134 } | 132 } |
135 | 133 |
136 int64_t TestPlatformScreen::GetPrimaryDisplayId() const { | 134 int64_t TestScreenManager::GetPrimaryDisplayId() const { |
137 return primary_display_id_; | 135 return primary_display_id_; |
138 } | 136 } |
139 | 137 |
140 // TestPlatformDisplayFactory ------------------------------------------------- | 138 // TestPlatformDisplayFactory ------------------------------------------------- |
141 | 139 |
142 TestPlatformDisplayFactory::TestPlatformDisplayFactory( | 140 TestPlatformDisplayFactory::TestPlatformDisplayFactory( |
143 mojom::Cursor* cursor_storage) | 141 mojom::Cursor* cursor_storage) |
144 : cursor_storage_(cursor_storage) {} | 142 : cursor_storage_(cursor_storage) {} |
145 | 143 |
146 TestPlatformDisplayFactory::~TestPlatformDisplayFactory() {} | 144 TestPlatformDisplayFactory::~TestPlatformDisplayFactory() {} |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 return nullptr; | 624 return nullptr; |
627 if (!tree->AddWindow(parent_client_id, client_window_id)) | 625 if (!tree->AddWindow(parent_client_id, client_window_id)) |
628 return nullptr; | 626 return nullptr; |
629 *client_id = client_window_id; | 627 *client_id = client_window_id; |
630 return tree->GetWindowByClientId(client_window_id); | 628 return tree->GetWindowByClientId(client_window_id); |
631 } | 629 } |
632 | 630 |
633 } // namespace test | 631 } // namespace test |
634 } // namespace ws | 632 } // namespace ws |
635 } // namespace ui | 633 } // namespace ui |
OLD | NEW |