Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: sync/test/fake_server/fake_server_verifier.cc

Issue 1866243002: Convert //sync from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix conflicts Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sync/test/fake_server/fake_server_verifier.h ('k') | sync/test/fake_server/permanent_entity.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <set> 11 #include <set>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "sync/internal_api/public/base/model_type.h" 16 #include "sync/internal_api/public/base/model_type.h"
17 #include "sync/test/fake_server/fake_server.h" 17 #include "sync/test/fake_server/fake_server.h"
18 #include "sync/test/fake_server/sessions_hierarchy.h" 18 #include "sync/test/fake_server/sessions_hierarchy.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 using base::JSONWriter; 21 using base::JSONWriter;
22 using std::string; 22 using std::string;
23 using testing::AssertionFailure; 23 using testing::AssertionFailure;
24 using testing::AssertionResult; 24 using testing::AssertionResult;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } // namespace 69 } // namespace
70 70
71 FakeServerVerifier::FakeServerVerifier(FakeServer* fake_server) 71 FakeServerVerifier::FakeServerVerifier(FakeServer* fake_server)
72 : fake_server_(fake_server) { } 72 : fake_server_(fake_server) { }
73 73
74 FakeServerVerifier::~FakeServerVerifier() {} 74 FakeServerVerifier::~FakeServerVerifier() {}
75 75
76 AssertionResult FakeServerVerifier::VerifyEntityCountByType( 76 AssertionResult FakeServerVerifier::VerifyEntityCountByType(
77 size_t expected_count, 77 size_t expected_count,
78 syncer::ModelType model_type) const { 78 syncer::ModelType model_type) const {
79 scoped_ptr<base::DictionaryValue> entities = 79 std::unique_ptr<base::DictionaryValue> entities =
80 fake_server_->GetEntitiesAsDictionaryValue(); 80 fake_server_->GetEntitiesAsDictionaryValue();
81 if (!entities.get()) { 81 if (!entities.get()) {
82 return DictionaryCreationAssertionFailure(); 82 return DictionaryCreationAssertionFailure();
83 } 83 }
84 84
85 string model_type_string = ModelTypeToString(model_type); 85 string model_type_string = ModelTypeToString(model_type);
86 base::ListValue* entity_list = NULL; 86 base::ListValue* entity_list = NULL;
87 if (!entities->GetList(model_type_string, &entity_list)) { 87 if (!entities->GetList(model_type_string, &entity_list)) {
88 return UnknownTypeAssertionFailure(model_type_string); 88 return UnknownTypeAssertionFailure(model_type_string);
89 } else if (expected_count != entity_list->GetSize()) { 89 } else if (expected_count != entity_list->GetSize()) {
90 return VerificationCountAssertionFailure(entity_list->GetSize(), 90 return VerificationCountAssertionFailure(entity_list->GetSize(),
91 expected_count) 91 expected_count)
92 << "\n\n" 92 << "\n\n"
93 << ConvertFakeServerContentsToString(*entities); 93 << ConvertFakeServerContentsToString(*entities);
94 } 94 }
95 95
96 return AssertionSuccess(); 96 return AssertionSuccess();
97 } 97 }
98 98
99 AssertionResult FakeServerVerifier::VerifyEntityCountByTypeAndName( 99 AssertionResult FakeServerVerifier::VerifyEntityCountByTypeAndName(
100 size_t expected_count, 100 size_t expected_count,
101 syncer::ModelType model_type, 101 syncer::ModelType model_type,
102 const string& name) const { 102 const string& name) const {
103 scoped_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 scoped_ptr<base::Value> name_value(new base::StringValue(name)); 113 std::unique_ptr<base::Value> name_value(new base::StringValue(name));
114 for (base::ListValue::const_iterator it = entity_list->begin(); 114 for (base::ListValue::const_iterator it = entity_list->begin();
115 it != entity_list->end(); ++it) { 115 it != entity_list->end(); ++it) {
116 if (name_value->Equals(*it)) { 116 if (name_value->Equals(*it)) {
117 actual_count++; 117 actual_count++;
118 } 118 }
119 } 119 }
120 } 120 }
121 121
122 if (!entity_list) { 122 if (!entity_list) {
123 return UnknownTypeAssertionFailure(model_type_string); 123 return UnknownTypeAssertionFailure(model_type_string);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return AssertionFailure() << "Malformed data: Tab entity not found."; 182 return AssertionFailure() << "Malformed data: Tab entity not found.";
183 } 183 }
184 tab_urls.insert(tab_ids_to_urls[tab_id]); 184 tab_urls.insert(tab_ids_to_urls[tab_id]);
185 } 185 }
186 actual_sessions.AddWindow(tab_urls); 186 actual_sessions.AddWindow(tab_urls);
187 } 187 }
188 return VerifySessionsHierarchyEquality(expected_sessions, actual_sessions); 188 return VerifySessionsHierarchyEquality(expected_sessions, actual_sessions);
189 } 189 }
190 190
191 } // namespace fake_server 191 } // namespace fake_server
OLDNEW
« no previous file with comments | « sync/test/fake_server/fake_server_verifier.h ('k') | sync/test/fake_server/permanent_entity.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698