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

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

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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
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 // 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 "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 base::MessageLoopForUI message_loop_; 151 base::MessageLoopForUI message_loop_;
152 base::ScopedTempDir temp_dir_; 152 base::ScopedTempDir temp_dir_;
153 }; 153 };
154 154
155 ACTION(STLDeleteElements0) { 155 ACTION(STLDeleteElements0) {
156 STLDeleteContainerPointers(arg0.begin(), arg0.end()); 156 STLDeleteContainerPointers(arg0.begin(), arg0.end());
157 } 157 }
158 158
159 TEST_F(PasswordStoreTest, IgnoreOldWwwGoogleLogins) { 159 TEST_F(PasswordStoreTest, IgnoreOldWwwGoogleLogins) {
160 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( 160 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault(
161 base::MessageLoopProxy::current(), base::MessageLoopProxy::current(), 161 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
162 make_scoped_ptr(new LoginDatabase(test_login_db_file_path())))); 162 make_scoped_ptr(new LoginDatabase(test_login_db_file_path()))));
163 store->Init(syncer::SyncableService::StartSyncFlare()); 163 store->Init(syncer::SyncableService::StartSyncFlare());
164 164
165 const time_t cutoff = 1325376000; // 00:00 Jan 1 2012 UTC 165 const time_t cutoff = 1325376000; // 00:00 Jan 1 2012 UTC
166 static const PasswordFormData form_data[] = { 166 static const PasswordFormData form_data[] = {
167 // A form on https://www.google.com/ older than the cutoff. Will be ignored. 167 // A form on https://www.google.com/ older than the cutoff. Will be ignored.
168 { PasswordForm::SCHEME_HTML, 168 { PasswordForm::SCHEME_HTML,
169 "https://www.google.com", 169 "https://www.google.com",
170 "https://www.google.com/origin", 170 "https://www.google.com/origin",
171 "https://www.google.com/action", 171 "https://www.google.com/action",
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 store->GetLogins(bar_example, PasswordStore::ALLOW_PROMPT, &consumer); 275 store->GetLogins(bar_example, PasswordStore::ALLOW_PROMPT, &consumer);
276 276
277 base::MessageLoop::current()->RunUntilIdle(); 277 base::MessageLoop::current()->RunUntilIdle();
278 278
279 store->Shutdown(); 279 store->Shutdown();
280 base::MessageLoop::current()->RunUntilIdle(); 280 base::MessageLoop::current()->RunUntilIdle();
281 } 281 }
282 282
283 TEST_F(PasswordStoreTest, StartSyncFlare) { 283 TEST_F(PasswordStoreTest, StartSyncFlare) {
284 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( 284 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault(
285 base::MessageLoopProxy::current(), base::MessageLoopProxy::current(), 285 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
286 make_scoped_ptr(new LoginDatabase(test_login_db_file_path())))); 286 make_scoped_ptr(new LoginDatabase(test_login_db_file_path()))));
287 StartSyncFlareMock mock; 287 StartSyncFlareMock mock;
288 store->Init( 288 store->Init(
289 base::Bind(&StartSyncFlareMock::StartSyncFlare, base::Unretained(&mock))); 289 base::Bind(&StartSyncFlareMock::StartSyncFlare, base::Unretained(&mock)));
290 { 290 {
291 PasswordForm form; 291 PasswordForm form;
292 form.origin = GURL("http://accounts.google.com/LoginAuth"); 292 form.origin = GURL("http://accounts.google.com/LoginAuth");
293 form.signon_realm = "http://accounts.google.com/"; 293 form.signon_realm = "http://accounts.google.com/";
294 EXPECT_CALL(mock, StartSyncFlare(syncer::PASSWORDS)); 294 EXPECT_CALL(mock, StartSyncFlare(syncer::PASSWORDS));
295 store->AddLogin(form); 295 store->AddLogin(form);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 L"", true, true, 1}, 371 L"", true, true, 1},
372 // Credential for an unrelated Android application. 372 // Credential for an unrelated Android application.
373 {PasswordForm::SCHEME_HTML, 373 {PasswordForm::SCHEME_HTML,
374 kTestUnrelatedAndroidRealm, 374 kTestUnrelatedAndroidRealm,
375 "", "", L"", L"", L"", 375 "", "", L"", L"", L"",
376 L"username_value_3", 376 L"username_value_3",
377 L"", true, true, 1}}; 377 L"", true, true, 1}};
378 /* clang-format on */ 378 /* clang-format on */
379 379
380 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( 380 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault(
381 base::MessageLoopProxy::current(), base::MessageLoopProxy::current(), 381 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
382 make_scoped_ptr(new LoginDatabase(test_login_db_file_path())))); 382 make_scoped_ptr(new LoginDatabase(test_login_db_file_path()))));
383 store->Init(syncer::SyncableService::StartSyncFlare()); 383 store->Init(syncer::SyncableService::StartSyncFlare());
384 384
385 MockAffiliatedMatchHelper* mock_helper = new MockAffiliatedMatchHelper; 385 MockAffiliatedMatchHelper* mock_helper = new MockAffiliatedMatchHelper;
386 store->SetAffiliatedMatchHelper(make_scoped_ptr(mock_helper)); 386 store->SetAffiliatedMatchHelper(make_scoped_ptr(mock_helper));
387 387
388 ScopedVector<PasswordForm> all_credentials; 388 ScopedVector<PasswordForm> all_credentials;
389 for (size_t i = 0; i < arraysize(kTestCredentials); ++i) { 389 for (size_t i = 0; i < arraysize(kTestCredentials); ++i) {
390 all_credentials.push_back( 390 all_credentials.push_back(
391 CreatePasswordFormFromDataForTesting(kTestCredentials[i])); 391 CreatePasswordFormFromDataForTesting(kTestCredentials[i]));
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 L"", true, true, 1}, 467 L"", true, true, 1},
468 // Credential for an unrelated Android application. 468 // Credential for an unrelated Android application.
469 {PasswordForm::SCHEME_HTML, 469 {PasswordForm::SCHEME_HTML,
470 kTestUnrelatedAndroidRealm, 470 kTestUnrelatedAndroidRealm,
471 "", "", L"", L"", L"", 471 "", "", L"", L"", L"",
472 L"username_value_5", 472 L"username_value_5",
473 L"", true, true, 1}}; 473 L"", true, true, 1}};
474 /* clang-format on */ 474 /* clang-format on */
475 475
476 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault( 476 scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault(
477 base::MessageLoopProxy::current(), base::MessageLoopProxy::current(), 477 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
478 make_scoped_ptr(new LoginDatabase(test_login_db_file_path())))); 478 make_scoped_ptr(new LoginDatabase(test_login_db_file_path()))));
479 store->Init(syncer::SyncableService::StartSyncFlare()); 479 store->Init(syncer::SyncableService::StartSyncFlare());
480 480
481 MockAffiliatedMatchHelper* mock_helper = new MockAffiliatedMatchHelper; 481 MockAffiliatedMatchHelper* mock_helper = new MockAffiliatedMatchHelper;
482 store->SetAffiliatedMatchHelper(make_scoped_ptr(mock_helper)); 482 store->SetAffiliatedMatchHelper(make_scoped_ptr(mock_helper));
483 483
484 ScopedVector<PasswordForm> all_credentials; 484 ScopedVector<PasswordForm> all_credentials;
485 for (size_t i = 0; i < arraysize(kTestCredentials); ++i) { 485 for (size_t i = 0; i < arraysize(kTestCredentials); ++i) {
486 all_credentials.push_back( 486 all_credentials.push_back(
487 CreatePasswordFormFromDataForTesting(kTestCredentials[i])); 487 CreatePasswordFormFromDataForTesting(kTestCredentials[i]));
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 OnGetPasswordStoreResultsConstRef(UnorderedPasswordFormElementsAre( 738 OnGetPasswordStoreResultsConstRef(UnorderedPasswordFormElementsAre(
739 expected_credentials_after_update.get()))); 739 expected_credentials_after_update.get())));
740 store->GetAutofillableLogins(&mock_consumer); 740 store->GetAutofillableLogins(&mock_consumer);
741 store->Shutdown(); 741 store->Shutdown();
742 base::MessageLoop::current()->RunUntilIdle(); 742 base::MessageLoop::current()->RunUntilIdle();
743 } 743 }
744 } 744 }
745 } 745 }
746 746
747 } // namespace password_manager 747 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698