OLD | NEW |
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 case CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED: | 98 case CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED: |
99 return base::StringPrintf("DrawnStateChanged window=%s drawn=%s", | 99 return base::StringPrintf("DrawnStateChanged window=%s drawn=%s", |
100 WindowIdToString(change.window_id).c_str(), | 100 WindowIdToString(change.window_id).c_str(), |
101 change.bool_value ? "true" : "false"); | 101 change.bool_value ? "true" : "false"); |
102 | 102 |
103 case CHANGE_TYPE_INPUT_EVENT: { | 103 case CHANGE_TYPE_INPUT_EVENT: { |
104 std::string result = base::StringPrintf( | 104 std::string result = base::StringPrintf( |
105 "InputEvent window=%s event_action=%d", | 105 "InputEvent window=%s event_action=%d", |
106 WindowIdToString(change.window_id).c_str(), change.event_action); | 106 WindowIdToString(change.window_id).c_str(), change.event_action); |
107 if (change.pointer_watcher_id != 0) | 107 if (change.matches_pointer_watcher) |
108 base::StringAppendF(&result, " pointer_watcher_id=%u", | 108 result += " matches_pointer_watcher"; |
109 change.pointer_watcher_id); | |
110 return result; | 109 return result; |
111 } | 110 } |
112 | 111 |
113 case CHANGE_TYPE_POINTER_WATCHER_EVENT: | 112 case CHANGE_TYPE_POINTER_WATCHER_EVENT: |
114 return base::StringPrintf( | 113 return base::StringPrintf("PointerWatcherEvent event_action=%d window=%s", |
115 "PointerWatcherEvent event_action=%d pointer_watcher_id=%u window=%s", | 114 change.event_action, |
116 change.event_action, change.pointer_watcher_id, | 115 WindowIdToString(change.window_id).c_str()); |
117 WindowIdToString(change.window_id).c_str()); | |
118 | 116 |
119 case CHANGE_TYPE_PROPERTY_CHANGED: | 117 case CHANGE_TYPE_PROPERTY_CHANGED: |
120 return base::StringPrintf("PropertyChanged window=%s key=%s value=%s", | 118 return base::StringPrintf("PropertyChanged window=%s key=%s value=%s", |
121 WindowIdToString(change.window_id).c_str(), | 119 WindowIdToString(change.window_id).c_str(), |
122 change.property_key.c_str(), | 120 change.property_key.c_str(), |
123 change.property_value.c_str()); | 121 change.property_value.c_str()); |
124 | 122 |
125 case CHANGE_TYPE_FOCUSED: | 123 case CHANGE_TYPE_FOCUSED: |
126 return base::StringPrintf("Focused id=%s", | 124 return base::StringPrintf("Focused id=%s", |
127 WindowIdToString(change.window_id).c_str()); | 125 WindowIdToString(change.window_id).c_str()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 test_windows->push_back(WindowDataToTestWindow(data[i])); | 209 test_windows->push_back(WindowDataToTestWindow(data[i])); |
212 } | 210 } |
213 | 211 |
214 Change::Change() | 212 Change::Change() |
215 : type(CHANGE_TYPE_EMBED), | 213 : type(CHANGE_TYPE_EMBED), |
216 client_id(0), | 214 client_id(0), |
217 window_id(0), | 215 window_id(0), |
218 window_id2(0), | 216 window_id2(0), |
219 window_id3(0), | 217 window_id3(0), |
220 event_action(0), | 218 event_action(0), |
221 pointer_watcher_id(0u), | 219 matches_pointer_watcher(false), |
222 direction(mojom::OrderDirection::ABOVE), | 220 direction(mojom::OrderDirection::ABOVE), |
223 bool_value(false), | 221 bool_value(false), |
224 float_value(0.f), | 222 float_value(0.f), |
225 cursor_id(0), | 223 cursor_id(0), |
226 change_id(0u) {} | 224 change_id(0u) {} |
227 | 225 |
228 Change::Change(const Change& other) = default; | 226 Change::Change(const Change& other) = default; |
229 | 227 |
230 Change::~Change() {} | 228 Change::~Change() {} |
231 | 229 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 bool drawn) { | 346 bool drawn) { |
349 Change change; | 347 Change change; |
350 change.type = CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED; | 348 change.type = CHANGE_TYPE_NODE_DRAWN_STATE_CHANGED; |
351 change.window_id = window_id; | 349 change.window_id = window_id; |
352 change.bool_value = drawn; | 350 change.bool_value = drawn; |
353 AddChange(change); | 351 AddChange(change); |
354 } | 352 } |
355 | 353 |
356 void TestChangeTracker::OnWindowInputEvent(Id window_id, | 354 void TestChangeTracker::OnWindowInputEvent(Id window_id, |
357 const ui::Event& event, | 355 const ui::Event& event, |
358 uint32_t pointer_watcher_id) { | 356 bool matches_pointer_watcher) { |
359 Change change; | 357 Change change; |
360 change.type = CHANGE_TYPE_INPUT_EVENT; | 358 change.type = CHANGE_TYPE_INPUT_EVENT; |
361 change.window_id = window_id; | 359 change.window_id = window_id; |
362 change.event_action = static_cast<int32_t>(event.type()); | 360 change.event_action = static_cast<int32_t>(event.type()); |
363 change.pointer_watcher_id = pointer_watcher_id; | 361 change.matches_pointer_watcher = matches_pointer_watcher; |
364 AddChange(change); | 362 AddChange(change); |
365 } | 363 } |
366 | 364 |
367 void TestChangeTracker::OnPointerEventObserved(const ui::Event& event, | 365 void TestChangeTracker::OnPointerEventObserved(const ui::Event& event, |
368 uint32_t pointer_watcher_id, | |
369 uint32_t window_id) { | 366 uint32_t window_id) { |
370 Change change; | 367 Change change; |
371 change.type = CHANGE_TYPE_POINTER_WATCHER_EVENT; | 368 change.type = CHANGE_TYPE_POINTER_WATCHER_EVENT; |
372 change.event_action = static_cast<int32_t>(event.type()); | 369 change.event_action = static_cast<int32_t>(event.type()); |
373 change.pointer_watcher_id = pointer_watcher_id; | |
374 change.window_id = window_id; | 370 change.window_id = window_id; |
375 AddChange(change); | 371 AddChange(change); |
376 } | 372 } |
377 | 373 |
378 void TestChangeTracker::OnWindowSharedPropertyChanged(Id window_id, | 374 void TestChangeTracker::OnWindowSharedPropertyChanged(Id window_id, |
379 String name, | 375 String name, |
380 Array<uint8_t> data) { | 376 Array<uint8_t> data) { |
381 Change change; | 377 Change change; |
382 change.type = CHANGE_TYPE_PROPERTY_CHANGED; | 378 change.type = CHANGE_TYPE_PROPERTY_CHANGED; |
383 change.window_id = window_id; | 379 change.window_id = window_id; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 441 |
446 std::string TestWindow::ToString2() const { | 442 std::string TestWindow::ToString2() const { |
447 return base::StringPrintf( | 443 return base::StringPrintf( |
448 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(), | 444 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(), |
449 WindowIdToString(parent_id).c_str(), visible ? "true" : "false"); | 445 WindowIdToString(parent_id).c_str(), visible ? "true" : "false"); |
450 } | 446 } |
451 | 447 |
452 } // namespace ws | 448 } // namespace ws |
453 | 449 |
454 } // namespace ui | 450 } // namespace ui |
OLD | NEW |