| 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 "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" |
| 11 #include "components/mus/common/util.h" | 11 #include "components/mus/common/util.h" |
| 12 #include "mojo/common/common_type_converters.h" | 12 #include "mojo/common/common_type_converters.h" |
| 13 | 13 |
| 14 using mojo::Array; | 14 using mojo::Array; |
| 15 using mojo::String; | 15 using mojo::String; |
| 16 | 16 |
| 17 namespace mus { | 17 namespace mus { |
| 18 | 18 |
| 19 namespace ws { | 19 namespace ws { |
| 20 | 20 |
| 21 std::string WindowIdToString(Id id) { | 21 std::string WindowIdToString(Id id) { |
| 22 return (id == 0) ? "null" | 22 return (id == 0) ? "null" |
| 23 : base::StringPrintf("%d,%d", HiWord(id), LoWord(id)); | 23 : base::StringPrintf("%d,%d", HiWord(id), LoWord(id)); |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 std::string RectToString(const mojo::Rect& rect) { | |
| 29 return base::StringPrintf("%d,%d %dx%d", rect.x, rect.y, rect.width, | |
| 30 rect.height); | |
| 31 } | |
| 32 | |
| 33 std::string DirectionToString(mojom::OrderDirection direction) { | 28 std::string DirectionToString(mojom::OrderDirection direction) { |
| 34 return direction == mojom::OrderDirection::ABOVE ? "above" : "below"; | 29 return direction == mojom::OrderDirection::ABOVE ? "above" : "below"; |
| 35 } | 30 } |
| 36 | 31 |
| 37 enum class ChangeDescriptionType { | 32 enum class ChangeDescriptionType { |
| 38 ONE, | 33 ONE, |
| 39 TWO, | 34 TWO, |
| 40 }; | 35 }; |
| 41 | 36 |
| 42 std::string ChangeToDescription(const Change& change, | 37 std::string ChangeToDescription(const Change& change, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 62 | 57 |
| 63 case CHANGE_TYPE_NODE_ADD_TRANSIENT_WINDOW: | 58 case CHANGE_TYPE_NODE_ADD_TRANSIENT_WINDOW: |
| 64 return base::StringPrintf("AddTransientWindow parent = %s child = %s", | 59 return base::StringPrintf("AddTransientWindow parent = %s child = %s", |
| 65 WindowIdToString(change.window_id).c_str(), | 60 WindowIdToString(change.window_id).c_str(), |
| 66 WindowIdToString(change.window_id2).c_str()); | 61 WindowIdToString(change.window_id2).c_str()); |
| 67 | 62 |
| 68 case CHANGE_TYPE_NODE_BOUNDS_CHANGED: | 63 case CHANGE_TYPE_NODE_BOUNDS_CHANGED: |
| 69 return base::StringPrintf( | 64 return base::StringPrintf( |
| 70 "BoundsChanged window=%s old_bounds=%s new_bounds=%s", | 65 "BoundsChanged window=%s old_bounds=%s new_bounds=%s", |
| 71 WindowIdToString(change.window_id).c_str(), | 66 WindowIdToString(change.window_id).c_str(), |
| 72 RectToString(change.bounds).c_str(), | 67 change.bounds.ToString().c_str(), change.bounds2.ToString().c_str()); |
| 73 RectToString(change.bounds2).c_str()); | |
| 74 | 68 |
| 75 case CHANGE_TYPE_NODE_HIERARCHY_CHANGED: | 69 case CHANGE_TYPE_NODE_HIERARCHY_CHANGED: |
| 76 return base::StringPrintf( | 70 return base::StringPrintf( |
| 77 "HierarchyChanged window=%s old_parent=%s new_parent=%s", | 71 "HierarchyChanged window=%s old_parent=%s new_parent=%s", |
| 78 WindowIdToString(change.window_id).c_str(), | 72 WindowIdToString(change.window_id).c_str(), |
| 79 WindowIdToString(change.window_id2).c_str(), | 73 WindowIdToString(change.window_id2).c_str(), |
| 80 WindowIdToString(change.window_id3).c_str()); | 74 WindowIdToString(change.window_id3).c_str()); |
| 81 | 75 |
| 82 case CHANGE_TYPE_NODE_REMOVE_TRANSIENT_WINDOW_FROM_PARENT: | 76 case CHANGE_TYPE_NODE_REMOVE_TRANSIENT_WINDOW_FROM_PARENT: |
| 83 return base::StringPrintf( | 77 return base::StringPrintf( |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 243 } |
| 250 | 244 |
| 251 void TestChangeTracker::OnEmbeddedAppDisconnected(Id window_id) { | 245 void TestChangeTracker::OnEmbeddedAppDisconnected(Id window_id) { |
| 252 Change change; | 246 Change change; |
| 253 change.type = CHANGE_TYPE_EMBEDDED_APP_DISCONNECTED; | 247 change.type = CHANGE_TYPE_EMBEDDED_APP_DISCONNECTED; |
| 254 change.window_id = window_id; | 248 change.window_id = window_id; |
| 255 AddChange(change); | 249 AddChange(change); |
| 256 } | 250 } |
| 257 | 251 |
| 258 void TestChangeTracker::OnWindowBoundsChanged(Id window_id, | 252 void TestChangeTracker::OnWindowBoundsChanged(Id window_id, |
| 259 mojo::RectPtr old_bounds, | 253 const gfx::Rect& old_bounds, |
| 260 mojo::RectPtr new_bounds) { | 254 const gfx::Rect& new_bounds) { |
| 261 Change change; | 255 Change change; |
| 262 change.type = CHANGE_TYPE_NODE_BOUNDS_CHANGED; | 256 change.type = CHANGE_TYPE_NODE_BOUNDS_CHANGED; |
| 263 change.window_id = window_id; | 257 change.window_id = window_id; |
| 264 change.bounds.x = old_bounds->x; | 258 change.bounds = old_bounds; |
| 265 change.bounds.y = old_bounds->y; | 259 change.bounds2 = new_bounds; |
| 266 change.bounds.width = old_bounds->width; | |
| 267 change.bounds.height = old_bounds->height; | |
| 268 change.bounds2.x = new_bounds->x; | |
| 269 change.bounds2.y = new_bounds->y; | |
| 270 change.bounds2.width = new_bounds->width; | |
| 271 change.bounds2.height = new_bounds->height; | |
| 272 AddChange(change); | 260 AddChange(change); |
| 273 } | 261 } |
| 274 | 262 |
| 275 void TestChangeTracker::OnUnembed(Id window_id) { | 263 void TestChangeTracker::OnUnembed(Id window_id) { |
| 276 Change change; | 264 Change change; |
| 277 change.type = CHANGE_TYPE_UNEMBED; | 265 change.type = CHANGE_TYPE_UNEMBED; |
| 278 change.window_id = window_id; | 266 change.window_id = window_id; |
| 279 AddChange(change); | 267 AddChange(change); |
| 280 } | 268 } |
| 281 | 269 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 439 |
| 452 std::string TestWindow::ToString2() const { | 440 std::string TestWindow::ToString2() const { |
| 453 return base::StringPrintf( | 441 return base::StringPrintf( |
| 454 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(), | 442 "window=%s parent=%s visible=%s", WindowIdToString(window_id).c_str(), |
| 455 WindowIdToString(parent_id).c_str(), visible ? "true" : "false"); | 443 WindowIdToString(parent_id).c_str(), visible ? "true" : "false"); |
| 456 } | 444 } |
| 457 | 445 |
| 458 } // namespace ws | 446 } // namespace ws |
| 459 | 447 |
| 460 } // namespace mus | 448 } // namespace mus |
| OLD | NEW |