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

Side by Side Diff: chrome/browser/extensions/settings/settings_sync_unittest.cc

Issue 9414020: [Sync] Switch Extension Settings DTC to use ProfilesyncComponentsFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove RunWithSyncableService and clean up Created 8 years, 10 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 private: 162 private:
163 // SettingsStorageFactory is refcounted. 163 // SettingsStorageFactory is refcounted.
164 virtual ~TestingSettingsStorageFactory() {} 164 virtual ~TestingSettingsStorageFactory() {}
165 165
166 // None of these storage areas are owned by this factory, so care must be 166 // None of these storage areas are owned by this factory, so care must be
167 // taken when calling GetExisting. 167 // taken when calling GetExisting.
168 std::map<std::string, TestingSettingsStorage*> created_; 168 std::map<std::string, TestingSettingsStorage*> created_;
169 }; 169 };
170 170
171 void AssignSettingsService(SyncableService** dst, SyncableService* src) { 171 void AssignSettingsService(SyncableService** dst,
172 *dst = src; 172 const SettingsFrontend* frontend,
173 syncable::ModelType type) {
174 *dst = frontend->GetBackendForSync(type);
173 } 175 }
174 176
175 } // namespace 177 } // namespace
176 178
177 class ExtensionSettingsSyncTest : public testing::Test { 179 class ExtensionSettingsSyncTest : public testing::Test {
178 public: 180 public:
179 ExtensionSettingsSyncTest() 181 ExtensionSettingsSyncTest()
180 : ui_thread_(BrowserThread::UI, MessageLoop::current()), 182 : ui_thread_(BrowserThread::UI, MessageLoop::current()),
181 file_thread_(BrowserThread::FILE, MessageLoop::current()), 183 file_thread_(BrowserThread::FILE, MessageLoop::current()),
182 storage_factory_(new ScopedSettingsStorageFactory()) {} 184 storage_factory_(new ScopedSettingsStorageFactory()) {}
(...skipping 16 matching lines...) Expand all
199 // its storage area. 201 // its storage area.
200 SettingsStorage* AddExtensionAndGetStorage( 202 SettingsStorage* AddExtensionAndGetStorage(
201 const std::string& id, Extension::Type type) { 203 const std::string& id, Extension::Type type) {
202 profile_->GetMockExtensionService()->AddExtensionWithId(id, type); 204 profile_->GetMockExtensionService()->AddExtensionWithId(id, type);
203 return GetStorage(id, frontend_.get()); 205 return GetStorage(id, frontend_.get());
204 } 206 }
205 207
206 // Gets the SyncableService for the given sync type. 208 // Gets the SyncableService for the given sync type.
207 SyncableService* GetSyncableService(syncable::ModelType model_type) { 209 SyncableService* GetSyncableService(syncable::ModelType model_type) {
208 SyncableService* settings_service = NULL; 210 SyncableService* settings_service = NULL;
209 frontend_->RunWithSyncableService( 211 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
210 model_type, base::Bind(&AssignSettingsService, &settings_service)); 212 base::Bind(&AssignSettingsService,
213 &settings_service,
214 frontend_.get(),
215 model_type));
not at google - send to devlin 2012/02/16 22:58:44 Same comment here as in apitest.cc. Hopefully no n
Nicolas Zea 2012/02/23 00:27:58 Done.
not at google - send to devlin 2012/02/23 02:15:38 Same response as before.
Nicolas Zea 2012/02/24 21:38:04 See other comment.
211 MessageLoop::current()->RunAllPending(); 216 MessageLoop::current()->RunAllPending();
212 return settings_service; 217 return settings_service;
213 } 218 }
214 219
215 // Gets all the sync data from the SyncableService for a sync type as a map 220 // Gets all the sync data from the SyncableService for a sync type as a map
216 // from extension id to its sync data. 221 // from extension id to its sync data.
217 std::map<std::string, SettingSyncDataList> GetAllSyncData( 222 std::map<std::string, SettingSyncDataList> GetAllSyncData(
218 syncable::ModelType model_type) { 223 syncable::ModelType model_type) {
219 SyncDataList as_list = 224 SyncDataList as_list =
220 GetSyncableService(model_type)->GetAllSyncData(model_type); 225 GetSyncableService(model_type)->GetAllSyncData(model_type);
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 DictionaryValue expected; 1288 DictionaryValue expected;
1284 expected.Set("large_value", large_value.DeepCopy()); 1289 expected.Set("large_value", large_value.DeepCopy());
1285 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage1->Get()); 1290 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage1->Get());
1286 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage2->Get()); 1291 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage2->Get());
1287 } 1292 }
1288 1293
1289 GetSyncableService(model_type)->StopSyncing(model_type); 1294 GetSyncableService(model_type)->StopSyncing(model_type);
1290 } 1295 }
1291 1296
1292 } // namespace extensions 1297 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698