| OLD | NEW |
| 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/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "chrome/browser/search_engines/template_url_service.h" | 11 #include "chrome/browser/search_engines/template_url_service.h" |
| 12 #include "chrome/browser/search_engines/template_url_service_client.h" |
| 12 #include "chrome/browser/search_engines/template_url_service_factory.h" | 13 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 13 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 14 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
| 14 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 15 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
| 15 #include "chrome/test/base/testing_pref_service_syncable.h" | 16 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 17 #include "components/search_engines/search_engines_pref_names.h" | 18 #include "components/search_engines/search_engines_pref_names.h" |
| 18 #include "components/search_engines/template_url.h" | 19 #include "components/search_engines/template_url.h" |
| 19 #include "components/search_engines/template_url_prepopulate_data.h" | 20 #include "components/search_engines/template_url_prepopulate_data.h" |
| 20 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
| 21 #include "sync/api/sync_change_processor_wrapper_for_test.h" | 22 #include "sync/api/sync_change_processor_wrapper_for_test.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 void TemplateURLServiceSyncTest::SetUp() { | 229 void TemplateURLServiceSyncTest::SetUp() { |
| 229 DefaultSearchManager::SetFallbackSearchEnginesDisabledForTesting(true); | 230 DefaultSearchManager::SetFallbackSearchEnginesDisabledForTesting(true); |
| 230 test_util_a_.SetUp(); | 231 test_util_a_.SetUp(); |
| 231 // Use ChangeToLoadState() instead of VerifyLoad() so we don't actually pull | 232 // Use ChangeToLoadState() instead of VerifyLoad() so we don't actually pull |
| 232 // in the prepopulate data, which the sync tests don't care about (and would | 233 // in the prepopulate data, which the sync tests don't care about (and would |
| 233 // just foul them up). | 234 // just foul them up). |
| 234 test_util_a_.ChangeModelToLoadState(); | 235 test_util_a_.ChangeModelToLoadState(); |
| 235 profile_b_.reset(new TestingProfile); | 236 profile_b_.reset(new TestingProfile); |
| 236 TemplateURLServiceFactory::GetInstance()-> | 237 TemplateURLServiceFactory::GetInstance()-> |
| 237 RegisterUserPrefsOnBrowserContextForTest(profile_b_.get()); | 238 RegisterUserPrefsOnBrowserContextForTest(profile_b_.get()); |
| 238 model_b_.reset(new TemplateURLService(profile_b_.get(), NULL, | 239 model_b_.reset(new TemplateURLService( |
| 239 base::Closure())); | 240 profile_b_->GetPrefs(), scoped_ptr<SearchTermsData>( |
| 241 new UIThreadSearchTermsData(profile_b_.get())), NULL, |
| 242 scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure())); |
| 240 model_b_->Load(); | 243 model_b_->Load(); |
| 241 } | 244 } |
| 242 | 245 |
| 243 void TemplateURLServiceSyncTest::TearDown() { | 246 void TemplateURLServiceSyncTest::TearDown() { |
| 244 test_util_a_.TearDown(); | 247 test_util_a_.TearDown(); |
| 245 DefaultSearchManager::SetFallbackSearchEnginesDisabledForTesting(false); | 248 DefaultSearchManager::SetFallbackSearchEnginesDisabledForTesting(false); |
| 246 } | 249 } |
| 247 | 250 |
| 248 scoped_ptr<syncer::SyncChangeProcessor> | 251 scoped_ptr<syncer::SyncChangeProcessor> |
| 249 TemplateURLServiceSyncTest::PassProcessor() { | 252 TemplateURLServiceSyncTest::PassProcessor() { |
| (...skipping 1982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2232 const char kNewGUID[] = "newdefault"; | 2235 const char kNewGUID[] = "newdefault"; |
| 2233 model()->Add(CreateTestTemplateURL(ASCIIToUTF16("what"), | 2236 model()->Add(CreateTestTemplateURL(ASCIIToUTF16("what"), |
| 2234 "http://thewhat.com/{searchTerms}", | 2237 "http://thewhat.com/{searchTerms}", |
| 2235 kNewGUID)); | 2238 kNewGUID)); |
| 2236 model()->SetUserSelectedDefaultSearchProvider( | 2239 model()->SetUserSelectedDefaultSearchProvider( |
| 2237 model()->GetTemplateURLForGUID(kNewGUID)); | 2240 model()->GetTemplateURLForGUID(kNewGUID)); |
| 2238 | 2241 |
| 2239 EXPECT_EQ(kNewGUID, profile_a()->GetTestingPrefService()->GetString( | 2242 EXPECT_EQ(kNewGUID, profile_a()->GetTestingPrefService()->GetString( |
| 2240 prefs::kSyncedDefaultSearchProviderGUID)); | 2243 prefs::kSyncedDefaultSearchProviderGUID)); |
| 2241 } | 2244 } |
| OLD | NEW |