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

Side by Side Diff: components/search_engines/template_url_service_sync_unittest.cc

Issue 655143002: Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/memory/scoped_vector.h" 6 #include "base/memory/scoped_vector.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 test_util_b_->VerifyLoad(); 238 test_util_b_->VerifyLoad();
239 } 239 }
240 240
241 void TemplateURLServiceSyncTest::TearDown() { 241 void TemplateURLServiceSyncTest::TearDown() {
242 test_util_a_.reset(); 242 test_util_a_.reset();
243 DefaultSearchManager::SetFallbackSearchEnginesDisabledForTesting(false); 243 DefaultSearchManager::SetFallbackSearchEnginesDisabledForTesting(false);
244 } 244 }
245 245
246 scoped_ptr<syncer::SyncChangeProcessor> 246 scoped_ptr<syncer::SyncChangeProcessor>
247 TemplateURLServiceSyncTest::PassProcessor() { 247 TemplateURLServiceSyncTest::PassProcessor() {
248 return sync_processor_wrapper_.PassAs<syncer::SyncChangeProcessor>(); 248 return sync_processor_wrapper_.Pass();
249 } 249 }
250 250
251 scoped_ptr<syncer::SyncErrorFactory> TemplateURLServiceSyncTest:: 251 scoped_ptr<syncer::SyncErrorFactory> TemplateURLServiceSyncTest::
252 CreateAndPassSyncErrorFactory() { 252 CreateAndPassSyncErrorFactory() {
253 return scoped_ptr<syncer::SyncErrorFactory>( 253 return scoped_ptr<syncer::SyncErrorFactory>(
254 new syncer::SyncErrorFactoryMock()); 254 new syncer::SyncErrorFactoryMock());
255 } 255 }
256 256
257 TemplateURL* TemplateURLServiceSyncTest::CreateTestTemplateURL( 257 TemplateURL* TemplateURLServiceSyncTest::CreateTestTemplateURL(
258 const base::string16& keyword, 258 const base::string16& keyword,
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 TEST_F(TemplateURLServiceSyncTest, MergeTwoClientsBasic) { 1279 TEST_F(TemplateURLServiceSyncTest, MergeTwoClientsBasic) {
1280 // Start off B with some empty data. 1280 // Start off B with some empty data.
1281 model_b()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES, 1281 model_b()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES,
1282 CreateInitialSyncData(), PassProcessor(), 1282 CreateInitialSyncData(), PassProcessor(),
1283 CreateAndPassSyncErrorFactory()); 1283 CreateAndPassSyncErrorFactory());
1284 1284
1285 // Merge A and B. All of B's data should transfer over to A, which initially 1285 // Merge A and B. All of B's data should transfer over to A, which initially
1286 // has no data. 1286 // has no data.
1287 scoped_ptr<syncer::SyncChangeProcessorWrapperForTest> delegate_b( 1287 scoped_ptr<syncer::SyncChangeProcessorWrapperForTest> delegate_b(
1288 new syncer::SyncChangeProcessorWrapperForTest(model_b())); 1288 new syncer::SyncChangeProcessorWrapperForTest(model_b()));
1289 model_a()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES, 1289 model_a()->MergeDataAndStartSyncing(
1290 syncer::SEARCH_ENGINES,
1290 model_b()->GetAllSyncData(syncer::SEARCH_ENGINES), 1291 model_b()->GetAllSyncData(syncer::SEARCH_ENGINES),
1291 delegate_b.PassAs<syncer::SyncChangeProcessor>(), 1292 delegate_b.Pass(),
1292 CreateAndPassSyncErrorFactory()); 1293 CreateAndPassSyncErrorFactory());
1293 1294
1294 // They should be consistent. 1295 // They should be consistent.
1295 AssertEquals(model_a()->GetAllSyncData(syncer::SEARCH_ENGINES), 1296 AssertEquals(model_a()->GetAllSyncData(syncer::SEARCH_ENGINES),
1296 model_b()->GetAllSyncData(syncer::SEARCH_ENGINES)); 1297 model_b()->GetAllSyncData(syncer::SEARCH_ENGINES));
1297 } 1298 }
1298 1299
1299 TEST_F(TemplateURLServiceSyncTest, MergeTwoClientsDupesAndConflicts) { 1300 TEST_F(TemplateURLServiceSyncTest, MergeTwoClientsDupesAndConflicts) {
1300 // Start off B with some empty data. 1301 // Start off B with some empty data.
1301 model_b()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES, 1302 model_b()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES,
1302 CreateInitialSyncData(), PassProcessor(), 1303 CreateInitialSyncData(), PassProcessor(),
1303 CreateAndPassSyncErrorFactory()); 1304 CreateAndPassSyncErrorFactory());
1304 1305
1305 // Set up A so we have some interesting duplicates and conflicts. 1306 // Set up A so we have some interesting duplicates and conflicts.
1306 model_a()->Add(CreateTestTemplateURL(ASCIIToUTF16("key4"), "http://key4.com", 1307 model_a()->Add(CreateTestTemplateURL(ASCIIToUTF16("key4"), "http://key4.com",
1307 "key4")); // Added 1308 "key4")); // Added
1308 model_a()->Add(CreateTestTemplateURL(ASCIIToUTF16("key2"), "http://key2.com", 1309 model_a()->Add(CreateTestTemplateURL(ASCIIToUTF16("key2"), "http://key2.com",
1309 "key2")); // Merge - Copy of key2. 1310 "key2")); // Merge - Copy of key2.
1310 model_a()->Add(CreateTestTemplateURL(ASCIIToUTF16("key3"), "http://key3.com", 1311 model_a()->Add(CreateTestTemplateURL(ASCIIToUTF16("key3"), "http://key3.com",
1311 "key5", 10)); // Merge - Dupe of key3. 1312 "key5", 10)); // Merge - Dupe of key3.
1312 model_a()->Add(CreateTestTemplateURL(ASCIIToUTF16("key1"), "http://key6.com", 1313 model_a()->Add(CreateTestTemplateURL(ASCIIToUTF16("key1"), "http://key6.com",
1313 "key6", 10)); // Conflict with key1 1314 "key6", 10)); // Conflict with key1
1314 1315
1315 // Merge A and B. 1316 // Merge A and B.
1316 scoped_ptr<syncer::SyncChangeProcessorWrapperForTest> delegate_b( 1317 scoped_ptr<syncer::SyncChangeProcessorWrapperForTest> delegate_b(
1317 new syncer::SyncChangeProcessorWrapperForTest(model_b())); 1318 new syncer::SyncChangeProcessorWrapperForTest(model_b()));
1318 model_a()->MergeDataAndStartSyncing(syncer::SEARCH_ENGINES, 1319 model_a()->MergeDataAndStartSyncing(
1320 syncer::SEARCH_ENGINES,
1319 model_b()->GetAllSyncData(syncer::SEARCH_ENGINES), 1321 model_b()->GetAllSyncData(syncer::SEARCH_ENGINES),
1320 delegate_b.PassAs<syncer::SyncChangeProcessor>(), 1322 delegate_b.Pass(),
1321 CreateAndPassSyncErrorFactory()); 1323 CreateAndPassSyncErrorFactory());
1322 1324
1323 // They should be consistent. 1325 // They should be consistent.
1324 AssertEquals(model_a()->GetAllSyncData(syncer::SEARCH_ENGINES), 1326 AssertEquals(model_a()->GetAllSyncData(syncer::SEARCH_ENGINES),
1325 model_b()->GetAllSyncData(syncer::SEARCH_ENGINES)); 1327 model_b()->GetAllSyncData(syncer::SEARCH_ENGINES));
1326 } 1328 }
1327 1329
1328 TEST_F(TemplateURLServiceSyncTest, StopSyncing) { 1330 TEST_F(TemplateURLServiceSyncTest, StopSyncing) {
1329 syncer::SyncError error = 1331 syncer::SyncError error =
1330 model()->MergeDataAndStartSyncing( 1332 model()->MergeDataAndStartSyncing(
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 const char kNewGUID[] = "newdefault"; 2232 const char kNewGUID[] = "newdefault";
2231 model()->Add(CreateTestTemplateURL(ASCIIToUTF16("what"), 2233 model()->Add(CreateTestTemplateURL(ASCIIToUTF16("what"),
2232 "http://thewhat.com/{searchTerms}", 2234 "http://thewhat.com/{searchTerms}",
2233 kNewGUID)); 2235 kNewGUID));
2234 model()->SetUserSelectedDefaultSearchProvider( 2236 model()->SetUserSelectedDefaultSearchProvider(
2235 model()->GetTemplateURLForGUID(kNewGUID)); 2237 model()->GetTemplateURLForGUID(kNewGUID));
2236 2238
2237 EXPECT_EQ(kNewGUID, profile_a()->GetTestingPrefService()->GetString( 2239 EXPECT_EQ(kNewGUID, profile_a()->GetTestingPrefService()->GetString(
2238 prefs::kSyncedDefaultSearchProviderGUID)); 2240 prefs::kSyncedDefaultSearchProviderGUID));
2239 } 2241 }
OLDNEW
« no previous file with comments | « components/proximity_auth/bluetooth_connection_unittest.cc ('k') | components/sync_driver/fake_generic_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698