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

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: DCHECK 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 private: 160 private:
161 // SettingsStorageFactory is refcounted. 161 // SettingsStorageFactory is refcounted.
162 virtual ~TestingSettingsStorageFactory() {} 162 virtual ~TestingSettingsStorageFactory() {}
163 163
164 // None of these storage areas are owned by this factory, so care must be 164 // None of these storage areas are owned by this factory, so care must be
165 // taken when calling GetExisting. 165 // taken when calling GetExisting.
166 std::map<std::string, TestingSettingsStorage*> created_; 166 std::map<std::string, TestingSettingsStorage*> created_;
167 }; 167 };
168 168
169 void AssignSettingsService(SyncableService** dst, SyncableService* src) { 169 void AssignSettingsService(SyncableService** dst,
170 *dst = src; 170 const SettingsFrontend* frontend,
171 syncable::ModelType type) {
172 *dst = frontend->GetBackendForSync(type);
171 } 173 }
172 174
173 } // namespace 175 } // namespace
174 176
175 class ExtensionSettingsSyncTest : public testing::Test { 177 class ExtensionSettingsSyncTest : public testing::Test {
176 public: 178 public:
177 ExtensionSettingsSyncTest() 179 ExtensionSettingsSyncTest()
178 : ui_thread_(BrowserThread::UI, MessageLoop::current()), 180 : ui_thread_(BrowserThread::UI, MessageLoop::current()),
179 file_thread_(BrowserThread::FILE, MessageLoop::current()), 181 file_thread_(BrowserThread::FILE, MessageLoop::current()),
180 storage_factory_(new ScopedSettingsStorageFactory()) {} 182 storage_factory_(new ScopedSettingsStorageFactory()) {}
(...skipping 15 matching lines...) Expand all
196 // Adds a record of an extension or app to the extension service, then returns 198 // Adds a record of an extension or app to the extension service, then returns
197 // its storage area. 199 // its storage area.
198 SettingsStorage* AddExtensionAndGetStorage( 200 SettingsStorage* AddExtensionAndGetStorage(
199 const std::string& id, Extension::Type type) { 201 const std::string& id, Extension::Type type) {
200 profile_->GetMockExtensionService()->AddExtensionWithId(id, type); 202 profile_->GetMockExtensionService()->AddExtensionWithId(id, type);
201 return GetStorage(id, frontend_.get()); 203 return GetStorage(id, frontend_.get());
202 } 204 }
203 205
204 // Gets the SyncableService for the given sync type. 206 // Gets the SyncableService for the given sync type.
205 SyncableService* GetSyncableService(syncable::ModelType model_type) { 207 SyncableService* GetSyncableService(syncable::ModelType model_type) {
206 SyncableService* settings_service = NULL;
207 frontend_->RunWithSyncableService(
208 model_type, base::Bind(&AssignSettingsService, &settings_service));
209 MessageLoop::current()->RunAllPending(); 208 MessageLoop::current()->RunAllPending();
210 return settings_service; 209 return frontend_->GetBackendForSync(model_type);
211 } 210 }
212 211
213 // Gets all the sync data from the SyncableService for a sync type as a map 212 // Gets all the sync data from the SyncableService for a sync type as a map
214 // from extension id to its sync data. 213 // from extension id to its sync data.
215 std::map<std::string, SettingSyncDataList> GetAllSyncData( 214 std::map<std::string, SettingSyncDataList> GetAllSyncData(
216 syncable::ModelType model_type) { 215 syncable::ModelType model_type) {
217 SyncDataList as_list = 216 SyncDataList as_list =
218 GetSyncableService(model_type)->GetAllSyncData(model_type); 217 GetSyncableService(model_type)->GetAllSyncData(model_type);
219 std::map<std::string, SettingSyncDataList> as_map; 218 std::map<std::string, SettingSyncDataList> as_map;
220 for (SyncDataList::iterator it = as_list.begin(); 219 for (SyncDataList::iterator it = as_list.begin();
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 DictionaryValue expected; 1280 DictionaryValue expected;
1282 expected.Set("large_value", large_value.DeepCopy()); 1281 expected.Set("large_value", large_value.DeepCopy());
1283 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage1->Get()); 1282 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage1->Get());
1284 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage2->Get()); 1283 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage2->Get());
1285 } 1284 }
1286 1285
1287 GetSyncableService(model_type)->StopSyncing(model_type); 1286 GetSyncableService(model_type)->StopSyncing(model_type);
1288 } 1287 }
1289 1288
1290 } // namespace extensions 1289 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698