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

Side by Side Diff: ios/chrome/test/app/sync_test_util.mm

Issue 2887343002: wip 3 (Closed)
Patch Set: cleanup Created 3 years, 6 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 | « components/sync/test/fake_server/unique_client_entity.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #import "ios/chrome/test/app/sync_test_util.h" 5 #import "ios/chrome/test/app/sync_test_util.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #import "base/mac/bind_objc_block.h" 11 #import "base/mac/bind_objc_block.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #import "base/test/ios/wait_util.h" 15 #import "base/test/ios/wait_util.h"
16 #include "components/autofill/core/browser/personal_data_manager.h" 16 #include "components/autofill/core/browser/personal_data_manager.h"
17 #include "components/browser_sync/profile_sync_service.h" 17 #include "components/browser_sync/profile_sync_service.h"
18 #include "components/history/core/browser/history_service.h" 18 #include "components/history/core/browser/history_service.h"
19 #include "components/keyed_service/core/service_access_type.h" 19 #include "components/keyed_service/core/service_access_type.h"
20 #include "components/sync/engine/net/http_bridge_network_resources.h" 20 #include "components/sync/engine/net/http_bridge_network_resources.h"
21 #include "components/sync/test/fake_server/entity_builder_factory.h" 21 #include "components/sync/test/fake_server/entity_builder_factory.h"
22 #include "components/sync/test/fake_server/fake_server.h" 22 #include "components/sync/test/fake_server/fake_server.h"
23 #include "components/sync/test/fake_server/fake_server_network_resources.h" 23 #include "components/sync/test/fake_server/fake_server_network_resources.h"
24 #include "components/sync/test/fake_server/fake_server_verifier.h" 24 #include "components/sync/test/fake_server/fake_server_verifier.h"
25 #include "components/sync/test/fake_server/sessions_hierarchy.h" 25 #include "components/sync/test/fake_server/sessions_hierarchy.h"
26 #include "components/sync/test/fake_server/tombstone_entity.h"
27 #include "components/sync/test/fake_server/unique_client_entity.h"
28 #include "ios/chrome/browser/autofill/personal_data_manager_factory.h" 26 #include "ios/chrome/browser/autofill/personal_data_manager_factory.h"
29 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 27 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
30 #include "ios/chrome/browser/history/history_service_factory.h" 28 #include "ios/chrome/browser/history/history_service_factory.h"
31 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" 29 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
32 #include "ios/chrome/browser/sync/sync_setup_service.h" 30 #include "ios/chrome/browser/sync/sync_setup_service.h"
33 #include "ios/chrome/browser/sync/sync_setup_service_factory.h" 31 #include "ios/chrome/browser/sync/sync_setup_service_factory.h"
34 #import "ios/chrome/test/app/chrome_test_util.h" 32 #import "ios/chrome/test/app/chrome_test_util.h"
35 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
36 34
37 namespace { 35 namespace {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 165
168 void InjectAutofillProfileOnFakeSyncServer(std::string guid, 166 void InjectAutofillProfileOnFakeSyncServer(std::string guid,
169 std::string full_name) { 167 std::string full_name) {
170 DCHECK(gSyncFakeServer); 168 DCHECK(gSyncFakeServer);
171 sync_pb::EntitySpecifics entity_specifics; 169 sync_pb::EntitySpecifics entity_specifics;
172 sync_pb::AutofillProfileSpecifics* autofill_profile = 170 sync_pb::AutofillProfileSpecifics* autofill_profile =
173 entity_specifics.mutable_autofill_profile(); 171 entity_specifics.mutable_autofill_profile();
174 autofill_profile->add_name_full(full_name); 172 autofill_profile->add_name_full(full_name);
175 autofill_profile->set_guid(guid); 173 autofill_profile->set_guid(guid);
176 174
177 std::unique_ptr<fake_server::FakeServerEntity> entity = 175 std::unique_ptr<syncer::LoopbackServerEntity> entity =
178 fake_server::UniqueClientEntity::CreateForInjection(guid, 176 syncer::PersistentUniqueClientEntity::CreateForInjection(
179 entity_specifics); 177 guid, entity_specifics);
180 gSyncFakeServer->InjectEntity(std::move(entity)); 178 gSyncFakeServer->InjectEntity(std::move(entity));
181 } 179 }
182 180
183 void DeleteAutofillProfileOnFakeSyncServer(std::string guid) { 181 void DeleteAutofillProfileOnFakeSyncServer(std::string guid) {
184 DCHECK(gSyncFakeServer); 182 DCHECK(gSyncFakeServer);
185 std::vector<sync_pb::SyncEntity> autofill_profiles = 183 std::vector<sync_pb::SyncEntity> autofill_profiles =
186 gSyncFakeServer->GetSyncEntitiesByModelType(syncer::AUTOFILL_PROFILE); 184 gSyncFakeServer->GetSyncEntitiesByModelType(syncer::AUTOFILL_PROFILE);
187 std::string entity_id; 185 std::string entity_id;
188 for (const sync_pb::SyncEntity& autofill_profile : autofill_profiles) { 186 for (const sync_pb::SyncEntity& autofill_profile : autofill_profiles) {
189 if (autofill_profile.specifics().autofill_profile().guid() == guid) { 187 if (autofill_profile.specifics().autofill_profile().guid() == guid) {
190 entity_id = autofill_profile.id_string(); 188 entity_id = autofill_profile.id_string();
191 break; 189 break;
192 } 190 }
193 } 191 }
194 // Delete the entity if it exists. 192 // Delete the entity if it exists.
195 if (!entity_id.empty()) { 193 if (!entity_id.empty()) {
196 std::unique_ptr<fake_server::FakeServerEntity> entity; 194 std::unique_ptr<syncer::LoopbackServerEntity> entity;
197 entity = fake_server::TombstoneEntity::Create(entity_id, std::string()); 195 entity = syncer::PersistentTombstoneEntity::CreateForInjection(
196 entity_id, std::string());
198 gSyncFakeServer->InjectEntity(std::move(entity)); 197 gSyncFakeServer->InjectEntity(std::move(entity));
199 } 198 }
200 } 199 }
201 200
202 bool IsAutofillProfilePresent(std::string guid, std::string full_name) { 201 bool IsAutofillProfilePresent(std::string guid, std::string full_name) {
203 ios::ChromeBrowserState* browser_state = 202 ios::ChromeBrowserState* browser_state =
204 chrome_test_util::GetOriginalBrowserState(); 203 chrome_test_util::GetOriginalBrowserState();
205 autofill::PersonalDataManager* personal_data_manager = 204 autofill::PersonalDataManager* personal_data_manager =
206 autofill::PersonalDataManagerFactory::GetForBrowserState(browser_state); 205 autofill::PersonalDataManagerFactory::GetForBrowserState(browser_state);
207 autofill::AutofillProfile* autofill_profile = 206 autofill::AutofillProfile* autofill_profile =
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 255
257 void InjectTypedURLOnFakeSyncServer(const std::string& url) { 256 void InjectTypedURLOnFakeSyncServer(const std::string& url) {
258 DCHECK(gSyncFakeServer); 257 DCHECK(gSyncFakeServer);
259 sync_pb::EntitySpecifics entitySpecifics; 258 sync_pb::EntitySpecifics entitySpecifics;
260 sync_pb::TypedUrlSpecifics* typedUrl = entitySpecifics.mutable_typed_url(); 259 sync_pb::TypedUrlSpecifics* typedUrl = entitySpecifics.mutable_typed_url();
261 typedUrl->set_url(url); 260 typedUrl->set_url(url);
262 typedUrl->set_title(url); 261 typedUrl->set_title(url);
263 typedUrl->add_visits(base::Time::Max().ToInternalValue()); 262 typedUrl->add_visits(base::Time::Max().ToInternalValue());
264 typedUrl->add_visit_transitions(sync_pb::SyncEnums::TYPED); 263 typedUrl->add_visit_transitions(sync_pb::SyncEnums::TYPED);
265 264
266 std::unique_ptr<fake_server::FakeServerEntity> entity = 265 std::unique_ptr<syncer::LoopbackServerEntity> entity =
267 fake_server::UniqueClientEntity::CreateForInjection(url, entitySpecifics); 266 syncer::PersistentUniqueClientEntity::CreateForInjection(url,
267 entitySpecifics);
268 gSyncFakeServer->InjectEntity(std::move(entity)); 268 gSyncFakeServer->InjectEntity(std::move(entity));
269 } 269 }
270 270
271 BOOL IsTypedUrlPresentOnClient(const GURL& url, 271 BOOL IsTypedUrlPresentOnClient(const GURL& url,
272 BOOL expect_present, 272 BOOL expect_present,
273 NSError** error) { 273 NSError** error) {
274 // Call the history service. 274 // Call the history service.
275 ios::ChromeBrowserState* browser_state = 275 ios::ChromeBrowserState* browser_state =
276 chrome_test_util::GetOriginalBrowserState(); 276 chrome_test_util::GetOriginalBrowserState();
277 history::HistoryService* history_service = 277 history::HistoryService* history_service =
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 std::vector<sync_pb::SyncEntity> typed_urls = 335 std::vector<sync_pb::SyncEntity> typed_urls =
336 gSyncFakeServer->GetSyncEntitiesByModelType(syncer::TYPED_URLS); 336 gSyncFakeServer->GetSyncEntitiesByModelType(syncer::TYPED_URLS);
337 std::string entity_id; 337 std::string entity_id;
338 for (const sync_pb::SyncEntity& typed_url : typed_urls) { 338 for (const sync_pb::SyncEntity& typed_url : typed_urls) {
339 if (typed_url.specifics().typed_url().url() == url) { 339 if (typed_url.specifics().typed_url().url() == url) {
340 entity_id = typed_url.id_string(); 340 entity_id = typed_url.id_string();
341 break; 341 break;
342 } 342 }
343 } 343 }
344 if (!entity_id.empty()) { 344 if (!entity_id.empty()) {
345 std::unique_ptr<fake_server::FakeServerEntity> entity; 345 std::unique_ptr<syncer::LoopbackServerEntity> entity;
346 entity = fake_server::TombstoneEntity::Create(entity_id, std::string()); 346 entity = syncer::PersistentTombstoneEntity::CreateForInjection(
347 entity_id, std::string());
347 gSyncFakeServer->InjectEntity(std::move(entity)); 348 gSyncFakeServer->InjectEntity(std::move(entity));
348 } 349 }
349 } 350 }
350 351
351 } // namespace chrome_test_util 352 } // namespace chrome_test_util
OLDNEW
« no previous file with comments | « components/sync/test/fake_server/unique_client_entity.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698