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

Side by Side Diff: chrome/browser/search_engines/template_url_service_sync_unittest.cc

Issue 9834056: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments, fixed bug Created 8 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 | Annotate | Revision Log
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/string_util.h" 6 #include "base/string_util.h"
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/search_engines/template_url.h" 9 #include "chrome/browser/search_engines/template_url.h"
10 #include "chrome/browser/search_engines/template_url_service.h" 10 #include "chrome/browser/search_engines/template_url_service.h"
11 #include "chrome/browser/search_engines/template_url_service_factory.h" 11 #include "chrome/browser/search_engines/template_url_service_factory.h"
12 #include "chrome/browser/webdata/web_data_service_factory.h"
12 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
13 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
14 #include "chrome/test/base/testing_pref_service.h" 15 #include "chrome/test/base/testing_pref_service.h"
15 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
16 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
17 #include "sync/protocol/search_engine_specifics.pb.h" 18 #include "sync/protocol/search_engine_specifics.pb.h"
18 #include "sync/protocol/sync.pb.h" 19 #include "sync/protocol/sync.pb.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 using base::Time; 22 using base::Time;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 public: 154 public:
154 typedef TemplateURLService::SyncDataMap SyncDataMap; 155 typedef TemplateURLService::SyncDataMap SyncDataMap;
155 156
156 TemplateURLServiceSyncTest() 157 TemplateURLServiceSyncTest()
157 : sync_processor_(new TestChangeProcessor), 158 : sync_processor_(new TestChangeProcessor),
158 sync_processor_delegate_(new SyncChangeProcessorDelegate( 159 sync_processor_delegate_(new SyncChangeProcessorDelegate(
159 sync_processor_.get())) {} 160 sync_processor_.get())) {}
160 161
161 virtual void SetUp() { 162 virtual void SetUp() {
162 profile_a_.reset(new TestingProfile); 163 profile_a_.reset(new TestingProfile);
164 WebDataServiceFactory::GetInstance()->SetTestingFactory(profile_a_.get(),
165 NULL);
163 TemplateURLServiceFactory::GetInstance()->RegisterUserPrefsOnProfile( 166 TemplateURLServiceFactory::GetInstance()->RegisterUserPrefsOnProfile(
164 profile_a_.get()); 167 profile_a_.get());
165 model_a_.reset(new TemplateURLService(profile_a_.get())); 168 model_a_.reset(new TemplateURLService(profile_a_.get()));
166 model_a_->Load(); 169 model_a_->Load();
167 profile_b_.reset(new TestingProfile); 170 profile_b_.reset(new TestingProfile);
171 WebDataServiceFactory::GetInstance()->SetTestingFactory(profile_b_.get(),
172 NULL);
168 TemplateURLServiceFactory::GetInstance()->RegisterUserPrefsOnProfile( 173 TemplateURLServiceFactory::GetInstance()->RegisterUserPrefsOnProfile(
169 profile_b_.get()); 174 profile_b_.get());
170 model_b_.reset(new TemplateURLService(profile_b_.get())); 175 model_b_.reset(new TemplateURLService(profile_b_.get()));
171 model_b_->Load(); 176 model_b_->Load();
172 } 177 }
173 178
174 virtual void TearDown() { } 179 virtual void TearDown() { }
175 180
176 TemplateURLService* model() { return model_a_.get(); } 181 TemplateURLService* model() { return model_a_.get(); }
177 // For readability, we redefine an accessor for Model A for use in tests that 182 // For readability, we redefine an accessor for Model A for use in tests that
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 1253
1249 // The key1 entry should be a duplicate of the default. 1254 // The key1 entry should be a duplicate of the default.
1250 model()->MergeDataAndStartSyncing(syncable::SEARCH_ENGINES, 1255 model()->MergeDataAndStartSyncing(syncable::SEARCH_ENGINES,
1251 CreateInitialSyncData(), PassProcessor()); 1256 CreateInitialSyncData(), PassProcessor());
1252 1257
1253 EXPECT_EQ(3U, model()->GetAllSyncData(syncable::SEARCH_ENGINES).size()); 1258 EXPECT_EQ(3U, model()->GetAllSyncData(syncable::SEARCH_ENGINES).size());
1254 EXPECT_FALSE(model()->GetTemplateURLForGUID("whateverguid")); 1259 EXPECT_FALSE(model()->GetTemplateURLForGUID("whateverguid"));
1255 EXPECT_EQ(model()->GetDefaultSearchProvider(), 1260 EXPECT_EQ(model()->GetDefaultSearchProvider(),
1256 model()->GetTemplateURLForGUID("key1")); 1261 model()->GetTemplateURLForGUID("key1"));
1257 } 1262 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698