Chromium Code Reviews| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 L"password_element", | 72 L"password_element", |
| 72 L"username_value", | 73 L"username_value", |
| 73 L"password_value", | 74 L"password_value", |
| 74 true, | 75 true, |
| 75 1}; | 76 1}; |
| 76 return data; | 77 return data; |
| 77 } | 78 } |
| 78 | 79 |
| 79 class PasswordStoreDefaultTestDelegate { | 80 class PasswordStoreDefaultTestDelegate { |
| 80 public: | 81 public: |
| 81 PasswordStoreDefaultTestDelegate(); | |
| 82 explicit PasswordStoreDefaultTestDelegate( | 82 explicit PasswordStoreDefaultTestDelegate( |
| 83 std::unique_ptr<LoginDatabase> database); | 83 std::unique_ptr<LoginDatabase> database) |
| 84 : scoped_task_environment_( | |
| 85 base::test::ScopedTaskEnvironment::MainThreadType::UI) {} | |
|
gab
2017/04/28 01:43:00
Deleting the default constructor and forcing this
fdoray
2017/05/01 17:16:51
Done.
| |
| 84 ~PasswordStoreDefaultTestDelegate(); | 86 ~PasswordStoreDefaultTestDelegate(); |
| 85 | 87 |
| 86 PasswordStoreDefault* store() { return store_.get(); } | 88 PasswordStoreDefault* store() { return store_.get(); } |
| 87 | 89 |
| 88 static void FinishAsyncProcessing(); | 90 static void FinishAsyncProcessing(); |
| 89 | 91 |
| 90 private: | 92 private: |
| 91 void SetupTempDir(); | 93 void SetupTempDir(); |
| 92 | 94 |
| 93 void ClosePasswordStore(); | 95 void ClosePasswordStore(); |
| 94 | 96 |
| 95 scoped_refptr<PasswordStoreDefault> CreateInitializedStore( | 97 scoped_refptr<PasswordStoreDefault> CreateInitializedStore( |
| 96 std::unique_ptr<LoginDatabase> database); | 98 std::unique_ptr<LoginDatabase> database); |
| 97 | 99 |
| 98 base::FilePath test_login_db_file_path() const; | 100 base::FilePath test_login_db_file_path() const; |
| 99 | 101 |
| 100 base::MessageLoopForUI message_loop_; | 102 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 101 base::ScopedTempDir temp_dir_; | 103 base::ScopedTempDir temp_dir_; |
| 102 scoped_refptr<PasswordStoreDefault> store_; | 104 scoped_refptr<PasswordStoreDefault> store_; |
| 103 | 105 |
| 104 DISALLOW_COPY_AND_ASSIGN(PasswordStoreDefaultTestDelegate); | 106 DISALLOW_COPY_AND_ASSIGN(PasswordStoreDefaultTestDelegate); |
| 105 }; | 107 }; |
| 106 | 108 |
| 107 PasswordStoreDefaultTestDelegate::PasswordStoreDefaultTestDelegate() { | 109 PasswordStoreDefaultTestDelegate::PasswordStoreDefaultTestDelegate() { |
|
sdefresne
2017/04/28 10:00:23
scoped_task_environment_ needs to be initialized h
fdoray
2017/05/01 17:16:51
Done.
| |
| 108 SetupTempDir(); | 110 SetupTempDir(); |
| 109 store_ = CreateInitializedStore( | 111 store_ = CreateInitializedStore( |
| 110 base::MakeUnique<LoginDatabase>(test_login_db_file_path())); | 112 base::MakeUnique<LoginDatabase>(test_login_db_file_path())); |
| 111 } | 113 } |
| 112 | 114 |
| 113 PasswordStoreDefaultTestDelegate::PasswordStoreDefaultTestDelegate( | 115 PasswordStoreDefaultTestDelegate::PasswordStoreDefaultTestDelegate( |
|
sdefresne
2017/04/28 10:00:23
ditto
fdoray
2017/05/01 17:16:51
Done.
| |
| 114 std::unique_ptr<LoginDatabase> database) { | 116 std::unique_ptr<LoginDatabase> database) { |
| 115 SetupTempDir(); | 117 SetupTempDir(); |
| 116 store_ = CreateInitializedStore(std::move(database)); | 118 store_ = CreateInitializedStore(std::move(database)); |
| 117 } | 119 } |
| 118 | 120 |
| 119 PasswordStoreDefaultTestDelegate::~PasswordStoreDefaultTestDelegate() { | 121 PasswordStoreDefaultTestDelegate::~PasswordStoreDefaultTestDelegate() { |
| 120 ClosePasswordStore(); | 122 ClosePasswordStore(); |
| 121 } | 123 } |
| 122 | 124 |
| 123 void PasswordStoreDefaultTestDelegate::FinishAsyncProcessing() { | 125 void PasswordStoreDefaultTestDelegate::FinishAsyncProcessing() { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 run_loop.Run(); | 297 run_loop.Run(); |
| 296 | 298 |
| 297 bad_store->RemoveLoginsSyncedBetween(base::Time(), base::Time::Max()); | 299 bad_store->RemoveLoginsSyncedBetween(base::Time(), base::Time::Max()); |
| 298 base::RunLoop().RunUntilIdle(); | 300 base::RunLoop().RunUntilIdle(); |
| 299 | 301 |
| 300 // Ensure no notifications and no explosions during shutdown either. | 302 // Ensure no notifications and no explosions during shutdown either. |
| 301 bad_store->RemoveObserver(&mock_observer); | 303 bad_store->RemoveObserver(&mock_observer); |
| 302 } | 304 } |
| 303 | 305 |
| 304 } // namespace password_manager | 306 } // namespace password_manager |
| OLD | NEW |