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

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

Issue 2799883003: Switch from TestBrowserThread to TestBrowserThreadBundle in chrome. (Closed)
Patch Set: fix-string Created 3 years, 7 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
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/message_loop/message_loop.h"
16 #include "base/run_loop.h" 15 #include "base/run_loop.h"
17 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
18 #include "base/values.h" 17 #include "base/values.h"
19 #include "build/build_config.h" 18 #include "build/build_config.h"
20 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" 19 #include "chrome/browser/extensions/api/storage/settings_sync_util.h"
21 #include "chrome/browser/extensions/api/storage/sync_value_store_cache.h" 20 #include "chrome/browser/extensions/api/storage/sync_value_store_cache.h"
22 #include "chrome/browser/extensions/api/storage/syncable_settings_storage.h" 21 #include "chrome/browser/extensions/api/storage/syncable_settings_storage.h"
23 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
24 #include "components/sync/model/sync_change_processor.h" 23 #include "components/sync/model/sync_change_processor.h"
25 #include "components/sync/model/sync_change_processor_wrapper_for_test.h" 24 #include "components/sync/model/sync_change_processor_wrapper_for_test.h"
26 #include "components/sync/model/sync_error_factory.h" 25 #include "components/sync/model/sync_error_factory.h"
27 #include "components/sync/model/sync_error_factory_mock.h" 26 #include "components/sync/model/sync_error_factory_mock.h"
28 #include "content/public/test/test_browser_thread.h" 27 #include "content/public/test/test_browser_thread_bundle.h"
29 #include "extensions/browser/api/storage/settings_test_util.h" 28 #include "extensions/browser/api/storage/settings_test_util.h"
30 #include "extensions/browser/api/storage/storage_frontend.h" 29 #include "extensions/browser/api/storage/storage_frontend.h"
31 #include "extensions/browser/event_router.h" 30 #include "extensions/browser/event_router.h"
32 #include "extensions/browser/event_router_factory.h" 31 #include "extensions/browser/event_router_factory.h"
33 #include "extensions/browser/extension_system.h" 32 #include "extensions/browser/extension_system.h"
34 #include "extensions/browser/mock_extension_system.h" 33 #include "extensions/browser/mock_extension_system.h"
35 #include "extensions/browser/value_store/test_value_store_factory.h" 34 #include "extensions/browser/value_store/test_value_store_factory.h"
36 #include "extensions/browser/value_store/testing_value_store.h" 35 #include "extensions/browser/value_store/testing_value_store.h"
37 #include "extensions/common/manifest.h" 36 #include "extensions/common/manifest.h"
38 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
39 38
40 using base::DictionaryValue; 39 using base::DictionaryValue;
41 using base::ListValue; 40 using base::ListValue;
42 using base::Value; 41 using base::Value;
43 using content::BrowserThread;
44
45 namespace extensions { 42 namespace extensions {
46 43
47 namespace util = settings_test_util; 44 namespace util = settings_test_util;
48 45
49 namespace { 46 namespace {
50 47
51 // To save typing ValueStore::DEFAULTS everywhere. 48 // To save typing ValueStore::DEFAULTS everywhere.
52 const ValueStore::WriteOptions DEFAULTS = ValueStore::DEFAULTS; 49 const ValueStore::WriteOptions DEFAULTS = ValueStore::DEFAULTS;
53 50
54 // More saving typing. Maps extension IDs to a list of sync changes for that 51 // More saving typing. Maps extension IDs to a list of sync changes for that
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 std::unique_ptr<KeyedService> BuildEventRouter( 172 std::unique_ptr<KeyedService> BuildEventRouter(
176 content::BrowserContext* profile) { 173 content::BrowserContext* profile) {
177 return base::MakeUnique<extensions::EventRouter>(profile, nullptr); 174 return base::MakeUnique<extensions::EventRouter>(profile, nullptr);
178 } 175 }
179 176
180 } // namespace 177 } // namespace
181 178
182 class ExtensionSettingsSyncTest : public testing::Test { 179 class ExtensionSettingsSyncTest : public testing::Test {
183 public: 180 public:
184 ExtensionSettingsSyncTest() 181 ExtensionSettingsSyncTest()
185 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()), 182 : storage_factory_(new TestValueStoreFactory()),
186 file_thread_(BrowserThread::FILE, base::MessageLoop::current()),
187 storage_factory_(new TestValueStoreFactory()),
188 sync_processor_(new MockSyncChangeProcessor), 183 sync_processor_(new MockSyncChangeProcessor),
189 sync_processor_wrapper_(new syncer::SyncChangeProcessorWrapperForTest( 184 sync_processor_wrapper_(new syncer::SyncChangeProcessorWrapperForTest(
190 sync_processor_.get())) {} 185 sync_processor_.get())) {}
191 186
192 void SetUp() override { 187 void SetUp() override {
193 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 188 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
194 profile_.reset(new TestingProfile(temp_dir_.GetPath())); 189 profile_.reset(new TestingProfile(temp_dir_.GetPath()));
195 storage_factory_->Reset(); 190 storage_factory_->Reset();
196 frontend_ = 191 frontend_ =
197 StorageFrontend::CreateForTesting(storage_factory_, profile_.get()); 192 StorageFrontend::CreateForTesting(storage_factory_, profile_.get());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return as_map; 243 return as_map;
249 } 244 }
250 245
251 // This class uses it's TestingValueStore in such a way that it always mints 246 // This class uses it's TestingValueStore in such a way that it always mints
252 // new TestingValueStore instances. 247 // new TestingValueStore instances.
253 TestingValueStore* GetExisting(const ExtensionId& extension_id) { 248 TestingValueStore* GetExisting(const ExtensionId& extension_id) {
254 return static_cast<TestingValueStore*>( 249 return static_cast<TestingValueStore*>(
255 storage_factory_->GetExisting(extension_id)); 250 storage_factory_->GetExisting(extension_id));
256 } 251 }
257 252
258 // Need these so that the DCHECKs for running on FILE or UI threads pass. 253 // Needed so that the DCHECKs for running on FILE or UI threads pass.
259 base::MessageLoop message_loop_; 254 content::TestBrowserThreadBundle test_browser_thread_bundle_;
260 content::TestBrowserThread ui_thread_;
261 content::TestBrowserThread file_thread_;
262 255
263 base::ScopedTempDir temp_dir_; 256 base::ScopedTempDir temp_dir_;
264 std::unique_ptr<TestingProfile> profile_; 257 std::unique_ptr<TestingProfile> profile_;
265 std::unique_ptr<StorageFrontend> frontend_; 258 std::unique_ptr<StorageFrontend> frontend_;
266 scoped_refptr<TestValueStoreFactory> storage_factory_; 259 scoped_refptr<TestValueStoreFactory> storage_factory_;
267 std::unique_ptr<MockSyncChangeProcessor> sync_processor_; 260 std::unique_ptr<MockSyncChangeProcessor> sync_processor_;
268 std::unique_ptr<syncer::SyncChangeProcessorWrapperForTest> 261 std::unique_ptr<syncer::SyncChangeProcessorWrapperForTest>
269 sync_processor_wrapper_; 262 sync_processor_wrapper_;
270 }; 263 };
271 264
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 settings_namespace::SYNC, 1401 settings_namespace::SYNC,
1409 base::Bind(&UnlimitedSyncStorageTestCallback)); 1402 base::Bind(&UnlimitedSyncStorageTestCallback));
1410 frontend_->RunWithStorage(extension, 1403 frontend_->RunWithStorage(extension,
1411 settings_namespace::LOCAL, 1404 settings_namespace::LOCAL,
1412 base::Bind(&UnlimitedLocalStorageTestCallback)); 1405 base::Bind(&UnlimitedLocalStorageTestCallback));
1413 1406
1414 base::RunLoop().RunUntilIdle(); 1407 base::RunLoop().RunUntilIdle();
1415 } 1408 }
1416 1409
1417 } // namespace extensions 1410 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698