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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/files/scoped_temp_dir.h" |
7 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
8 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
9 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
10 #include "base/time/time.h" | 11 #include "base/time/time.h" |
11 #include "chrome/test/base/testing_profile.h" | |
12 #include "components/password_manager/core/browser/password_form_data.h" | 12 #include "components/password_manager/core/browser/password_form_data.h" |
13 #include "components/password_manager/core/browser/password_store_consumer.h" | 13 #include "components/password_manager/core/browser/password_store_consumer.h" |
14 #include "components/password_manager/core/browser/password_store_default.h" | 14 #include "components/password_manager/core/browser/password_store_default.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 using autofill::PasswordForm; | 18 using autofill::PasswordForm; |
19 using base::WaitableEvent; | 19 using base::WaitableEvent; |
20 using testing::_; | 20 using testing::_; |
21 using testing::DoAll; | 21 using testing::DoAll; |
22 using testing::WithArg; | 22 using testing::WithArg; |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 class MockPasswordStoreConsumer : public PasswordStoreConsumer { | 26 class MockPasswordStoreConsumer : public PasswordStoreConsumer { |
27 public: | 27 public: |
28 MOCK_METHOD1(OnGetPasswordStoreResults, | 28 MOCK_METHOD1(OnGetPasswordStoreResults, |
29 void(const std::vector<PasswordForm*>&)); | 29 void(const std::vector<PasswordForm*>&)); |
30 }; | 30 }; |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 class PasswordStoreTest : public testing::Test { | 34 class PasswordStoreTest : public testing::Test { |
35 protected: | 35 protected: |
36 virtual void SetUp() { | 36 virtual void SetUp() OVERRIDE { |
37 profile_.reset(new TestingProfile()); | 37 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 38 login_db_.reset(new LoginDatabase()); |
| 39 ASSERT_TRUE(login_db_->Init(temp_dir_.path().Append( |
| 40 FILE_PATH_LITERAL("login_test")))); |
| 41 } |
38 | 42 |
39 login_db_.reset(new LoginDatabase()); | 43 virtual void TearDown() OVERRIDE { |
40 ASSERT_TRUE(login_db_->Init(profile_->GetPath().Append( | 44 ASSERT_TRUE(temp_dir_.Delete()); |
41 FILE_PATH_LITERAL("login_test")))); | |
42 } | 45 } |
43 | 46 |
44 base::MessageLoopForUI message_loop_; | 47 base::MessageLoopForUI message_loop_; |
45 scoped_ptr<LoginDatabase> login_db_; | 48 scoped_ptr<LoginDatabase> login_db_; |
46 scoped_ptr<TestingProfile> profile_; | 49 base::ScopedTempDir temp_dir_; |
47 }; | 50 }; |
48 | 51 |
49 ACTION(STLDeleteElements0) { | 52 ACTION(STLDeleteElements0) { |
50 STLDeleteContainerPointers(arg0.begin(), arg0.end()); | 53 STLDeleteContainerPointers(arg0.begin(), arg0.end()); |
51 } | 54 } |
52 | 55 |
53 TEST_F(PasswordStoreTest, IgnoreOldWwwGoogleLogins) { | 56 TEST_F(PasswordStoreTest, IgnoreOldWwwGoogleLogins) { |
54 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( | 57 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( |
55 base::MessageLoopProxy::current(), | 58 base::MessageLoopProxy::current(), |
56 base::MessageLoopProxy::current(), | 59 base::MessageLoopProxy::current(), |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 174 |
172 store->GetLogins(www_google, PasswordStore::ALLOW_PROMPT, &consumer); | 175 store->GetLogins(www_google, PasswordStore::ALLOW_PROMPT, &consumer); |
173 store->GetLogins(accounts_google, PasswordStore::ALLOW_PROMPT, &consumer); | 176 store->GetLogins(accounts_google, PasswordStore::ALLOW_PROMPT, &consumer); |
174 store->GetLogins(bar_example, PasswordStore::ALLOW_PROMPT, &consumer); | 177 store->GetLogins(bar_example, PasswordStore::ALLOW_PROMPT, &consumer); |
175 | 178 |
176 base::MessageLoop::current()->RunUntilIdle(); | 179 base::MessageLoop::current()->RunUntilIdle(); |
177 | 180 |
178 STLDeleteElements(&all_forms); | 181 STLDeleteElements(&all_forms); |
179 store->Shutdown(); | 182 store->Shutdown(); |
180 } | 183 } |
OLD | NEW |