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" |
11 #include "mojo/public/cpp/bindings/map.h" | 11 #include "mojo/public/cpp/bindings/map.h" |
12 #include "services/ui/common/util.h" | 12 #include "services/ui/common/util.h" |
| 13 #include "ui/base/cursor/cursor.h" |
13 | 14 |
14 namespace ui { | 15 namespace ui { |
15 | 16 |
16 namespace ws { | 17 namespace ws { |
17 | 18 |
18 std::string WindowIdToString(Id id) { | 19 std::string WindowIdToString(Id id) { |
19 return (id == 0) ? "null" | 20 return (id == 0) ? "null" |
20 : base::StringPrintf("%d,%d", HiWord(id), LoWord(id)); | 21 : base::StringPrintf("%d,%d", HiWord(id), LoWord(id)); |
21 } | 22 } |
22 | 23 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 return base::StringPrintf("PropertyChanged window=%s key=%s value=%s", | 125 return base::StringPrintf("PropertyChanged window=%s key=%s value=%s", |
125 WindowIdToString(change.window_id).c_str(), | 126 WindowIdToString(change.window_id).c_str(), |
126 change.property_key.c_str(), | 127 change.property_key.c_str(), |
127 change.property_value.c_str()); | 128 change.property_value.c_str()); |
128 | 129 |
129 case CHANGE_TYPE_FOCUSED: | 130 case CHANGE_TYPE_FOCUSED: |
130 return base::StringPrintf("Focused id=%s", | 131 return base::StringPrintf("Focused id=%s", |
131 WindowIdToString(change.window_id).c_str()); | 132 WindowIdToString(change.window_id).c_str()); |
132 | 133 |
133 case CHANGE_TYPE_CURSOR_CHANGED: | 134 case CHANGE_TYPE_CURSOR_CHANGED: |
134 return base::StringPrintf("CursorChanged id=%s cursor_id=%d", | 135 return base::StringPrintf("CursorChanged id=%s cursor_type=%d", |
135 WindowIdToString(change.window_id).c_str(), | 136 WindowIdToString(change.window_id).c_str(), |
136 change.cursor_id); | 137 static_cast<int>(change.cursor_type)); |
137 case CHANGE_TYPE_ON_CHANGE_COMPLETED: | 138 case CHANGE_TYPE_ON_CHANGE_COMPLETED: |
138 return base::StringPrintf("ChangeCompleted id=%d sucess=%s", | 139 return base::StringPrintf("ChangeCompleted id=%d sucess=%s", |
139 change.change_id, | 140 change.change_id, |
140 change.bool_value ? "true" : "false"); | 141 change.bool_value ? "true" : "false"); |
141 | 142 |
142 case CHANGE_TYPE_ON_TOP_LEVEL_CREATED: | 143 case CHANGE_TYPE_ON_TOP_LEVEL_CREATED: |
143 return base::StringPrintf( | 144 return base::StringPrintf( |
144 "TopLevelCreated id=%d %s window_id=%s drawn=%s", change.change_id, | 145 "TopLevelCreated id=%d %s window_id=%s drawn=%s", change.change_id, |
145 change.frame_sink_id.ToString().c_str(), | 146 change.frame_sink_id.ToString().c_str(), |
146 WindowIdToString(change.window_id).c_str(), | 147 WindowIdToString(change.window_id).c_str(), |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 : type(CHANGE_TYPE_EMBED), | 224 : type(CHANGE_TYPE_EMBED), |
224 client_id(0), | 225 client_id(0), |
225 window_id(0), | 226 window_id(0), |
226 window_id2(0), | 227 window_id2(0), |
227 window_id3(0), | 228 window_id3(0), |
228 event_action(0), | 229 event_action(0), |
229 matches_pointer_watcher(false), | 230 matches_pointer_watcher(false), |
230 direction(mojom::OrderDirection::ABOVE), | 231 direction(mojom::OrderDirection::ABOVE), |
231 bool_value(false), | 232 bool_value(false), |
232 float_value(0.f), | 233 float_value(0.f), |
233 cursor_id(0), | 234 cursor_type(ui::CursorType::kNull), |
234 change_id(0u) {} | 235 change_id(0u) {} |
235 | 236 |
236 Change::Change(const Change& other) = default; | 237 Change::Change(const Change& other) = default; |
237 | 238 |
238 Change::~Change() {} | 239 Change::~Change() {} |
239 | 240 |
240 TestChangeTracker::TestChangeTracker() : delegate_(NULL) {} | 241 TestChangeTracker::TestChangeTracker() : delegate_(NULL) {} |
241 | 242 |
242 TestChangeTracker::~TestChangeTracker() {} | 243 TestChangeTracker::~TestChangeTracker() {} |
243 | 244 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 AddChange(change); | 414 AddChange(change); |
414 } | 415 } |
415 | 416 |
416 void TestChangeTracker::OnWindowFocused(Id window_id) { | 417 void TestChangeTracker::OnWindowFocused(Id window_id) { |
417 Change change; | 418 Change change; |
418 change.type = CHANGE_TYPE_FOCUSED; | 419 change.type = CHANGE_TYPE_FOCUSED; |
419 change.window_id = window_id; | 420 change.window_id = window_id; |
420 AddChange(change); | 421 AddChange(change); |
421 } | 422 } |
422 | 423 |
423 void TestChangeTracker::OnWindowPredefinedCursorChanged( | 424 void TestChangeTracker::OnWindowCursorChanged(Id window_id, |
424 Id window_id, | 425 const ui::CursorData& cursor) { |
425 mojom::CursorType cursor_id) { | |
426 Change change; | 426 Change change; |
427 change.type = CHANGE_TYPE_CURSOR_CHANGED; | 427 change.type = CHANGE_TYPE_CURSOR_CHANGED; |
428 change.window_id = window_id; | 428 change.window_id = window_id; |
429 change.cursor_id = static_cast<int32_t>(cursor_id); | 429 change.cursor_type = cursor.cursor_type(); |
430 AddChange(change); | 430 AddChange(change); |
431 } | 431 } |
432 | 432 |
433 void TestChangeTracker::OnChangeCompleted(uint32_t change_id, bool success) { | 433 void TestChangeTracker::OnChangeCompleted(uint32_t change_id, bool success) { |
434 Change change; | 434 Change change; |
435 change.type = CHANGE_TYPE_ON_CHANGE_COMPLETED; | 435 change.type = CHANGE_TYPE_ON_CHANGE_COMPLETED; |
436 change.change_id = change_id; | 436 change.change_id = change_id; |
437 change.bool_value = success; | 437 change.bool_value = success; |
438 AddChange(change); | 438 AddChange(change); |
439 } | 439 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 | 484 |
485 std::string TestWindow::ToString2() const { | 485 std::string TestWindow::ToString2() const { |
486 return base::StringPrintf( | 486 return base::StringPrintf( |
487 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(), | 487 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(), |
488 WindowIdToString(parent_id).c_str(), visible ? "true" : "false"); | 488 WindowIdToString(parent_id).c_str(), visible ? "true" : "false"); |
489 } | 489 } |
490 | 490 |
491 } // namespace ws | 491 } // namespace ws |
492 | 492 |
493 } // namespace ui | 493 } // namespace ui |
OLD | NEW |