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

Unified Diff: components/password_manager/content/browser/credential_manager_impl_unittest.cc

Issue 2277793002: Filter duplicates in the account chooser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/password_manager/content/browser/credential_manager_impl_unittest.cc
diff --git a/components/password_manager/content/browser/credential_manager_impl_unittest.cc b/components/password_manager/content/browser/credential_manager_impl_unittest.cc
index f6c0ee62921fa38eac6cdd476179ee7da71e4b4f..6b0649a21216c715992b18d3685a89a68367efe1 100644
--- a/components/password_manager/content/browser/credential_manager_impl_unittest.cc
+++ b/components/password_manager/content/browser/credential_manager_impl_unittest.cc
@@ -40,6 +40,8 @@ using content::BrowserContext;
using content::WebContents;
using testing::_;
+using testing::Pointee;
+using testing::UnorderedElementsAre;
namespace password_manager {
@@ -97,7 +99,7 @@ class MockPasswordManagerClient : public StubPasswordManagerClient {
ScopedVector<autofill::PasswordForm> local_forms,
ScopedVector<autofill::PasswordForm> federated_forms,
const GURL& origin,
- const CredentialsCallback& callback) {
+ const CredentialsCallback& callback) override {
EXPECT_FALSE(local_forms.empty() && federated_forms.empty());
const autofill::PasswordForm* form =
local_forms.empty() ? federated_forms[0] : local_forms[0];
@@ -695,11 +697,14 @@ TEST_F(CredentialManagerImplTest,
}
TEST_F(CredentialManagerImplTest,
- CredentialManagerOnRequestCredentialWithEmptyAndNonUsernames) {
+ CredentialManagerOnRequestCredentialWithEmptyAndNonemptyUsernames) {
store_->AddLogin(form_);
autofill::PasswordForm empty = form_;
empty.username_value.clear();
store_->AddLogin(empty);
+ autofill::PasswordForm duplicate = form_;
+ duplicate.username_element = base::ASCIIToUTF16("username_element");
vabr (Chromium) 2016/08/24 15:56:17 nit: If this is meant to be different from form_.u
vasilii 2016/08/24 16:51:15 Done.
+ store_->AddLogin(duplicate);
std::vector<GURL> federations;
ExpectZeroClickSignInSuccess(false, true, federations,
@@ -707,6 +712,41 @@ TEST_F(CredentialManagerImplTest,
}
TEST_F(CredentialManagerImplTest,
+ CredentialManagerOnRequestCredentialWithDuplicates) {
+ // Add 5 credentials. Two pairs of duplicates and one empty username. There
+ // should be just two in the account chooser.
+ store_->AddLogin(form_);
+ autofill::PasswordForm empty = form_;
+ empty.username_value.clear();
+ store_->AddLogin(empty);
+ autofill::PasswordForm duplicate = form_;
+ duplicate.username_element = base::ASCIIToUTF16("username_element");
+ duplicate.is_public_suffix_match = true;
+ store_->AddLogin(duplicate);
+
+ store_->AddLogin(origin_path_form_);
+ duplicate = origin_path_form_;
+ duplicate.username_element = base::ASCIIToUTF16("username_element");
+ duplicate.is_public_suffix_match = true;
+ store_->AddLogin(duplicate);
+
+ EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(
+ UnorderedElementsAre(Pointee(form_),
+ Pointee(origin_path_form_)),
+ testing::IsEmpty(), _, _))
+ .Times(testing::Exactly(1));
vabr (Chromium) 2016/08/24 15:56:17 optional: This line is not necessary (omitting is
vasilii 2016/08/24 16:51:15 It was copy-paste.
+
+ bool called = false;
+ mojom::CredentialManagerError error;
+ base::Optional<CredentialInfo> credential;
+ std::vector<GURL> federations;
+ CallGet(false, true, federations,
+ base::Bind(&GetCredentialCallback, &called, &error, &credential));
+
+ RunAllPendingTasks();
+}
+
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialWithCrossOriginPasswordStore) {
store_->AddLogin(cross_origin_form_);

Powered by Google App Engine
This is Rietveld 408576698