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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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.h" 10 #include "base/message_loop.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // None of these storage areas are owned by this factory, so care must be 194 // None of these storage areas are owned by this factory, so care must be
195 // taken when calling GetExisting. 195 // taken when calling GetExisting.
196 std::map<std::string, TestingValueStore*> created_; 196 std::map<std::string, TestingValueStore*> created_;
197 }; 197 };
198 198
199 } // namespace 199 } // namespace
200 200
201 class ExtensionSettingsSyncTest : public testing::Test { 201 class ExtensionSettingsSyncTest : public testing::Test {
202 public: 202 public:
203 ExtensionSettingsSyncTest() 203 ExtensionSettingsSyncTest()
204 : ui_thread_(BrowserThread::UI, MessageLoop::current()), 204 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()),
205 file_thread_(BrowserThread::FILE, MessageLoop::current()), 205 file_thread_(BrowserThread::FILE, base::MessageLoop::current()),
206 storage_factory_(new util::ScopedSettingsStorageFactory()), 206 storage_factory_(new util::ScopedSettingsStorageFactory()),
207 sync_processor_(new MockSyncChangeProcessor), 207 sync_processor_(new MockSyncChangeProcessor),
208 sync_processor_delegate_(new SyncChangeProcessorDelegate( 208 sync_processor_delegate_(new SyncChangeProcessorDelegate(
209 sync_processor_.get())) {} 209 sync_processor_.get())) {}
210 210
211 virtual void SetUp() OVERRIDE { 211 virtual void SetUp() OVERRIDE {
212 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 212 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
213 profile_.reset(new util::MockProfile(temp_dir_.path())); 213 profile_.reset(new util::MockProfile(temp_dir_.path()));
214 storage_factory_->Reset(new LeveldbSettingsStorageFactory()); 214 storage_factory_->Reset(new LeveldbSettingsStorageFactory());
215 frontend_.reset( 215 frontend_.reset(
(...skipping 14 matching lines...) Expand all
230 const std::string& id, Manifest::Type type) { 230 const std::string& id, Manifest::Type type) {
231 ExtensionServiceInterface* esi = 231 ExtensionServiceInterface* esi =
232 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); 232 extensions::ExtensionSystem::Get(profile_.get())->extension_service();
233 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> 233 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)->
234 AddExtensionWithId(id, type); 234 AddExtensionWithId(id, type);
235 return util::GetStorage(id, frontend_.get()); 235 return util::GetStorage(id, frontend_.get());
236 } 236 }
237 237
238 // Gets the syncer::SyncableService for the given sync type. 238 // Gets the syncer::SyncableService for the given sync type.
239 syncer::SyncableService* GetSyncableService(syncer::ModelType model_type) { 239 syncer::SyncableService* GetSyncableService(syncer::ModelType model_type) {
240 MessageLoop::current()->RunUntilIdle(); 240 base::MessageLoop::current()->RunUntilIdle();
241 return frontend_->GetBackendForSync(model_type); 241 return frontend_->GetBackendForSync(model_type);
242 } 242 }
243 243
244 // Gets all the sync data from the SyncableService for a sync type as a map 244 // Gets all the sync data from the SyncableService for a sync type as a map
245 // from extension id to its sync data. 245 // from extension id to its sync data.
246 std::map<std::string, SettingSyncDataList> GetAllSyncData( 246 std::map<std::string, SettingSyncDataList> GetAllSyncData(
247 syncer::ModelType model_type) { 247 syncer::ModelType model_type) {
248 syncer::SyncDataList as_list = 248 syncer::SyncDataList as_list =
249 GetSyncableService(model_type)->GetAllSyncData(model_type); 249 GetSyncableService(model_type)->GetAllSyncData(model_type);
250 std::map<std::string, SettingSyncDataList> as_map; 250 std::map<std::string, SettingSyncDataList> as_map;
251 for (syncer::SyncDataList::iterator it = as_list.begin(); 251 for (syncer::SyncDataList::iterator it = as_list.begin();
252 it != as_list.end(); ++it) { 252 it != as_list.end(); ++it) {
253 SettingSyncData sync_data(*it); 253 SettingSyncData sync_data(*it);
254 as_map[sync_data.extension_id()].push_back(sync_data); 254 as_map[sync_data.extension_id()].push_back(sync_data);
255 } 255 }
256 return as_map; 256 return as_map;
257 } 257 }
258 258
259 // Need these so that the DCHECKs for running on FILE or UI threads pass. 259 // Need these so that the DCHECKs for running on FILE or UI threads pass.
260 MessageLoop message_loop_; 260 base::MessageLoop message_loop_;
261 content::TestBrowserThread ui_thread_; 261 content::TestBrowserThread ui_thread_;
262 content::TestBrowserThread file_thread_; 262 content::TestBrowserThread file_thread_;
263 263
264 base::ScopedTempDir temp_dir_; 264 base::ScopedTempDir temp_dir_;
265 scoped_ptr<util::MockProfile> profile_; 265 scoped_ptr<util::MockProfile> profile_;
266 scoped_ptr<SettingsFrontend> frontend_; 266 scoped_ptr<SettingsFrontend> frontend_;
267 scoped_refptr<util::ScopedSettingsStorageFactory> storage_factory_; 267 scoped_refptr<util::ScopedSettingsStorageFactory> storage_factory_;
268 scoped_ptr<MockSyncChangeProcessor> sync_processor_; 268 scoped_ptr<MockSyncChangeProcessor> sync_processor_;
269 scoped_ptr<SyncChangeProcessorDelegate> sync_processor_delegate_; 269 scoped_ptr<SyncChangeProcessorDelegate> sync_processor_delegate_;
270 }; 270 };
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 ASSERT_EQ(1u, sync_processor_->changes().size()); 1418 ASSERT_EQ(1u, sync_processor_->changes().size());
1419 SettingSyncData sync_data = sync_processor_->changes()[0]; 1419 SettingSyncData sync_data = sync_processor_->changes()[0];
1420 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type()); 1420 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type());
1421 EXPECT_EQ("ext", sync_data.extension_id()); 1421 EXPECT_EQ("ext", sync_data.extension_id());
1422 EXPECT_EQ("key.with.spot", sync_data.key()); 1422 EXPECT_EQ("key.with.spot", sync_data.key());
1423 EXPECT_TRUE(sync_data.value().Equals(string_value.get())); 1423 EXPECT_TRUE(sync_data.value().Equals(string_value.get()));
1424 } 1424 }
1425 } 1425 }
1426 1426
1427 } // namespace extensions 1427 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698