| 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/view_manager/test_change_tracker.h" | 5 #include "components/view_manager/test_change_tracker.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "components/view_manager/public/cpp/util.h" | 9 #include "components/view_manager/public/cpp/util.h" |
| 10 #include "mojo/common/common_type_converters.h" | 10 #include "mojo/common/common_type_converters.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 rect.height); | 28 rect.height); |
| 29 } | 29 } |
| 30 | 30 |
| 31 std::string DirectionToString(mojo::OrderDirection direction) { | 31 std::string DirectionToString(mojo::OrderDirection direction) { |
| 32 return direction == mojo::ORDER_DIRECTION_ABOVE ? "above" : "below"; | 32 return direction == mojo::ORDER_DIRECTION_ABOVE ? "above" : "below"; |
| 33 } | 33 } |
| 34 | 34 |
| 35 std::string ChangeToDescription1(const Change& change) { | 35 std::string ChangeToDescription1(const Change& change) { |
| 36 switch (change.type) { | 36 switch (change.type) { |
| 37 case CHANGE_TYPE_EMBED: | 37 case CHANGE_TYPE_EMBED: |
| 38 return base::StringPrintf("OnEmbed creator=%s", | 38 return "OnEmbed"; |
| 39 change.creator_url.data()); | |
| 40 | 39 |
| 41 case CHANGE_TYPE_EMBEDDED_APP_DISCONNECTED: | 40 case CHANGE_TYPE_EMBEDDED_APP_DISCONNECTED: |
| 42 return base::StringPrintf("OnEmbeddedAppDisconnected view=%s", | 41 return base::StringPrintf("OnEmbeddedAppDisconnected view=%s", |
| 43 ViewIdToString(change.view_id).c_str()); | 42 ViewIdToString(change.view_id).c_str()); |
| 44 | 43 |
| 45 case CHANGE_TYPE_WILL_EMBED: | 44 case CHANGE_TYPE_EMBED_FOR_DESCENDANT: |
| 46 return base::StringPrintf("OnWillEmbed view=%s", | 45 return base::StringPrintf("OnEmbedForDescendant view=%s", |
| 47 ViewIdToString(change.view_id).c_str()); | 46 ViewIdToString(change.view_id).c_str()); |
| 48 | 47 |
| 49 case CHANGE_TYPE_NODE_BOUNDS_CHANGED: | 48 case CHANGE_TYPE_NODE_BOUNDS_CHANGED: |
| 50 return base::StringPrintf( | 49 return base::StringPrintf( |
| 51 "BoundsChanged view=%s old_bounds=%s new_bounds=%s", | 50 "BoundsChanged view=%s old_bounds=%s new_bounds=%s", |
| 52 ViewIdToString(change.view_id).c_str(), | 51 ViewIdToString(change.view_id).c_str(), |
| 53 RectToString(change.bounds).c_str(), | 52 RectToString(change.bounds).c_str(), |
| 54 RectToString(change.bounds2).c_str()); | 53 RectToString(change.bounds2).c_str()); |
| 55 | 54 |
| 56 case CHANGE_TYPE_NODE_VIEWPORT_METRICS_CHANGED: | 55 case CHANGE_TYPE_NODE_VIEWPORT_METRICS_CHANGED: |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 168 } |
| 170 | 169 |
| 171 TestChangeTracker::TestChangeTracker() | 170 TestChangeTracker::TestChangeTracker() |
| 172 : delegate_(NULL) { | 171 : delegate_(NULL) { |
| 173 } | 172 } |
| 174 | 173 |
| 175 TestChangeTracker::~TestChangeTracker() { | 174 TestChangeTracker::~TestChangeTracker() { |
| 176 } | 175 } |
| 177 | 176 |
| 178 void TestChangeTracker::OnEmbed(mojo::ConnectionSpecificId connection_id, | 177 void TestChangeTracker::OnEmbed(mojo::ConnectionSpecificId connection_id, |
| 179 const String& creator_url, | |
| 180 ViewDataPtr root) { | 178 ViewDataPtr root) { |
| 181 Change change; | 179 Change change; |
| 182 change.type = CHANGE_TYPE_EMBED; | 180 change.type = CHANGE_TYPE_EMBED; |
| 183 change.connection_id = connection_id; | 181 change.connection_id = connection_id; |
| 184 change.creator_url = creator_url; | |
| 185 change.views.push_back(ViewDataToTestView(root)); | 182 change.views.push_back(ViewDataToTestView(root)); |
| 186 AddChange(change); | 183 AddChange(change); |
| 187 } | 184 } |
| 188 | 185 |
| 189 void TestChangeTracker::OnWillEmbed(mojo::Id view_id) { | 186 void TestChangeTracker::OnEmbedForDescendant(mojo::Id view_id) { |
| 190 Change change; | 187 Change change; |
| 191 change.type = CHANGE_TYPE_WILL_EMBED; | 188 change.type = CHANGE_TYPE_EMBED_FOR_DESCENDANT; |
| 192 change.view_id = view_id; | 189 change.view_id = view_id; |
| 193 AddChange(change); | 190 AddChange(change); |
| 194 } | 191 } |
| 195 | 192 |
| 196 void TestChangeTracker::OnEmbeddedAppDisconnected(Id view_id) { | 193 void TestChangeTracker::OnEmbeddedAppDisconnected(Id view_id) { |
| 197 Change change; | 194 Change change; |
| 198 change.type = CHANGE_TYPE_EMBEDDED_APP_DISCONNECTED; | 195 change.type = CHANGE_TYPE_EMBEDDED_APP_DISCONNECTED; |
| 199 change.view_id = view_id; | 196 change.view_id = view_id; |
| 200 AddChange(change); | 197 AddChange(change); |
| 201 } | 198 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 324 |
| 328 std::string TestView::ToString2() const { | 325 std::string TestView::ToString2() const { |
| 329 return base::StringPrintf("view=%s parent=%s visible=%s drawn=%s", | 326 return base::StringPrintf("view=%s parent=%s visible=%s drawn=%s", |
| 330 ViewIdToString(view_id).c_str(), | 327 ViewIdToString(view_id).c_str(), |
| 331 ViewIdToString(parent_id).c_str(), | 328 ViewIdToString(parent_id).c_str(), |
| 332 visible ? "true" : "false", | 329 visible ? "true" : "false", |
| 333 drawn ? "true" : "false"); | 330 drawn ? "true" : "false"); |
| 334 } | 331 } |
| 335 | 332 |
| 336 } // namespace view_manager | 333 } // namespace view_manager |
| OLD | NEW |