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/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 MOCK_METHOD1(OnLoginsChanged, | 38 MOCK_METHOD1(OnLoginsChanged, |
39 void(const PasswordStoreChangeList& changes)); | 39 void(const PasswordStoreChangeList& changes)); |
40 }; | 40 }; |
41 | 41 |
42 } // anonymous namespace | 42 } // anonymous namespace |
43 | 43 |
44 class PasswordStoreDefaultTest : public testing::Test { | 44 class PasswordStoreDefaultTest : public testing::Test { |
45 protected: | 45 protected: |
46 void SetUp() override { | 46 void SetUp() override { |
47 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 47 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
48 login_db_.reset(new LoginDatabase()); | |
49 ASSERT_TRUE(login_db_->Init(temp_dir_.path().Append( | |
50 FILE_PATH_LITERAL("login_test")))); | |
51 } | 48 } |
52 | 49 |
53 void TearDown() override { ASSERT_TRUE(temp_dir_.Delete()); } | 50 void TearDown() override { ASSERT_TRUE(temp_dir_.Delete()); } |
54 | 51 |
| 52 base::FilePath test_login_db_file_path() const { |
| 53 return temp_dir_.path().Append(FILE_PATH_LITERAL("login_test")); |
| 54 } |
| 55 |
55 base::MessageLoopForUI message_loop_; | 56 base::MessageLoopForUI message_loop_; |
56 scoped_ptr<LoginDatabase> login_db_; | |
57 base::ScopedTempDir temp_dir_; | 57 base::ScopedTempDir temp_dir_; |
58 }; | 58 }; |
59 | 59 |
60 ACTION(STLDeleteElements0) { | 60 ACTION(STLDeleteElements0) { |
61 STLDeleteContainerPointers(arg0.begin(), arg0.end()); | 61 STLDeleteContainerPointers(arg0.begin(), arg0.end()); |
62 } | 62 } |
63 | 63 |
64 TEST_F(PasswordStoreDefaultTest, NonASCIIData) { | 64 TEST_F(PasswordStoreDefaultTest, NonASCIIData) { |
65 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( | 65 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( |
66 base::MessageLoopProxy::current(), | 66 base::MessageLoopProxy::current(), |
67 base::MessageLoopProxy::current(), | 67 base::MessageLoopProxy::current(), |
68 login_db_.release())); | 68 test_login_db_file_path())); |
69 store->Init(syncer::SyncableService::StartSyncFlare()); | 69 store->Init(syncer::SyncableService::StartSyncFlare()); |
70 | 70 |
71 // Some non-ASCII password form data. | 71 // Some non-ASCII password form data. |
72 static const PasswordFormData form_data[] = { | 72 static const PasswordFormData form_data[] = { |
73 { PasswordForm::SCHEME_HTML, | 73 { PasswordForm::SCHEME_HTML, |
74 "http://foo.example.com", | 74 "http://foo.example.com", |
75 "http://foo.example.com/origin", | 75 "http://foo.example.com/origin", |
76 "http://foo.example.com/action", | 76 "http://foo.example.com/action", |
77 L"มีสีสัน", | 77 L"มีสีสัน", |
78 L"お元気ですか?", | 78 L"お元気ですか?", |
(...skipping 25 matching lines...) Expand all Loading... |
104 | 104 |
105 STLDeleteElements(&expected_forms); | 105 STLDeleteElements(&expected_forms); |
106 store->Shutdown(); | 106 store->Shutdown(); |
107 base::MessageLoop::current()->RunUntilIdle(); | 107 base::MessageLoop::current()->RunUntilIdle(); |
108 } | 108 } |
109 | 109 |
110 TEST_F(PasswordStoreDefaultTest, Notifications) { | 110 TEST_F(PasswordStoreDefaultTest, Notifications) { |
111 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( | 111 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( |
112 base::MessageLoopProxy::current(), | 112 base::MessageLoopProxy::current(), |
113 base::MessageLoopProxy::current(), | 113 base::MessageLoopProxy::current(), |
114 login_db_.release())); | 114 test_login_db_file_path())); |
115 store->Init(syncer::SyncableService::StartSyncFlare()); | 115 store->Init(syncer::SyncableService::StartSyncFlare()); |
116 | 116 |
117 PasswordFormData form_data = | 117 PasswordFormData form_data = |
118 { PasswordForm::SCHEME_HTML, | 118 { PasswordForm::SCHEME_HTML, |
119 "http://bar.example.com", | 119 "http://bar.example.com", |
120 "http://bar.example.com/origin", | 120 "http://bar.example.com/origin", |
121 "http://bar.example.com/action", | 121 "http://bar.example.com/action", |
122 L"submit_element", | 122 L"submit_element", |
123 L"username_element", | 123 L"username_element", |
124 L"password_element", | 124 L"password_element", |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // Deleting the login should trigger a notification. | 168 // Deleting the login should trigger a notification. |
169 store->RemoveLogin(*form); | 169 store->RemoveLogin(*form); |
170 base::MessageLoop::current()->RunUntilIdle(); | 170 base::MessageLoop::current()->RunUntilIdle(); |
171 | 171 |
172 store->RemoveObserver(&observer); | 172 store->RemoveObserver(&observer); |
173 store->Shutdown(); | 173 store->Shutdown(); |
174 base::MessageLoop::current()->RunUntilIdle(); | 174 base::MessageLoop::current()->RunUntilIdle(); |
175 } | 175 } |
176 | 176 |
177 } // namespace password_manager | 177 } // namespace password_manager |
OLD | NEW |