| 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/sync/test/fake_server/fake_server_verifier.h" | 5 #include "components/sync/test/fake_server/fake_server_verifier.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 AssertionResult FakeServerVerifier::VerifyEntityCountByType( | 70 AssertionResult FakeServerVerifier::VerifyEntityCountByType( |
| 71 size_t expected_count, | 71 size_t expected_count, |
| 72 syncer::ModelType model_type) const { | 72 syncer::ModelType model_type) const { |
| 73 std::unique_ptr<base::DictionaryValue> entities = | 73 std::unique_ptr<base::DictionaryValue> entities = |
| 74 fake_server_->GetEntitiesAsDictionaryValue(); | 74 fake_server_->GetEntitiesAsDictionaryValue(); |
| 75 if (!entities.get()) { | 75 if (!entities.get()) { |
| 76 return DictionaryCreationAssertionFailure(); | 76 return DictionaryCreationAssertionFailure(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 string model_type_string = ModelTypeToString(model_type); | 79 string model_type_string = ModelTypeToString(model_type); |
| 80 base::ListValue* entity_list = NULL; | 80 base::ListValue* entity_list = nullptr; |
| 81 if (!entities->GetList(model_type_string, &entity_list)) { | 81 if (!entities->GetList(model_type_string, &entity_list)) { |
| 82 return UnknownTypeAssertionFailure(model_type_string); | 82 return UnknownTypeAssertionFailure(model_type_string); |
| 83 } else if (expected_count != entity_list->GetSize()) { | 83 } else if (expected_count != entity_list->GetSize()) { |
| 84 return VerificationCountAssertionFailure(entity_list->GetSize(), | 84 return VerificationCountAssertionFailure(entity_list->GetSize(), |
| 85 expected_count) | 85 expected_count) |
| 86 << "\n\n" | 86 << "\n\n" |
| 87 << ConvertFakeServerContentsToString(*entities); | 87 << ConvertFakeServerContentsToString(*entities); |
| 88 } | 88 } |
| 89 | 89 |
| 90 return AssertionSuccess(); | 90 return AssertionSuccess(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 AssertionResult FakeServerVerifier::VerifyEntityCountByTypeAndName( | 93 AssertionResult FakeServerVerifier::VerifyEntityCountByTypeAndName( |
| 94 size_t expected_count, | 94 size_t expected_count, |
| 95 syncer::ModelType model_type, | 95 syncer::ModelType model_type, |
| 96 const string& name) const { | 96 const string& name) const { |
| 97 std::unique_ptr<base::DictionaryValue> entities = | 97 std::unique_ptr<base::DictionaryValue> entities = |
| 98 fake_server_->GetEntitiesAsDictionaryValue(); | 98 fake_server_->GetEntitiesAsDictionaryValue(); |
| 99 if (!entities.get()) { | 99 if (!entities.get()) { |
| 100 return DictionaryCreationAssertionFailure(); | 100 return DictionaryCreationAssertionFailure(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 string model_type_string = ModelTypeToString(model_type); | 103 string model_type_string = ModelTypeToString(model_type); |
| 104 base::ListValue* entity_list = NULL; | 104 base::ListValue* entity_list = nullptr; |
| 105 size_t actual_count = 0; | 105 size_t actual_count = 0; |
| 106 if (entities->GetList(model_type_string, &entity_list)) { | 106 if (entities->GetList(model_type_string, &entity_list)) { |
| 107 base::StringValue name_value(name); | 107 base::StringValue name_value(name); |
| 108 for (const auto& entity : *entity_list) { | 108 for (const auto& entity : *entity_list) { |
| 109 if (name_value.Equals(entity.get())) | 109 if (name_value.Equals(entity.get())) |
| 110 actual_count++; | 110 actual_count++; |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 if (!entity_list) { | 114 if (!entity_list) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 return AssertionFailure() << "Malformed data: Tab entity not found."; | 172 return AssertionFailure() << "Malformed data: Tab entity not found."; |
| 173 } | 173 } |
| 174 tab_urls.insert(tab_ids_to_urls[tab_id]); | 174 tab_urls.insert(tab_ids_to_urls[tab_id]); |
| 175 } | 175 } |
| 176 actual_sessions.AddWindow(tab_urls); | 176 actual_sessions.AddWindow(tab_urls); |
| 177 } | 177 } |
| 178 return VerifySessionsHierarchyEquality(expected_sessions, actual_sessions); | 178 return VerifySessionsHierarchyEquality(expected_sessions, actual_sessions); |
| 179 } | 179 } |
| 180 | 180 |
| 181 } // namespace fake_server | 181 } // namespace fake_server |
| OLD | NEW |