Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: components/password_manager/core/browser/password_store_unittest.cc

Issue 838453003: Open the LoginDatabase on the DB thread, not the UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits from vabr@. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/password_manager/core/browser/password_store_default_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/files/scoped_temp_dir.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 27 matching lines...) Expand all
38 38
39 MOCK_METHOD1(StartSyncFlare, void(syncer::ModelType)); 39 MOCK_METHOD1(StartSyncFlare, void(syncer::ModelType));
40 }; 40 };
41 41
42 } // namespace 42 } // namespace
43 43
44 class PasswordStoreTest : public testing::Test { 44 class PasswordStoreTest : 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(
50 temp_dir_.path().Append(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(PasswordStoreTest, IgnoreOldWwwGoogleLogins) { 64 TEST_F(PasswordStoreTest, IgnoreOldWwwGoogleLogins) {
65 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( 65 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault(
66 base::MessageLoopProxy::current(), 66 base::MessageLoopProxy::current(), base::MessageLoopProxy::current(),
67 base::MessageLoopProxy::current(), 67 make_scoped_ptr(new LoginDatabase(test_login_db_file_path()))));
68 login_db_.release()));
69 store->Init(syncer::SyncableService::StartSyncFlare()); 68 store->Init(syncer::SyncableService::StartSyncFlare());
70 69
71 const time_t cutoff = 1325376000; // 00:00 Jan 1 2012 UTC 70 const time_t cutoff = 1325376000; // 00:00 Jan 1 2012 UTC
72 // The passwords are all empty because PasswordStoreDefault doesn't store the 71 // The passwords are all empty because PasswordStoreDefault doesn't store the
73 // actual passwords on OS X (they're stored in the Keychain instead). We could 72 // actual passwords on OS X (they're stored in the Keychain instead). We could
74 // special-case it, but it's easier to just have empty passwords. 73 // special-case it, but it's easier to just have empty passwords.
75 static const PasswordFormData form_data[] = { 74 static const PasswordFormData form_data[] = {
76 // A form on https://www.google.com/ older than the cutoff. Will be ignored. 75 // A form on https://www.google.com/ older than the cutoff. Will be ignored.
77 { PasswordForm::SCHEME_HTML, 76 { PasswordForm::SCHEME_HTML,
78 "https://www.google.com", 77 "https://www.google.com",
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 185
187 base::MessageLoop::current()->RunUntilIdle(); 186 base::MessageLoop::current()->RunUntilIdle();
188 187
189 STLDeleteElements(&all_forms); 188 STLDeleteElements(&all_forms);
190 store->Shutdown(); 189 store->Shutdown();
191 base::MessageLoop::current()->RunUntilIdle(); 190 base::MessageLoop::current()->RunUntilIdle();
192 } 191 }
193 192
194 TEST_F(PasswordStoreTest, StartSyncFlare) { 193 TEST_F(PasswordStoreTest, StartSyncFlare) {
195 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( 194 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault(
196 base::MessageLoopProxy::current(), 195 base::MessageLoopProxy::current(), base::MessageLoopProxy::current(),
197 base::MessageLoopProxy::current(), 196 make_scoped_ptr(new LoginDatabase(test_login_db_file_path()))));
198 login_db_.release()));
199 StartSyncFlareMock mock; 197 StartSyncFlareMock mock;
200 store->Init( 198 store->Init(
201 base::Bind(&StartSyncFlareMock::StartSyncFlare, base::Unretained(&mock))); 199 base::Bind(&StartSyncFlareMock::StartSyncFlare, base::Unretained(&mock)));
202 { 200 {
203 PasswordForm form; 201 PasswordForm form;
204 form.origin = GURL("http://accounts.google.com/LoginAuth"); 202 form.origin = GURL("http://accounts.google.com/LoginAuth");
205 form.signon_realm = "http://accounts.google.com/"; 203 form.signon_realm = "http://accounts.google.com/";
206 EXPECT_CALL(mock, StartSyncFlare(syncer::PASSWORDS)); 204 EXPECT_CALL(mock, StartSyncFlare(syncer::PASSWORDS));
207 store->AddLogin(form); 205 store->AddLogin(form);
208 base::MessageLoop::current()->RunUntilIdle(); 206 base::MessageLoop::current()->RunUntilIdle();
209 } 207 }
210 store->Shutdown(); 208 store->Shutdown();
211 base::MessageLoop::current()->RunUntilIdle(); 209 base::MessageLoop::current()->RunUntilIdle();
212 } 210 }
213 211
214 } // namespace password_manager 212 } // namespace password_manager
OLDNEW
« no previous file with comments | « components/password_manager/core/browser/password_store_default_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698