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

Side by Side Diff: components/sync/engine_impl/sync_manager_impl_unittest.cc

Issue 2798963003: Use ScopedTaskEnvironment instead of MessageLoop in components unit tests. (Closed)
Patch Set: Created 3 years, 8 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/sync/engine_impl/sync_manager_impl.h" 5 #include "components/sync/engine_impl/sync_manager_impl.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/format_macros.h" 13 #include "base/format_macros.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/metrics/field_trial.h" 15 #include "base/metrics/field_trial.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "base/test/scoped_feature_list.h" 20 #include "base/test/scoped_feature_list.h"
21 #include "base/test/scoped_task_environment.h"
21 #include "base/test/values_test_util.h" 22 #include "base/test/values_test_util.h"
22 #include "base/values.h" 23 #include "base/values.h"
23 #include "components/sync/base/attachment_id_proto.h" 24 #include "components/sync/base/attachment_id_proto.h"
24 #include "components/sync/base/cancelation_signal.h" 25 #include "components/sync/base/cancelation_signal.h"
25 #include "components/sync/base/extensions_activity.h" 26 #include "components/sync/base/extensions_activity.h"
26 #include "components/sync/base/fake_encryptor.h" 27 #include "components/sync/base/fake_encryptor.h"
27 #include "components/sync/base/hash_util.h" 28 #include "components/sync/base/hash_util.h"
28 #include "components/sync/base/mock_unrecoverable_error_handler.h" 29 #include "components/sync/base/mock_unrecoverable_error_handler.h"
29 #include "components/sync/base/model_type_test_util.h" 30 #include "components/sync/base/model_type_test_util.h"
30 #include "components/sync/base/sync_features.h" 31 #include "components/sync/base/sync_features.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 249
249 // Save changes to the Directory, destroy it then reload it. 250 // Save changes to the Directory, destroy it then reload it.
250 bool ReloadDir(); 251 bool ReloadDir();
251 252
252 UserShare* user_share(); 253 UserShare* user_share();
253 syncable::Directory* dir(); 254 syncable::Directory* dir();
254 SyncEncryptionHandler* encryption_handler(); 255 SyncEncryptionHandler* encryption_handler();
255 PassphraseType GetPassphraseType(BaseTransaction* trans); 256 PassphraseType GetPassphraseType(BaseTransaction* trans);
256 257
257 private: 258 private:
258 base::MessageLoop message_loop_; 259 base::test::ScopedTaskEnvironment scoped_task_environment_;
259 TestUserShare test_user_share_; 260 TestUserShare test_user_share_;
260 }; 261 };
261 262
262 UserShare* SyncApiTest::user_share() { 263 UserShare* SyncApiTest::user_share() {
263 return test_user_share_.user_share(); 264 return test_user_share_.user_share();
264 } 265 }
265 266
266 syncable::Directory* SyncApiTest::dir() { 267 syncable::Directory* SyncApiTest::dir() {
267 return test_user_share_.user_share()->directory.get(); 268 return test_user_share_.user_share()->directory.get();
268 } 269 }
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 true); 1229 true);
1229 EXPECT_EQ(PassphraseType::CUSTOM_PASSPHRASE, GetPassphraseType()); 1230 EXPECT_EQ(PassphraseType::CUSTOM_PASSPHRASE, GetPassphraseType());
1230 } 1231 }
1231 1232
1232 bool HasUnrecoverableError() { 1233 bool HasUnrecoverableError() {
1233 return mock_unrecoverable_error_handler_.invocation_count() > 0; 1234 return mock_unrecoverable_error_handler_.invocation_count() > 0;
1234 } 1235 }
1235 1236
1236 private: 1237 private:
1237 // Needed by |sync_manager_|. 1238 // Needed by |sync_manager_|.
1238 base::MessageLoop message_loop_; 1239 base::test::ScopedTaskEnvironment scoped_task_environment_;
1239 // Needed by |sync_manager_|. 1240 // Needed by |sync_manager_|.
1240 base::ScopedTempDir temp_dir_; 1241 base::ScopedTempDir temp_dir_;
1241 // Sync Id's for the roots of the enabled datatypes. 1242 // Sync Id's for the roots of the enabled datatypes.
1242 std::map<ModelType, int64_t> type_roots_; 1243 std::map<ModelType, int64_t> type_roots_;
1243 scoped_refptr<ExtensionsActivity> extensions_activity_; 1244 scoped_refptr<ExtensionsActivity> extensions_activity_;
1244 1245
1245 protected: 1246 protected:
1246 FakeEncryptor encryptor_; 1247 FakeEncryptor encryptor_;
1247 SyncManagerImpl sync_manager_; 1248 SyncManagerImpl sync_manager_;
1248 CancelationSignal cancelation_signal_; 1249 CancelationSignal cancelation_signal_;
(...skipping 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3483 // SyncManagerInitInvalidStorageTest::GetFactory will return 3484 // SyncManagerInitInvalidStorageTest::GetFactory will return
3484 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3485 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3485 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3486 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3486 // task is to ensure that SyncManagerImpl reported initialization failure in 3487 // task is to ensure that SyncManagerImpl reported initialization failure in
3487 // OnInitializationComplete callback. 3488 // OnInitializationComplete callback.
3488 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3489 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3489 EXPECT_FALSE(initialization_succeeded_); 3490 EXPECT_FALSE(initialization_succeeded_);
3490 } 3491 }
3491 3492
3492 } // namespace syncer 3493 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698