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

Side by Side Diff: services/ui/ws/test_change_tracker.cc

Issue 2125663002: mus: Add watcher for all touch events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Overload copy assignment operator for Change struct. Created 4 years, 5 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_change_tracker.h" 5 #include "services/ui/ws/test_change_tracker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 case CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED: 97 case CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED:
98 return base::StringPrintf("DrawnStateChanged window=%s drawn=%s", 98 return base::StringPrintf("DrawnStateChanged window=%s drawn=%s",
99 WindowIdToString(change.window_id).c_str(), 99 WindowIdToString(change.window_id).c_str(),
100 change.bool_value ? "true" : "false"); 100 change.bool_value ? "true" : "false");
101 101
102 case CHANGE_TYPE_INPUT_EVENT: { 102 case CHANGE_TYPE_INPUT_EVENT: {
103 std::string result = base::StringPrintf( 103 std::string result = base::StringPrintf(
104 "InputEvent window=%s event_action=%d", 104 "InputEvent window=%s event_action=%d",
105 WindowIdToString(change.window_id).c_str(), change.event_action); 105 WindowIdToString(change.window_id).c_str(), change.event_action);
106 if (change.event_observer_id != 0) 106 if (!change.event_observer_ids.is_null() &&
107 base::StringAppendF(&result, " event_observer_id=%u", 107 !change.event_observer_ids.empty()) {
108 change.event_observer_id); 108 for (uint32_t id : change.event_observer_ids) {
109 if (id != 0)
110 base::StringAppendF(&result, " event_observer_id=%u", id);
111 }
112 }
109 return result; 113 return result;
110 } 114 }
111 115
112 case CHANGE_TYPE_EVENT_OBSERVED: 116 case CHANGE_TYPE_EVENT_OBSERVED: {
113 return base::StringPrintf( 117 std::string result = base::StringPrintf(
114 "EventObserved event_action=%d event_observer_id=%u", 118 "EventObserved event_action=%d", change.event_action);
115 change.event_action, change.event_observer_id); 119 for (uint32_t id : change.event_observer_ids) {
120 base::StringAppendF(&result, " event_observer_id=%u", id);
121 }
122 return result;
123 }
116 124
117 case CHANGE_TYPE_PROPERTY_CHANGED: 125 case CHANGE_TYPE_PROPERTY_CHANGED:
118 return base::StringPrintf("PropertyChanged window=%s key=%s value=%s", 126 return base::StringPrintf("PropertyChanged window=%s key=%s value=%s",
119 WindowIdToString(change.window_id).c_str(), 127 WindowIdToString(change.window_id).c_str(),
120 change.property_key.c_str(), 128 change.property_key.c_str(),
121 change.property_value.c_str()); 129 change.property_value.c_str());
122 130
123 case CHANGE_TYPE_FOCUSED: 131 case CHANGE_TYPE_FOCUSED:
124 return base::StringPrintf("Focused id=%s", 132 return base::StringPrintf("Focused id=%s",
125 WindowIdToString(change.window_id).c_str()); 133 WindowIdToString(change.window_id).c_str());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 test_windows->push_back(WindowDataToTestWindow(data[i])); 217 test_windows->push_back(WindowDataToTestWindow(data[i]));
210 } 218 }
211 219
212 Change::Change() 220 Change::Change()
213 : type(CHANGE_TYPE_EMBED), 221 : type(CHANGE_TYPE_EMBED),
214 client_id(0), 222 client_id(0),
215 window_id(0), 223 window_id(0),
216 window_id2(0), 224 window_id2(0),
217 window_id3(0), 225 window_id3(0),
218 event_action(0), 226 event_action(0),
219 event_observer_id(0u),
220 direction(mojom::OrderDirection::ABOVE), 227 direction(mojom::OrderDirection::ABOVE),
221 bool_value(false), 228 bool_value(false),
222 float_value(0.f), 229 float_value(0.f),
223 cursor_id(0), 230 cursor_id(0),
224 change_id(0u) {} 231 change_id(0u) {}
225 232
226 Change::Change(const Change& other) = default; 233 Change::Change(const Change& other) {
234 type = other.type;
235 client_id = other.client_id;
236 windows = other.windows;
237 window_id = other.window_id;
238 window_id2 = other.window_id2;
239 window_id3 = other.window_id3;
240 bounds = other.bounds;
241 bounds2 = other.bounds2;
242 event_action = other.event_action;
243 event_observer_ids = other.event_observer_ids.Clone();
244 embed_url = other.embed_url;
245 direction = other.direction;
246 bool_value = other.bool_value;
247 float_value = other.float_value;
248 property_key = other.property_key;
249 property_value = other.property_value;
250 cursor_id = other.cursor_id;
251 change_id = other.change_id;
252 }
227 253
228 Change::~Change() {} 254 Change::~Change() {}
229 255
256 Change& Change::operator=(Change other) {
257 type = other.type;
258 client_id = other.client_id;
259 windows = other.windows;
260 window_id = other.window_id;
261 window_id2 = other.window_id2;
262 window_id3 = other.window_id3;
263 bounds = other.bounds;
264 bounds2 = other.bounds2;
265 event_action = other.event_action;
266 event_observer_ids = other.event_observer_ids.Clone();
267 embed_url = other.embed_url;
268 direction = other.direction;
269 bool_value = other.bool_value;
270 float_value = other.float_value;
271 property_key = other.property_key;
272 property_value = other.property_value;
273 cursor_id = other.cursor_id;
274 change_id = other.change_id;
275 return *this;
276 }
277
230 TestChangeTracker::TestChangeTracker() : delegate_(NULL) {} 278 TestChangeTracker::TestChangeTracker() : delegate_(NULL) {}
231 279
232 TestChangeTracker::~TestChangeTracker() {} 280 TestChangeTracker::~TestChangeTracker() {}
233 281
234 void TestChangeTracker::OnEmbed(ClientSpecificId client_id, 282 void TestChangeTracker::OnEmbed(ClientSpecificId client_id,
235 mojom::WindowDataPtr root, 283 mojom::WindowDataPtr root,
236 bool drawn) { 284 bool drawn) {
237 Change change; 285 Change change;
238 change.type = CHANGE_TYPE_EMBED; 286 change.type = CHANGE_TYPE_EMBED;
239 change.client_id = client_id; 287 change.client_id = client_id;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 390
343 void TestChangeTracker::OnWindowParentDrawnStateChanged(Id window_id, 391 void TestChangeTracker::OnWindowParentDrawnStateChanged(Id window_id,
344 bool drawn) { 392 bool drawn) {
345 Change change; 393 Change change;
346 change.type = CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED; 394 change.type = CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED;
347 change.window_id = window_id; 395 change.window_id = window_id;
348 change.bool_value = drawn; 396 change.bool_value = drawn;
349 AddChange(change); 397 AddChange(change);
350 } 398 }
351 399
352 void TestChangeTracker::OnWindowInputEvent(Id window_id, 400 void TestChangeTracker::OnWindowInputEvent(
353 const ui::Event& event, 401 Id window_id, const ui::Event& event,
354 uint32_t event_observer_id) { 402 mojo::Array<uint32_t> event_observer_ids) {
355 Change change; 403 Change change;
356 change.type = CHANGE_TYPE_INPUT_EVENT; 404 change.type = CHANGE_TYPE_INPUT_EVENT;
357 change.window_id = window_id; 405 change.window_id = window_id;
358 change.event_action = static_cast<int32_t>(event.type()); 406 change.event_action = static_cast<int32_t>(event.type());
359 change.event_observer_id = event_observer_id; 407 change.event_observer_ids = std::move(event_observer_ids);
360 AddChange(change); 408 AddChange(change);
361 } 409 }
362 410
363 void TestChangeTracker::OnEventObserved(const ui::Event& event, 411 void TestChangeTracker::OnEventObserved(
364 uint32_t event_observer_id) { 412 const ui::Event& event, mojo::Array<uint32_t> event_observer_ids) {
365 Change change; 413 Change change;
366 change.type = CHANGE_TYPE_EVENT_OBSERVED; 414 change.type = CHANGE_TYPE_EVENT_OBSERVED;
367 change.event_action = static_cast<int32_t>(event.type()); 415 change.event_action = static_cast<int32_t>(event.type());
368 change.event_observer_id = event_observer_id; 416 change.event_observer_ids = std::move(event_observer_ids);
369 AddChange(change); 417 AddChange(change);
370 } 418 }
371 419
372 void TestChangeTracker::OnWindowSharedPropertyChanged(Id window_id, 420 void TestChangeTracker::OnWindowSharedPropertyChanged(Id window_id,
373 String name, 421 String name,
374 Array<uint8_t> data) { 422 Array<uint8_t> data) {
375 Change change; 423 Change change;
376 change.type = CHANGE_TYPE_PROPERTY_CHANGED; 424 change.type = CHANGE_TYPE_PROPERTY_CHANGED;
377 change.window_id = window_id; 425 change.window_id = window_id;
378 change.property_key = name; 426 change.property_key = name;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 487
440 std::string TestWindow::ToString2() const { 488 std::string TestWindow::ToString2() const {
441 return base::StringPrintf( 489 return base::StringPrintf(
442 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(), 490 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(),
443 WindowIdToString(parent_id).c_str(), visible ? "true" : "false"); 491 WindowIdToString(parent_id).c_str(), visible ? "true" : "false");
444 } 492 }
445 493
446 } // namespace ws 494 } // namespace ws
447 495
448 } // namespace ui 496 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698