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 "components/password_manager/core/browser/password_store_default.h" | 5 #include "components/password_manager/core/browser/password_store_default.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/test/scoped_task_environment.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
20 #include "components/password_manager/core/browser/login_database.h" | 21 #include "components/password_manager/core/browser/login_database.h" |
21 #include "components/password_manager/core/browser/password_manager_test_utils.h
" | 22 #include "components/password_manager/core/browser/password_manager_test_utils.h
" |
22 #include "components/password_manager/core/browser/password_store_change.h" | 23 #include "components/password_manager/core/browser/password_store_change.h" |
23 #include "components/password_manager/core/browser/password_store_consumer.h" | 24 #include "components/password_manager/core/browser/password_store_consumer.h" |
24 #include "components/password_manager/core/browser/password_store_origin_unittes
t.h" | 25 #include "components/password_manager/core/browser/password_store_origin_unittes
t.h" |
25 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 private: | 91 private: |
91 void SetupTempDir(); | 92 void SetupTempDir(); |
92 | 93 |
93 void ClosePasswordStore(); | 94 void ClosePasswordStore(); |
94 | 95 |
95 scoped_refptr<PasswordStoreDefault> CreateInitializedStore( | 96 scoped_refptr<PasswordStoreDefault> CreateInitializedStore( |
96 std::unique_ptr<LoginDatabase> database); | 97 std::unique_ptr<LoginDatabase> database); |
97 | 98 |
98 base::FilePath test_login_db_file_path() const; | 99 base::FilePath test_login_db_file_path() const; |
99 | 100 |
100 base::MessageLoopForUI message_loop_; | 101 base::test::ScopedTaskEnvironment scoped_task_environment_; |
101 base::ScopedTempDir temp_dir_; | 102 base::ScopedTempDir temp_dir_; |
102 scoped_refptr<PasswordStoreDefault> store_; | 103 scoped_refptr<PasswordStoreDefault> store_; |
103 | 104 |
104 DISALLOW_COPY_AND_ASSIGN(PasswordStoreDefaultTestDelegate); | 105 DISALLOW_COPY_AND_ASSIGN(PasswordStoreDefaultTestDelegate); |
105 }; | 106 }; |
106 | 107 |
107 PasswordStoreDefaultTestDelegate::PasswordStoreDefaultTestDelegate() { | 108 PasswordStoreDefaultTestDelegate::PasswordStoreDefaultTestDelegate() |
| 109 : scoped_task_environment_( |
| 110 base::test::ScopedTaskEnvironment::MainThreadType::UI) { |
108 SetupTempDir(); | 111 SetupTempDir(); |
109 store_ = CreateInitializedStore( | 112 store_ = CreateInitializedStore( |
110 base::MakeUnique<LoginDatabase>(test_login_db_file_path())); | 113 base::MakeUnique<LoginDatabase>(test_login_db_file_path())); |
111 } | 114 } |
112 | 115 |
113 PasswordStoreDefaultTestDelegate::PasswordStoreDefaultTestDelegate( | 116 PasswordStoreDefaultTestDelegate::PasswordStoreDefaultTestDelegate( |
114 std::unique_ptr<LoginDatabase> database) { | 117 std::unique_ptr<LoginDatabase> database) |
| 118 : scoped_task_environment_( |
| 119 base::test::ScopedTaskEnvironment::MainThreadType::UI) { |
115 SetupTempDir(); | 120 SetupTempDir(); |
116 store_ = CreateInitializedStore(std::move(database)); | 121 store_ = CreateInitializedStore(std::move(database)); |
117 } | 122 } |
118 | 123 |
119 PasswordStoreDefaultTestDelegate::~PasswordStoreDefaultTestDelegate() { | 124 PasswordStoreDefaultTestDelegate::~PasswordStoreDefaultTestDelegate() { |
120 ClosePasswordStore(); | 125 ClosePasswordStore(); |
121 } | 126 } |
122 | 127 |
123 void PasswordStoreDefaultTestDelegate::FinishAsyncProcessing() { | 128 void PasswordStoreDefaultTestDelegate::FinishAsyncProcessing() { |
124 base::RunLoop().RunUntilIdle(); | 129 base::RunLoop().RunUntilIdle(); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 run_loop.Run(); | 300 run_loop.Run(); |
296 | 301 |
297 bad_store->RemoveLoginsSyncedBetween(base::Time(), base::Time::Max()); | 302 bad_store->RemoveLoginsSyncedBetween(base::Time(), base::Time::Max()); |
298 base::RunLoop().RunUntilIdle(); | 303 base::RunLoop().RunUntilIdle(); |
299 | 304 |
300 // Ensure no notifications and no explosions during shutdown either. | 305 // Ensure no notifications and no explosions during shutdown either. |
301 bad_store->RemoveObserver(&mock_observer); | 306 bad_store->RemoveObserver(&mock_observer); |
302 } | 307 } |
303 | 308 |
304 } // namespace password_manager | 309 } // namespace password_manager |
OLD | NEW |