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 "sync/test/fake_server/fake_server_verifier.h" | 5 #include "sync/test/fake_server/fake_server_verifier.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 std::unique_ptr<base::DictionaryValue> entities = | 103 std::unique_ptr<base::DictionaryValue> entities = |
104 fake_server_->GetEntitiesAsDictionaryValue(); | 104 fake_server_->GetEntitiesAsDictionaryValue(); |
105 if (!entities.get()) { | 105 if (!entities.get()) { |
106 return DictionaryCreationAssertionFailure(); | 106 return DictionaryCreationAssertionFailure(); |
107 } | 107 } |
108 | 108 |
109 string model_type_string = ModelTypeToString(model_type); | 109 string model_type_string = ModelTypeToString(model_type); |
110 base::ListValue* entity_list = NULL; | 110 base::ListValue* entity_list = NULL; |
111 size_t actual_count = 0; | 111 size_t actual_count = 0; |
112 if (entities->GetList(model_type_string, &entity_list)) { | 112 if (entities->GetList(model_type_string, &entity_list)) { |
113 std::unique_ptr<base::Value> name_value(new base::StringValue(name)); | 113 base::StringValue name_value(name); |
114 for (base::ListValue::const_iterator it = entity_list->begin(); | 114 for (const auto& entity : *entity_list) { |
115 it != entity_list->end(); ++it) { | 115 if (name_value.Equals(entity.get())) |
116 if (name_value->Equals(*it)) { | |
117 actual_count++; | 116 actual_count++; |
118 } | |
119 } | 117 } |
120 } | 118 } |
121 | 119 |
122 if (!entity_list) { | 120 if (!entity_list) { |
123 return UnknownTypeAssertionFailure(model_type_string); | 121 return UnknownTypeAssertionFailure(model_type_string); |
124 } else if (actual_count != expected_count) { | 122 } else if (actual_count != expected_count) { |
125 return VerificationCountAssertionFailure(actual_count, expected_count) | 123 return VerificationCountAssertionFailure(actual_count, expected_count) |
126 << "; Name: " | 124 << "; Name: " |
127 << name | 125 << name |
128 << "\n\n" | 126 << "\n\n" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 return AssertionFailure() << "Malformed data: Tab entity not found."; | 180 return AssertionFailure() << "Malformed data: Tab entity not found."; |
183 } | 181 } |
184 tab_urls.insert(tab_ids_to_urls[tab_id]); | 182 tab_urls.insert(tab_ids_to_urls[tab_id]); |
185 } | 183 } |
186 actual_sessions.AddWindow(tab_urls); | 184 actual_sessions.AddWindow(tab_urls); |
187 } | 185 } |
188 return VerifySessionsHierarchyEquality(expected_sessions, actual_sessions); | 186 return VerifySessionsHierarchyEquality(expected_sessions, actual_sessions); |
189 } | 187 } |
190 | 188 |
191 } // namespace fake_server | 189 } // namespace fake_server |
OLD | NEW |