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

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: Address comments 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 15 matching lines...) Expand all
198 // Adds a record of an extension or app to the extension service, then returns 200 // Adds a record of an extension or app to the extension service, then returns
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;
209 frontend_->RunWithSyncableService(
210 model_type, base::Bind(&AssignSettingsService, &settings_service));
211 MessageLoop::current()->RunAllPending(); 210 MessageLoop::current()->RunAllPending();
212 return settings_service; 211 return frontend_->GetBackendForSync(model_type);
213 } 212 }
214 213
215 // Gets all the sync data from the SyncableService for a sync type as a map 214 // Gets all the sync data from the SyncableService for a sync type as a map
216 // from extension id to its sync data. 215 // from extension id to its sync data.
217 std::map<std::string, SettingSyncDataList> GetAllSyncData( 216 std::map<std::string, SettingSyncDataList> GetAllSyncData(
218 syncable::ModelType model_type) { 217 syncable::ModelType model_type) {
219 SyncDataList as_list = 218 SyncDataList as_list =
220 GetSyncableService(model_type)->GetAllSyncData(model_type); 219 GetSyncableService(model_type)->GetAllSyncData(model_type);
221 std::map<std::string, SettingSyncDataList> as_map; 220 std::map<std::string, SettingSyncDataList> as_map;
222 for (SyncDataList::iterator it = as_list.begin(); 221 for (SyncDataList::iterator it = as_list.begin();
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 DictionaryValue expected; 1282 DictionaryValue expected;
1284 expected.Set("large_value", large_value.DeepCopy()); 1283 expected.Set("large_value", large_value.DeepCopy());
1285 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage1->Get()); 1284 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage1->Get());
1286 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage2->Get()); 1285 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage2->Get());
1287 } 1286 }
1288 1287
1289 GetSyncableService(model_type)->StopSyncing(model_type); 1288 GetSyncableService(model_type)->StopSyncing(model_type);
1290 } 1289 }
1291 1290
1292 } // namespace extensions 1291 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698