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/test_change_tracker.h" | 5 #include "components/mus/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/mus/public/cpp/util.h" | 9 #include "components/mus/public/cpp/util.h" |
10 #include "mojo/common/common_type_converters.h" | 10 #include "mojo/common/common_type_converters.h" |
11 | 11 |
12 using mojo::Array; | 12 using mojo::Array; |
| 13 using mojo::Id; |
13 using mojo::ViewDataPtr; | 14 using mojo::ViewDataPtr; |
14 using mojo::String; | 15 using mojo::String; |
15 | 16 |
16 namespace mus { | 17 namespace view_manager { |
17 | 18 |
18 std::string ViewIdToString(Id id) { | 19 std::string ViewIdToString(Id id) { |
19 return (id == 0) ? "null" | 20 return (id == 0) ? "null" : base::StringPrintf("%d,%d", mojo::HiWord(id), |
20 : base::StringPrintf("%d,%d", HiWord(id), LoWord(id)); | 21 mojo::LoWord(id)); |
21 } | 22 } |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 std::string RectToString(const mojo::Rect& rect) { | 26 std::string RectToString(const mojo::Rect& rect) { |
26 return base::StringPrintf("%d,%d %dx%d", rect.x, rect.y, rect.width, | 27 return base::StringPrintf("%d,%d %dx%d", rect.x, rect.y, rect.width, |
27 rect.height); | 28 rect.height); |
28 } | 29 } |
29 | 30 |
30 std::string DirectionToString(mojo::OrderDirection direction) { | 31 std::string DirectionToString(mojo::OrderDirection direction) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 event_action(0), | 165 event_action(0), |
165 direction(mojo::ORDER_DIRECTION_ABOVE), | 166 direction(mojo::ORDER_DIRECTION_ABOVE), |
166 bool_value(false) {} | 167 bool_value(false) {} |
167 | 168 |
168 Change::~Change() {} | 169 Change::~Change() {} |
169 | 170 |
170 TestChangeTracker::TestChangeTracker() : delegate_(NULL) {} | 171 TestChangeTracker::TestChangeTracker() : delegate_(NULL) {} |
171 | 172 |
172 TestChangeTracker::~TestChangeTracker() {} | 173 TestChangeTracker::~TestChangeTracker() {} |
173 | 174 |
174 void TestChangeTracker::OnEmbed(ConnectionSpecificId connection_id, | 175 void TestChangeTracker::OnEmbed(mojo::ConnectionSpecificId connection_id, |
175 ViewDataPtr root) { | 176 ViewDataPtr root) { |
176 Change change; | 177 Change change; |
177 change.type = CHANGE_TYPE_EMBED; | 178 change.type = CHANGE_TYPE_EMBED; |
178 change.connection_id = connection_id; | 179 change.connection_id = connection_id; |
179 change.views.push_back(ViewDataToTestView(root)); | 180 change.views.push_back(ViewDataToTestView(root)); |
180 AddChange(change); | 181 AddChange(change); |
181 } | 182 } |
182 | 183 |
183 void TestChangeTracker::OnEmbeddedAppDisconnected(Id view_id) { | 184 void TestChangeTracker::OnEmbeddedAppDisconnected(Id view_id) { |
184 Change change; | 185 Change change; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 change.type = CHANGE_TYPE_PROPERTY_CHANGED; | 282 change.type = CHANGE_TYPE_PROPERTY_CHANGED; |
282 change.view_id = view_id; | 283 change.view_id = view_id; |
283 change.property_key = name; | 284 change.property_key = name; |
284 if (data.is_null()) | 285 if (data.is_null()) |
285 change.property_value = "NULL"; | 286 change.property_value = "NULL"; |
286 else | 287 else |
287 change.property_value = data.To<std::string>(); | 288 change.property_value = data.To<std::string>(); |
288 AddChange(change); | 289 AddChange(change); |
289 } | 290 } |
290 | 291 |
291 void TestChangeTracker::OnViewFocused(Id view_id) { | 292 void TestChangeTracker::OnViewFocused(mojo::Id view_id) { |
292 Change change; | 293 Change change; |
293 change.type = CHANGE_TYPE_FOCUSED; | 294 change.type = CHANGE_TYPE_FOCUSED; |
294 change.view_id = view_id; | 295 change.view_id = view_id; |
295 AddChange(change); | 296 AddChange(change); |
296 } | 297 } |
297 | 298 |
298 void TestChangeTracker::DelegateEmbed(const String& url) { | 299 void TestChangeTracker::DelegateEmbed(const String& url) { |
299 Change change; | 300 Change change; |
300 change.type = CHANGE_TYPE_DELEGATE_EMBED; | 301 change.type = CHANGE_TYPE_DELEGATE_EMBED; |
301 change.embed_url = url; | 302 change.embed_url = url; |
(...skipping 16 matching lines...) Expand all Loading... |
318 ViewIdToString(parent_id).c_str()); | 319 ViewIdToString(parent_id).c_str()); |
319 } | 320 } |
320 | 321 |
321 std::string TestView::ToString2() const { | 322 std::string TestView::ToString2() const { |
322 return base::StringPrintf( | 323 return base::StringPrintf( |
323 "view=%s parent=%s visible=%s drawn=%s", ViewIdToString(view_id).c_str(), | 324 "view=%s parent=%s visible=%s drawn=%s", ViewIdToString(view_id).c_str(), |
324 ViewIdToString(parent_id).c_str(), visible ? "true" : "false", | 325 ViewIdToString(parent_id).c_str(), visible ? "true" : "false", |
325 drawn ? "true" : "false"); | 326 drawn ? "true" : "false"); |
326 } | 327 } |
327 | 328 |
328 } // namespace mus | 329 } // namespace view_manager |
OLD | NEW |