OLD | NEW |
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/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 profile_.reset(new util::MockProfile(temp_dir_.path())); | 210 profile_.reset(new util::MockProfile(temp_dir_.path())); |
211 storage_factory_->Reset(new LeveldbSettingsStorageFactory()); | 211 storage_factory_->Reset(new LeveldbSettingsStorageFactory()); |
212 frontend_.reset( | 212 frontend_.reset( |
213 SettingsFrontend::Create(storage_factory_.get(), profile_.get())); | 213 SettingsFrontend::Create(storage_factory_.get(), profile_.get())); |
214 } | 214 } |
215 | 215 |
216 virtual void TearDown() OVERRIDE { | 216 virtual void TearDown() OVERRIDE { |
217 frontend_.reset(); | 217 frontend_.reset(); |
218 profile_.reset(); | 218 profile_.reset(); |
219 // Execute any pending deletion tasks. | 219 // Execute any pending deletion tasks. |
220 message_loop_.RunAllPending(); | 220 message_loop_.RunUntilIdle(); |
221 } | 221 } |
222 | 222 |
223 protected: | 223 protected: |
224 // Adds a record of an extension or app to the extension service, then returns | 224 // Adds a record of an extension or app to the extension service, then returns |
225 // its storage area. | 225 // its storage area. |
226 ValueStore* AddExtensionAndGetStorage( | 226 ValueStore* AddExtensionAndGetStorage( |
227 const std::string& id, Extension::Type type) { | 227 const std::string& id, Extension::Type type) { |
228 profile_->GetMockExtensionService()->AddExtensionWithId(id, type); | 228 profile_->GetMockExtensionService()->AddExtensionWithId(id, type); |
229 return util::GetStorage(id, frontend_.get()); | 229 return util::GetStorage(id, frontend_.get()); |
230 } | 230 } |
231 | 231 |
232 // Gets the syncer::SyncableService for the given sync type. | 232 // Gets the syncer::SyncableService for the given sync type. |
233 syncer::SyncableService* GetSyncableService(syncer::ModelType model_type) { | 233 syncer::SyncableService* GetSyncableService(syncer::ModelType model_type) { |
234 MessageLoop::current()->RunAllPending(); | 234 MessageLoop::current()->RunUntilIdle(); |
235 return frontend_->GetBackendForSync(model_type); | 235 return frontend_->GetBackendForSync(model_type); |
236 } | 236 } |
237 | 237 |
238 // Gets all the sync data from the SyncableService for a sync type as a map | 238 // Gets all the sync data from the SyncableService for a sync type as a map |
239 // from extension id to its sync data. | 239 // from extension id to its sync data. |
240 std::map<std::string, SettingSyncDataList> GetAllSyncData( | 240 std::map<std::string, SettingSyncDataList> GetAllSyncData( |
241 syncer::ModelType model_type) { | 241 syncer::ModelType model_type) { |
242 syncer::SyncDataList as_list = | 242 syncer::SyncDataList as_list = |
243 GetSyncableService(model_type)->GetAllSyncData(model_type); | 243 GetSyncableService(model_type)->GetAllSyncData(model_type); |
244 std::map<std::string, SettingSyncDataList> as_map; | 244 std::map<std::string, SettingSyncDataList> as_map; |
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 ASSERT_EQ(1u, sync_processor_->changes().size()); | 1412 ASSERT_EQ(1u, sync_processor_->changes().size()); |
1413 SettingSyncData sync_data = sync_processor_->changes()[0]; | 1413 SettingSyncData sync_data = sync_processor_->changes()[0]; |
1414 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type()); | 1414 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type()); |
1415 EXPECT_EQ("ext", sync_data.extension_id()); | 1415 EXPECT_EQ("ext", sync_data.extension_id()); |
1416 EXPECT_EQ("key.with.spot", sync_data.key()); | 1416 EXPECT_EQ("key.with.spot", sync_data.key()); |
1417 EXPECT_TRUE(sync_data.value().Equals(string_value.get())); | 1417 EXPECT_TRUE(sync_data.value().Equals(string_value.get())); |
1418 } | 1418 } |
1419 } | 1419 } |
1420 | 1420 |
1421 } // namespace extensions | 1421 } // namespace extensions |
OLD | NEW |