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

Side by Side Diff: components/mus/ws/test_change_tracker.cc

Issue 1909733002: mus: Add EventObserver to allow passively listening to UI events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 "components/mus/ws/test_change_tracker.h" 5 #include "components/mus/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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 case CHANGE_TYPE_NODE_VISIBILITY_CHANGED: 102 case CHANGE_TYPE_NODE_VISIBILITY_CHANGED:
103 return base::StringPrintf("VisibilityChanged window=%s visible=%s", 103 return base::StringPrintf("VisibilityChanged window=%s visible=%s",
104 WindowIdToString(change.window_id).c_str(), 104 WindowIdToString(change.window_id).c_str(),
105 change.bool_value ? "true" : "false"); 105 change.bool_value ? "true" : "false");
106 106
107 case CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED: 107 case CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED:
108 return base::StringPrintf("DrawnStateChanged window=%s drawn=%s", 108 return base::StringPrintf("DrawnStateChanged window=%s drawn=%s",
109 WindowIdToString(change.window_id).c_str(), 109 WindowIdToString(change.window_id).c_str(),
110 change.bool_value ? "true" : "false"); 110 change.bool_value ? "true" : "false");
111 111
112 case CHANGE_TYPE_INPUT_EVENT: 112 case CHANGE_TYPE_INPUT_EVENT: {
113 return base::StringPrintf("InputEvent window=%s event_action=%d", 113 std::string result = base::StringPrintf(
114 WindowIdToString(change.window_id).c_str(), 114 "InputEvent window=%s event_action=%d",
115 change.event_action); 115 WindowIdToString(change.window_id).c_str(), change.event_action);
116 if (change.event_observer_id != 0)
117 base::StringAppendF(&result, " event_observer_id=%u",
118 change.event_observer_id);
119 return result;
120 }
121
122 case CHANGE_TYPE_EVENT_OBSERVED:
123 return base::StringPrintf(
124 "EventObserved event_action=%d event_observer_id=%u",
125 change.event_action, change.event_observer_id);
116 126
117 case CHANGE_TYPE_PROPERTY_CHANGED: 127 case CHANGE_TYPE_PROPERTY_CHANGED:
118 return base::StringPrintf("PropertyChanged window=%s key=%s value=%s", 128 return base::StringPrintf("PropertyChanged window=%s key=%s value=%s",
119 WindowIdToString(change.window_id).c_str(), 129 WindowIdToString(change.window_id).c_str(),
120 change.property_key.c_str(), 130 change.property_key.c_str(),
121 change.property_value.c_str()); 131 change.property_value.c_str());
122 132
123 case CHANGE_TYPE_FOCUSED: 133 case CHANGE_TYPE_FOCUSED:
124 return base::StringPrintf("Focused id=%s", 134 return base::StringPrintf("Focused id=%s",
125 WindowIdToString(change.window_id).c_str()); 135 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])); 219 test_windows->push_back(WindowDataToTestWindow(data[i]));
210 } 220 }
211 221
212 Change::Change() 222 Change::Change()
213 : type(CHANGE_TYPE_EMBED), 223 : type(CHANGE_TYPE_EMBED),
214 connection_id(0), 224 connection_id(0),
215 window_id(0), 225 window_id(0),
216 window_id2(0), 226 window_id2(0),
217 window_id3(0), 227 window_id3(0),
218 event_action(0), 228 event_action(0),
229 event_observer_id(0u),
219 direction(mojom::OrderDirection::ABOVE), 230 direction(mojom::OrderDirection::ABOVE),
220 bool_value(false), 231 bool_value(false),
232 float_value(0.f),
233 cursor_id(0),
221 change_id(0u) {} 234 change_id(0u) {}
222 235
223 Change::Change(const Change& other) = default; 236 Change::Change(const Change& other) = default;
224 237
225 Change::~Change() {} 238 Change::~Change() {}
226 239
227 TestChangeTracker::TestChangeTracker() : delegate_(NULL) {} 240 TestChangeTracker::TestChangeTracker() : delegate_(NULL) {}
228 241
229 TestChangeTracker::~TestChangeTracker() {} 242 TestChangeTracker::~TestChangeTracker() {}
230 243
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 void TestChangeTracker::OnWindowParentDrawnStateChanged(Id window_id, 368 void TestChangeTracker::OnWindowParentDrawnStateChanged(Id window_id,
356 bool drawn) { 369 bool drawn) {
357 Change change; 370 Change change;
358 change.type = CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED; 371 change.type = CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED;
359 change.window_id = window_id; 372 change.window_id = window_id;
360 change.bool_value = drawn; 373 change.bool_value = drawn;
361 AddChange(change); 374 AddChange(change);
362 } 375 }
363 376
364 void TestChangeTracker::OnWindowInputEvent(Id window_id, 377 void TestChangeTracker::OnWindowInputEvent(Id window_id,
365 mojom::EventPtr event) { 378 mojom::EventPtr event,
379 uint32_t event_observer_id) {
366 Change change; 380 Change change;
367 change.type = CHANGE_TYPE_INPUT_EVENT; 381 change.type = CHANGE_TYPE_INPUT_EVENT;
368 change.window_id = window_id; 382 change.window_id = window_id;
369 change.event_action = static_cast<int32_t>(event->action); 383 change.event_action = static_cast<int32_t>(event->action);
384 change.event_observer_id = event_observer_id;
370 AddChange(change); 385 AddChange(change);
371 } 386 }
372 387
388 void TestChangeTracker::OnEventObserved(mojom::EventPtr event,
389 uint32_t event_observer_id) {
390 Change change;
391 change.type = CHANGE_TYPE_EVENT_OBSERVED;
392 change.event_action = static_cast<int32_t>(event->action);
393 change.event_observer_id = event_observer_id;
394 AddChange(change);
395 }
396
373 void TestChangeTracker::OnWindowSharedPropertyChanged(Id window_id, 397 void TestChangeTracker::OnWindowSharedPropertyChanged(Id window_id,
374 String name, 398 String name,
375 Array<uint8_t> data) { 399 Array<uint8_t> data) {
376 Change change; 400 Change change;
377 change.type = CHANGE_TYPE_PROPERTY_CHANGED; 401 change.type = CHANGE_TYPE_PROPERTY_CHANGED;
378 change.window_id = window_id; 402 change.window_id = window_id;
379 change.property_key = name; 403 change.property_key = name;
380 if (data.is_null()) 404 if (data.is_null())
381 change.property_value = "NULL"; 405 change.property_value = "NULL";
382 else 406 else
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 464
441 std::string TestWindow::ToString2() const { 465 std::string TestWindow::ToString2() const {
442 return base::StringPrintf( 466 return base::StringPrintf(
443 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(), 467 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(),
444 WindowIdToString(parent_id).c_str(), visible ? "true" : "false"); 468 WindowIdToString(parent_id).c_str(), visible ? "true" : "false");
445 } 469 }
446 470
447 } // namespace ws 471 } // namespace ws
448 472
449 } // namespace mus 473 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698