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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_state_unittest.cc

Issue 1620083003: Fix best credentials selection algorithm in Password Manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tests added Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/ui/passwords/manage_passwords_state.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_state.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 EXPECT_THAT(passwords_data().federated_credentials_forms(), IsEmpty()); 357 EXPECT_THAT(passwords_data().federated_credentials_forms(), IsEmpty());
358 EXPECT_EQ(password_manager::ui::MANAGE_STATE, passwords_data().state()); 358 EXPECT_EQ(password_manager::ui::MANAGE_STATE, passwords_data().state());
359 EXPECT_EQ(origin, passwords_data().origin()); 359 EXPECT_EQ(origin, passwords_data().origin());
360 360
361 // |passwords_data| should hold a separate copy of test_local_form(). 361 // |passwords_data| should hold a separate copy of test_local_form().
362 EXPECT_THAT(passwords_data().GetCurrentForms(), 362 EXPECT_THAT(passwords_data().GetCurrentForms(),
363 Not(Contains(&test_local_form()))); 363 Not(Contains(&test_local_form())));
364 TestAllUpdates(); 364 TestAllUpdates();
365 } 365 }
366 366
367 TEST_F(ManagePasswordsStateTest, ActiveOnMixedPSLAndNonPSLMatched) {
368 autofill::PasswordFormMap password_form_map;
369 password_form_map.insert(std::make_pair(
370 test_local_form().username_value,
371 make_scoped_ptr(new autofill::PasswordForm(test_local_form()))));
372 autofill::PasswordForm psl_matched_test_form = test_local_form();
373 psl_matched_test_form.is_public_suffix_match = true;
374 password_form_map.insert(std::make_pair(
375 psl_matched_test_form.username_value,
376 make_scoped_ptr(new autofill::PasswordForm(psl_matched_test_form))));
377 GURL origin("https://example.com");
378 passwords_data().OnPasswordAutofilled(password_form_map, origin);
379
380 EXPECT_THAT(passwords_data().GetCurrentForms(),
381 ElementsAre(Pointee(test_local_form())));
382 EXPECT_THAT(passwords_data().federated_credentials_forms(), IsEmpty());
383 EXPECT_EQ(password_manager::ui::MANAGE_STATE, passwords_data().state());
384 EXPECT_EQ(origin, passwords_data().origin());
385
386 // |passwords_data| should hold a separate copy of test_local_form().
387 EXPECT_THAT(passwords_data().GetCurrentForms(),
388 Not(Contains(&test_local_form())));
389 TestAllUpdates();
390 }
391
367 TEST_F(ManagePasswordsStateTest, InactiveOnPSLMatched) { 392 TEST_F(ManagePasswordsStateTest, InactiveOnPSLMatched) {
368 autofill::PasswordForm psl_matched_test_form = test_local_form(); 393 autofill::PasswordForm psl_matched_test_form = test_local_form();
369 psl_matched_test_form.is_public_suffix_match = true; 394 psl_matched_test_form.is_public_suffix_match = true;
370 autofill::PasswordFormMap password_form_map; 395 autofill::PasswordFormMap password_form_map;
371 password_form_map.insert(std::make_pair( 396 password_form_map.insert(std::make_pair(
372 psl_matched_test_form.username_value, 397 psl_matched_test_form.username_value,
373 make_scoped_ptr(new autofill::PasswordForm(psl_matched_test_form)))); 398 make_scoped_ptr(new autofill::PasswordForm(psl_matched_test_form))));
374 passwords_data().OnPasswordAutofilled(password_form_map, 399 passwords_data().OnPasswordAutofilled(password_form_map,
375 GURL("https://m.example.com/")); 400 GURL("https://m.example.com/"));
376 401
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 passwords_data().set_credentials_callback(base::Bind( 575 passwords_data().set_credentials_callback(base::Bind(
551 &ManagePasswordsStateTest::CredentialCallback, base::Unretained(this))); 576 &ManagePasswordsStateTest::CredentialCallback, base::Unretained(this)));
552 password_manager::CredentialInfo credential_info( 577 password_manager::CredentialInfo credential_info(
553 form, password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED); 578 form, password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED);
554 EXPECT_CALL(*this, CredentialCallback(credential_info)); 579 EXPECT_CALL(*this, CredentialCallback(credential_info));
555 passwords_data().ChooseCredential( 580 passwords_data().ChooseCredential(
556 form, password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); 581 form, password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD);
557 } 582 }
558 583
559 } // namespace 584 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/passwords/manage_passwords_state.cc ('k') | chrome/browser/ui/views/passwords/manage_password_items_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698