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

Side by Side Diff: chrome/browser/extensions/api/storage/settings_sync_unittest.cc

Issue 184043031: Split up extensions storage API implementations for sync and local storage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (split_sync) Created 6 years, 9 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/bind.h" 5 #include "base/bind.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory .h" 11 #include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory .h"
12 #include "chrome/browser/extensions/api/storage/settings_frontend.h" 12 #include "chrome/browser/extensions/api/storage/settings_frontend.h"
13 #include "chrome/browser/extensions/api/storage/settings_storage_factory.h" 13 #include "chrome/browser/extensions/api/storage/settings_storage_factory.h"
14 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" 14 #include "chrome/browser/extensions/api/storage/settings_sync_util.h"
15 #include "chrome/browser/extensions/api/storage/settings_test_util.h" 15 #include "chrome/browser/extensions/api/storage/settings_test_util.h"
16 #include "chrome/browser/extensions/api/storage/sync_value_store_cache.h"
16 #include "chrome/browser/extensions/api/storage/syncable_settings_storage.h" 17 #include "chrome/browser/extensions/api/storage/syncable_settings_storage.h"
17 #include "chrome/browser/extensions/test_extension_service.h" 18 #include "chrome/browser/extensions/test_extension_service.h"
18 #include "content/public/test/test_browser_thread.h" 19 #include "content/public/test/test_browser_thread.h"
19 #include "extensions/browser/extension_system.h" 20 #include "extensions/browser/extension_system.h"
20 #include "extensions/browser/value_store/testing_value_store.h" 21 #include "extensions/browser/value_store/testing_value_store.h"
21 #include "extensions/common/manifest.h" 22 #include "extensions/common/manifest.h"
22 #include "sync/api/sync_change_processor.h" 23 #include "sync/api/sync_change_processor.h"
23 #include "sync/api/sync_change_processor_wrapper_for_test.h" 24 #include "sync/api/sync_change_processor_wrapper_for_test.h"
24 #include "sync/api/sync_error_factory.h" 25 #include "sync/api/sync_error_factory.h"
25 #include "sync/api/sync_error_factory_mock.h" 26 #include "sync/api/sync_error_factory_mock.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 ValueStore* AddExtensionAndGetStorage( 225 ValueStore* AddExtensionAndGetStorage(
225 const std::string& id, Manifest::Type type) { 226 const std::string& id, Manifest::Type type) {
226 scoped_refptr<const Extension> extension = 227 scoped_refptr<const Extension> extension =
227 util::AddExtensionWithId(profile_.get(), id, type); 228 util::AddExtensionWithId(profile_.get(), id, type);
228 return util::GetStorage(extension, frontend_.get()); 229 return util::GetStorage(extension, frontend_.get());
229 } 230 }
230 231
231 // Gets the syncer::SyncableService for the given sync type. 232 // Gets the syncer::SyncableService for the given sync type.
232 syncer::SyncableService* GetSyncableService(syncer::ModelType model_type) { 233 syncer::SyncableService* GetSyncableService(syncer::ModelType model_type) {
233 base::MessageLoop::current()->RunUntilIdle(); 234 base::MessageLoop::current()->RunUntilIdle();
234 return frontend_->GetBackendForSync(model_type); 235 SyncValueStoreCache* sync_cache = static_cast<SyncValueStoreCache*>(
236 frontend_->GetValueStoreCache(settings_namespace::SYNC));
237 return sync_cache->GetSyncableService(model_type);
235 } 238 }
236 239
237 // Gets all the sync data from the SyncableService for a sync type as a map 240 // Gets all the sync data from the SyncableService for a sync type as a map
238 // from extension id to its sync data. 241 // from extension id to its sync data.
239 std::map<std::string, SettingSyncDataList> GetAllSyncData( 242 std::map<std::string, SettingSyncDataList> GetAllSyncData(
240 syncer::ModelType model_type) { 243 syncer::ModelType model_type) {
241 syncer::SyncDataList as_list = 244 syncer::SyncDataList as_list =
242 GetSyncableService(model_type)->GetAllSyncData(model_type); 245 GetSyncableService(model_type)->GetAllSyncData(model_type);
243 std::map<std::string, SettingSyncDataList> as_map; 246 std::map<std::string, SettingSyncDataList> as_map;
244 for (syncer::SyncDataList::iterator it = as_list.begin(); 247 for (syncer::SyncDataList::iterator it = as_list.begin();
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 ASSERT_EQ(1u, sync_processor_->changes().size()); 1418 ASSERT_EQ(1u, sync_processor_->changes().size());
1416 SettingSyncData sync_data = sync_processor_->changes()[0]; 1419 SettingSyncData sync_data = sync_processor_->changes()[0];
1417 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type()); 1420 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type());
1418 EXPECT_EQ("ext", sync_data.extension_id()); 1421 EXPECT_EQ("ext", sync_data.extension_id());
1419 EXPECT_EQ("key.with.spot", sync_data.key()); 1422 EXPECT_EQ("key.with.spot", sync_data.key());
1420 EXPECT_TRUE(sync_data.value().Equals(string_value.get())); 1423 EXPECT_TRUE(sync_data.value().Equals(string_value.get()));
1421 } 1424 }
1422 } 1425 }
1423 1426
1424 } // namespace extensions 1427 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698