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 // The passwords in the tests below are all empty because PasswordStoreDefault | 5 // The passwords in the tests below are all empty because PasswordStoreDefault |
6 // does not store the actual passwords on OS X (they are stored in the Keychain | 6 // does not store the actual passwords on OS X (they are stored in the Keychain |
7 // instead). We could special-case it, but it is easier to just have empty | 7 // instead). We could special-case it, but it is easier to just have empty |
8 // passwords. This will not be needed anymore if crbug.com/466638 is fixed. | 8 // passwords. This will not be needed anymore if crbug.com/466638 is fixed. |
9 | 9 |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 | 11 |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
18 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "base/synchronization/waitable_event.h" | 21 #include "base/synchronization/waitable_event.h" |
| 22 #include "base/test/scoped_task_environment.h" |
22 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
23 #include "base/time/time.h" | 24 #include "base/time/time.h" |
24 #include "build/build_config.h" | 25 #include "build/build_config.h" |
25 #include "components/password_manager/core/browser/affiliated_match_helper.h" | 26 #include "components/password_manager/core/browser/affiliated_match_helper.h" |
26 #include "components/password_manager/core/browser/affiliation_service.h" | 27 #include "components/password_manager/core/browser/affiliation_service.h" |
27 #include "components/password_manager/core/browser/mock_affiliated_match_helper.
h" | 28 #include "components/password_manager/core/browser/mock_affiliated_match_helper.
h" |
28 #include "components/password_manager/core/browser/password_manager_test_utils.h
" | 29 #include "components/password_manager/core/browser/password_manager_test_utils.h
" |
29 #include "components/password_manager/core/browser/password_store_consumer.h" | 30 #include "components/password_manager/core/browser/password_store_consumer.h" |
30 #include "components/password_manager/core/browser/password_store_default.h" | 31 #include "components/password_manager/core/browser/password_store_default.h" |
31 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 StartSyncFlareMock() {} | 83 StartSyncFlareMock() {} |
83 ~StartSyncFlareMock() {} | 84 ~StartSyncFlareMock() {} |
84 | 85 |
85 MOCK_METHOD1(StartSyncFlare, void(syncer::ModelType)); | 86 MOCK_METHOD1(StartSyncFlare, void(syncer::ModelType)); |
86 }; | 87 }; |
87 | 88 |
88 } // namespace | 89 } // namespace |
89 | 90 |
90 class PasswordStoreTest : public testing::Test { | 91 class PasswordStoreTest : public testing::Test { |
91 protected: | 92 protected: |
| 93 PasswordStoreTest() |
| 94 : scoped_task_environment_( |
| 95 base::test::ScopedTaskEnvironment::MainThreadType::UI) {} |
| 96 |
92 void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); } | 97 void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); } |
93 | 98 |
94 void TearDown() override { ASSERT_TRUE(temp_dir_.Delete()); } | 99 void TearDown() override { ASSERT_TRUE(temp_dir_.Delete()); } |
95 | 100 |
96 base::FilePath test_login_db_file_path() const { | 101 base::FilePath test_login_db_file_path() const { |
97 return temp_dir_.GetPath().Append(FILE_PATH_LITERAL("login_test")); | 102 return temp_dir_.GetPath().Append(FILE_PATH_LITERAL("login_test")); |
98 } | 103 } |
99 | 104 |
100 base::MessageLoopForUI message_loop_; | 105 base::test::ScopedTaskEnvironment scoped_task_environment_; |
101 base::ScopedTempDir temp_dir_; | 106 base::ScopedTempDir temp_dir_; |
102 }; | 107 }; |
103 | 108 |
104 TEST_F(PasswordStoreTest, IgnoreOldWwwGoogleLogins) { | 109 TEST_F(PasswordStoreTest, IgnoreOldWwwGoogleLogins) { |
105 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( | 110 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( |
106 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(), | 111 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(), |
107 base::MakeUnique<LoginDatabase>(test_login_db_file_path()))); | 112 base::MakeUnique<LoginDatabase>(test_login_db_file_path()))); |
108 store->Init(syncer::SyncableService::StartSyncFlare()); | 113 store->Init(syncer::SyncableService::StartSyncFlare()); |
109 | 114 |
110 const time_t cutoff = 1325376000; // 00:00 Jan 1 2012 UTC | 115 const time_t cutoff = 1325376000; // 00:00 Jan 1 2012 UTC |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 | 902 |
898 store->ShutdownOnUIThread(); | 903 store->ShutdownOnUIThread(); |
899 base::RunLoop().RunUntilIdle(); | 904 base::RunLoop().RunUntilIdle(); |
900 #if defined(OS_MACOSX) | 905 #if defined(OS_MACOSX) |
901 OSCryptMocker::TearDown(); | 906 OSCryptMocker::TearDown(); |
902 #endif | 907 #endif |
903 } | 908 } |
904 #endif | 909 #endif |
905 | 910 |
906 } // namespace password_manager | 911 } // namespace password_manager |
OLD | NEW |