Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: ui/aura/test/mus/test_window_tree.cc

Issue 2445163002: Make aura work with mus (Closed)
Patch Set: NON_EXPORTED_BASE_CLASS Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/aura/test/mus/test_window_tree.h ('k') | ui/aura/test/mus/test_window_tree_client_setup.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/public/cpp/tests/test_window_tree.h" 5 #include "ui/aura/test/mus/test_window_tree.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace ui { 9 namespace aura {
10 10
11 TestWindowTree::TestWindowTree() 11 TestWindowTree::TestWindowTree() {}
12 : got_change_(false), change_id_(0), window_id_(0u) {}
13 12
14 TestWindowTree::~TestWindowTree() {} 13 TestWindowTree::~TestWindowTree() {}
15 14
16 bool TestWindowTree::GetAndClearChangeId(uint32_t* change_id) {
17 if (!got_change_)
18 return false;
19
20 if (change_id)
21 *change_id = change_id_;
22 got_change_ = false;
23 return true;
24 }
25
26 bool TestWindowTree::WasEventAcked(uint32_t event_id) const { 15 bool TestWindowTree::WasEventAcked(uint32_t event_id) const {
27 return acked_events_.count(event_id); 16 return acked_events_.count(event_id);
28 } 17 }
29 18
19 mojo::Array<uint8_t> TestWindowTree::GetLastPropertyValue() {
20 return std::move(last_property_value_);
21 }
22
23 mojo::Map<mojo::String, mojo::Array<uint8_t>>
24 TestWindowTree::GetLastNewWindowProperties() {
25 return std::move(last_new_window_properties_);
26 }
27
28 void TestWindowTree::AckAllChanges() {
29 while (!changes_.empty()) {
30 client_->OnChangeCompleted(changes_[0].id, true);
31 changes_.erase(changes_.begin());
32 }
33 }
34
35 bool TestWindowTree::AckSingleChangeOfType(WindowTreeChangeType type,
36 bool result) {
37 auto match = changes_.end();
38 for (auto iter = changes_.begin(); iter != changes_.end(); ++iter) {
39 if (iter->type == type) {
40 if (match == changes_.end())
41 match = iter;
42 else
43 return false;
44 }
45 }
46 if (match == changes_.end())
47 return false;
48 const uint32_t change_id = match->id;
49 changes_.erase(match);
50 client_->OnChangeCompleted(change_id, result);
51 return true;
52 }
53
54 bool TestWindowTree::AckFirstChangeOfType(WindowTreeChangeType type,
55 bool result) {
56 uint32_t change_id;
57 if (!GetAndRemoveFirstChangeOfType(type, &change_id))
58 return false;
59 client_->OnChangeCompleted(change_id, result);
60 return true;
61 }
62
63 void TestWindowTree::AckAllChangesOfType(WindowTreeChangeType type,
64 bool result) {
65 for (size_t i = 0; i < changes_.size();) {
66 if (changes_[i].type != type) {
67 ++i;
68 continue;
69 }
70 const uint32_t change_id = changes_[i].id;
71 changes_.erase(changes_.begin() + i);
72 client_->OnChangeCompleted(change_id, result);
73 }
74 }
75
76 bool TestWindowTree::GetAndRemoveFirstChangeOfType(WindowTreeChangeType type,
77 uint32_t* change_id) {
78 for (auto iter = changes_.begin(); iter != changes_.end(); ++iter) {
79 if (iter->type != type)
80 continue;
81 *change_id = iter->id;
82 changes_.erase(iter);
83 return true;
84 }
85 return false;
86 }
87
88 void TestWindowTree::OnChangeReceived(uint32_t change_id,
89 WindowTreeChangeType type) {
90 changes_.push_back({type, change_id});
91 }
92
30 void TestWindowTree::NewWindow( 93 void TestWindowTree::NewWindow(
31 uint32_t change_id, 94 uint32_t change_id,
32 uint32_t window_id, 95 uint32_t window_id,
33 mojo::Map<mojo::String, mojo::Array<uint8_t>> properties) {} 96 mojo::Map<mojo::String, mojo::Array<uint8_t>> properties) {
97 last_new_window_properties_ = std::move(properties);
98 OnChangeReceived(change_id, WindowTreeChangeType::NEW_WINDOW);
99 }
34 100
35 void TestWindowTree::NewTopLevelWindow( 101 void TestWindowTree::NewTopLevelWindow(
36 uint32_t change_id, 102 uint32_t change_id,
37 uint32_t window_id, 103 uint32_t window_id,
38 mojo::Map<mojo::String, mojo::Array<uint8_t>> properties) { 104 mojo::Map<mojo::String, mojo::Array<uint8_t>> properties) {
39 got_change_ = true; 105 last_new_window_properties_ = std::move(properties);
40 change_id_ = change_id;
41 window_id_ = window_id; 106 window_id_ = window_id;
107 OnChangeReceived(change_id, WindowTreeChangeType::NEW_TOP_LEVEL);
42 } 108 }
43 109
44 void TestWindowTree::DeleteWindow(uint32_t change_id, uint32_t window_id) {} 110 void TestWindowTree::DeleteWindow(uint32_t change_id, uint32_t window_id) {
111 OnChangeReceived(change_id);
112 }
45 113
46 void TestWindowTree::SetWindowBounds(uint32_t change_id, 114 void TestWindowTree::SetWindowBounds(uint32_t change_id,
47 uint32_t window_id, 115 uint32_t window_id,
48 const gfx::Rect& bounds) { 116 const gfx::Rect& bounds) {
49 got_change_ = true; 117 OnChangeReceived(change_id, WindowTreeChangeType::BOUNDS);
50 change_id_ = change_id;
51 } 118 }
52 119
53 void TestWindowTree::SetClientArea( 120 void TestWindowTree::SetClientArea(
54 uint32_t window_id, 121 uint32_t window_id,
55 const gfx::Insets& insets, 122 const gfx::Insets& insets,
56 mojo::Array<gfx::Rect> additional_client_areas) {} 123 mojo::Array<gfx::Rect> additional_client_areas) {}
57 124
58 void TestWindowTree::SetHitTestMask(uint32_t window_id, 125 void TestWindowTree::SetHitTestMask(uint32_t window_id,
59 const base::Optional<gfx::Rect>& mask) {} 126 const base::Optional<gfx::Rect>& mask) {}
60 127
61 void TestWindowTree::SetCanAcceptDrops(uint32_t window_id, bool accepts_drops) { 128 void TestWindowTree::SetCanAcceptDrops(uint32_t window_id, bool accepts_drops) {
62 } 129 }
63 130
64 void TestWindowTree::SetWindowVisibility(uint32_t change_id, 131 void TestWindowTree::SetWindowVisibility(uint32_t change_id,
65 uint32_t window_id, 132 uint32_t window_id,
66 bool visible) { 133 bool visible) {
67 got_change_ = true; 134 OnChangeReceived(change_id, WindowTreeChangeType::VISIBLE);
68 change_id_ = change_id;
69 } 135 }
70 136
71 void TestWindowTree::SetWindowProperty(uint32_t change_id, 137 void TestWindowTree::SetWindowProperty(uint32_t change_id,
72 uint32_t window_id, 138 uint32_t window_id,
73 const mojo::String& name, 139 const mojo::String& name,
74 mojo::Array<uint8_t> value) { 140 mojo::Array<uint8_t> value) {
75 got_change_ = true; 141 last_property_value_ = std::move(value);
76 change_id_ = change_id; 142 OnChangeReceived(change_id, WindowTreeChangeType::PROPERTY);
77 } 143 }
78 144
79 void TestWindowTree::SetWindowOpacity(uint32_t change_id, 145 void TestWindowTree::SetWindowOpacity(uint32_t change_id,
80 uint32_t window_id, 146 uint32_t window_id,
81 float opacity) { 147 float opacity) {
82 got_change_ = true; 148 OnChangeReceived(change_id);
83 change_id_ = change_id;
84 } 149 }
85 150
86 void TestWindowTree::AttachCompositorFrameSink( 151 void TestWindowTree::AttachCompositorFrameSink(
87 uint32_t window_id, 152 uint32_t window_id,
88 mojom::CompositorFrameSinkType type, 153 ui::mojom::CompositorFrameSinkType type,
89 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> surface, 154 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> surface,
90 cc::mojom::MojoCompositorFrameSinkClientPtr client) {} 155 cc::mojom::MojoCompositorFrameSinkClientPtr client) {}
91 156
157 void TestWindowTree::OnWindowSurfaceDetached(
158 uint32_t window_id,
159 const cc::SurfaceSequence& sequence) {}
160
92 void TestWindowTree::AddWindow(uint32_t change_id, 161 void TestWindowTree::AddWindow(uint32_t change_id,
93 uint32_t parent, 162 uint32_t parent,
94 uint32_t child) {} 163 uint32_t child) {
164 OnChangeReceived(change_id);
165 }
95 166
96 void TestWindowTree::RemoveWindowFromParent(uint32_t change_id, 167 void TestWindowTree::RemoveWindowFromParent(uint32_t change_id,
97 uint32_t window_id) {} 168 uint32_t window_id) {
169 OnChangeReceived(change_id);
170 }
98 171
99 void TestWindowTree::AddTransientWindow(uint32_t change_id, 172 void TestWindowTree::AddTransientWindow(uint32_t change_id,
100 uint32_t window_id, 173 uint32_t window_id,
101 uint32_t transient_window_id) {} 174 uint32_t transient_window_id) {
175 OnChangeReceived(change_id);
176 }
102 177
103 void TestWindowTree::RemoveTransientWindowFromParent( 178 void TestWindowTree::RemoveTransientWindowFromParent(
104 uint32_t change_id, 179 uint32_t change_id,
105 uint32_t transient_window_id) {} 180 uint32_t transient_window_id) {
181 OnChangeReceived(change_id);
182 }
106 183
107 void TestWindowTree::SetModal(uint32_t change_id, uint32_t window_id) { 184 void TestWindowTree::SetModal(uint32_t change_id, uint32_t window_id) {
108 got_change_ = true; 185 OnChangeReceived(change_id);
109 change_id_ = change_id;
110 } 186 }
111 187
112 void TestWindowTree::ReorderWindow(uint32_t change_id, 188 void TestWindowTree::ReorderWindow(uint32_t change_id,
113 uint32_t window_id, 189 uint32_t window_id,
114 uint32_t relative_window_id, 190 uint32_t relative_window_id,
115 mojom::OrderDirection direction) {} 191 ui::mojom::OrderDirection direction) {
192 OnChangeReceived(change_id);
193 }
116 194
117 void TestWindowTree::GetWindowTree(uint32_t window_id, 195 void TestWindowTree::GetWindowTree(uint32_t window_id,
118 const GetWindowTreeCallback& callback) {} 196 const GetWindowTreeCallback& callback) {}
119 197
120 void TestWindowTree::SetCapture(uint32_t change_id, uint32_t window_id) { 198 void TestWindowTree::SetCapture(uint32_t change_id, uint32_t window_id) {
121 got_change_ = true; 199 OnChangeReceived(change_id, WindowTreeChangeType::CAPTURE);
122 change_id_ = change_id;
123 } 200 }
124 201
125 void TestWindowTree::ReleaseCapture(uint32_t change_id, uint32_t window_id) { 202 void TestWindowTree::ReleaseCapture(uint32_t change_id, uint32_t window_id) {
126 got_change_ = true; 203 OnChangeReceived(change_id, WindowTreeChangeType::CAPTURE);
127 change_id_ = change_id;
128 } 204 }
129 205
130 void TestWindowTree::StartPointerWatcher(bool want_moves) {} 206 void TestWindowTree::StartPointerWatcher(bool want_moves) {}
131 207
132 void TestWindowTree::StopPointerWatcher() {} 208 void TestWindowTree::StopPointerWatcher() {}
133 209
134 void TestWindowTree::Embed(uint32_t window_id, 210 void TestWindowTree::Embed(uint32_t window_id,
135 mojom::WindowTreeClientPtr client, 211 ui::mojom::WindowTreeClientPtr client,
136 uint32_t flags, 212 uint32_t flags,
137 const EmbedCallback& callback) {} 213 const EmbedCallback& callback) {}
138 214
139 void TestWindowTree::SetFocus(uint32_t change_id, uint32_t window_id) { 215 void TestWindowTree::SetFocus(uint32_t change_id, uint32_t window_id) {
140 got_change_ = true; 216 OnChangeReceived(change_id, WindowTreeChangeType::FOCUS);
141 change_id_ = change_id;
142 } 217 }
143 218
144 void TestWindowTree::SetCanFocus(uint32_t window_id, bool can_focus) {} 219 void TestWindowTree::SetCanFocus(uint32_t window_id, bool can_focus) {}
145 220
146 void TestWindowTree::SetCanAcceptEvents(uint32_t window_id, 221 void TestWindowTree::SetCanAcceptEvents(uint32_t window_id,
147 bool can_accept_events) {} 222 bool can_accept_events) {}
148 223
149 void TestWindowTree::SetPredefinedCursor(uint32_t change_id, 224 void TestWindowTree::SetPredefinedCursor(uint32_t change_id,
150 uint32_t window_id, 225 uint32_t window_id,
151 ui::mojom::Cursor cursor_id) {} 226 ui::mojom::Cursor cursor_id) {
227 OnChangeReceived(change_id);
228 }
152 229
153 void TestWindowTree::SetWindowTextInputState(uint32_t window_id, 230 void TestWindowTree::SetWindowTextInputState(uint32_t window_id,
154 mojo::TextInputStatePtr state) {} 231 mojo::TextInputStatePtr state) {}
155 232
156 void TestWindowTree::SetImeVisibility(uint32_t window_id, 233 void TestWindowTree::SetImeVisibility(uint32_t window_id,
157 bool visible, 234 bool visible,
158 mojo::TextInputStatePtr state) {} 235 mojo::TextInputStatePtr state) {}
159 236
160 void TestWindowTree::OnWindowInputEventAck(uint32_t event_id, 237 void TestWindowTree::OnWindowInputEventAck(uint32_t event_id,
161 ui::mojom::EventResult result) { 238 ui::mojom::EventResult result) {
162 EXPECT_FALSE(acked_events_.count(event_id)); 239 EXPECT_FALSE(acked_events_.count(event_id));
163 acked_events_.insert(event_id); 240 acked_events_.insert(event_id);
164 } 241 }
165 242
166 void TestWindowTree::GetWindowManagerClient( 243 void TestWindowTree::GetWindowManagerClient(
167 mojo::AssociatedInterfaceRequest<mojom::WindowManagerClient> internal) {} 244 mojo::AssociatedInterfaceRequest<ui::mojom::WindowManagerClient> internal) {
245 }
168 246
169 void TestWindowTree::GetCursorLocationMemory( 247 void TestWindowTree::GetCursorLocationMemory(
170 const GetCursorLocationMemoryCallback& callback) { 248 const GetCursorLocationMemoryCallback& callback) {
171 callback.Run(mojo::ScopedSharedBufferHandle()); 249 callback.Run(mojo::ScopedSharedBufferHandle());
172 } 250 }
173 251
174 void TestWindowTree::PerformDragDrop( 252 void TestWindowTree::PerformDragDrop(
175 uint32_t change_id, 253 uint32_t change_id,
176 uint32_t source_window_id, 254 uint32_t source_window_id,
177 mojo::Map<mojo::String, mojo::Array<uint8_t>> drag_data, 255 mojo::Map<mojo::String, mojo::Array<uint8_t>> drag_data,
178 uint32_t drag_operation) {} 256 uint32_t drag_operation) {
257 OnChangeReceived(change_id);
258 }
179 259
180 void TestWindowTree::CancelDragDrop(uint32_t window_id) {} 260 void TestWindowTree::CancelDragDrop(uint32_t window_id) {}
181 261
182 void TestWindowTree::PerformWindowMove(uint32_t change_id, 262 void TestWindowTree::PerformWindowMove(uint32_t change_id,
183 uint32_t window_id, 263 uint32_t window_id,
184 mojom::MoveLoopSource source, 264 ui::mojom::MoveLoopSource source,
185 const gfx::Point& cursor_location) {} 265 const gfx::Point& cursor_location) {
266 OnChangeReceived(change_id);
267 }
186 268
187 void TestWindowTree::CancelWindowMove(uint32_t window_id) {} 269 void TestWindowTree::CancelWindowMove(uint32_t window_id) {}
188 270
189 void TestWindowTree::OnWindowSurfaceDetached( 271 } // namespace aura
190 uint32_t window_id,
191 const cc::SurfaceSequence& sequence) {}
192
193 } // namespace ui
OLDNEW
« no previous file with comments | « ui/aura/test/mus/test_window_tree.h ('k') | ui/aura/test/mus/test_window_tree_client_setup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698