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

Unified Diff: components/password_manager/core/browser/password_autofill_manager_unittest.cc

Issue 695233002: Revert of Do not haul suggestions back to browser in AutofillHostMsg_ShowPasswordSuggestions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « components/password_manager/core/browser/password_autofill_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/password_manager/core/browser/password_autofill_manager_unittest.cc
diff --git a/components/password_manager/core/browser/password_autofill_manager_unittest.cc b/components/password_manager/core/browser/password_autofill_manager_unittest.cc
index ab09812d3429900d2393a1e68681d145164296c5..c2056c148ae8c99edb23477c57230906c9bcfaf6 100644
--- a/components/password_manager/core/browser/password_autofill_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_autofill_manager_unittest.cc
@@ -1,8 +1,6 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
-#include "components/password_manager/core/browser/password_autofill_manager.h"
#include "base/compiler_specific.h"
#include "base/message_loop/message_loop.h"
@@ -10,8 +8,7 @@
#include "components/autofill/core/browser/popup_item_ids.h"
#include "components/autofill/core/browser/test_autofill_client.h"
#include "components/autofill/core/browser/test_autofill_driver.h"
-#include "components/autofill/core/common/form_field_data.h"
-#include "components/autofill/core/common/password_form_fill_data.h"
+#include "components/password_manager/core/browser/password_autofill_manager.h"
#include "components/password_manager/core/browser/stub_password_manager_client.h"
#include "components/password_manager/core/browser/stub_password_manager_driver.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -170,16 +167,10 @@
InitializePasswordAutofillManager(client.get(), autofill_client.get());
gfx::RectF element_bounds;
- autofill::PasswordFormFillData data;
- data.basic_data.fields.resize(2);
- data.basic_data.fields[0].value = test_username_;
- data.basic_data.fields[1].value = test_password_;
- data.preferred_realm = "http://foo.com/";
- autofill::FormFieldData dummy_key;
- password_autofill_manager_->OnAddPasswordFormMapping(dummy_key, data);
-
- EXPECT_CALL(*client->mock_driver(),
- FillSuggestion(test_username_, test_password_));
+ std::vector<base::string16> suggestions;
+ suggestions.push_back(test_username_);
+ std::vector<base::string16> realms;
+ realms.push_back(base::ASCIIToUTF16("http://foo.com/"));
// The enums must be cast to ints to prevent compile errors on linux_rel.
EXPECT_CALL(*autofill_client,
@@ -192,71 +183,12 @@
testing::ElementsAre(autofill::POPUP_ITEM_ID_PASSWORD_ENTRY),
_));
password_autofill_manager_->OnShowPasswordSuggestions(
- dummy_key, base::string16(), false, element_bounds);
+ username_field_, element_bounds, suggestions, realms);
// Accepting a suggestion should trigger a call to hide the popup.
EXPECT_CALL(*autofill_client, HideAutofillPopup());
password_autofill_manager_->DidAcceptSuggestion(
- test_username_, autofill::POPUP_ITEM_ID_PASSWORD_ENTRY);
-}
-
-// Test that OnShowPasswordSuggestions correctly matches the given FormFieldData
-// to the known PasswordFormFillData, and extracts the right suggestions.
-TEST_F(PasswordAutofillManagerTest, ExtractSuggestions) {
- scoped_ptr<TestPasswordManagerClient> client(new TestPasswordManagerClient);
- scoped_ptr<MockAutofillClient> autofill_client(new MockAutofillClient);
- InitializePasswordAutofillManager(client.get(), autofill_client.get());
-
- gfx::RectF element_bounds;
- autofill::PasswordFormFillData data;
- data.basic_data.fields.resize(2);
- data.basic_data.fields[0].value = test_username_;
- data.basic_data.fields[1].value = test_password_;
- data.preferred_realm = "http://foo.com/";
-
- autofill::PasswordAndRealm additional;
- additional.realm = "https://foobarrealm.org";
- base::string16 additional_username(base::ASCIIToUTF16("John Foo"));
- data.additional_logins[additional_username] = additional;
-
- autofill::UsernamesCollectionKey usernames_key;
- usernames_key.realm = "http://yetanother.net";
- std::vector<base::string16> other_names;
- base::string16 other_username(base::ASCIIToUTF16("John Different"));
- other_names.push_back(other_username);
- data.other_possible_usernames[usernames_key] = other_names;
-
- autofill::FormFieldData dummy_key;
- password_autofill_manager_->OnAddPasswordFormMapping(dummy_key, data);
-
- // First, simulate displaying suggestions matching an empty prefix.
- EXPECT_CALL(*autofill_client,
- ShowAutofillPopup(
- element_bounds, _,
- testing::UnorderedElementsAre(
- test_username_, additional_username, other_username),
- _, _, _, _));
- password_autofill_manager_->OnShowPasswordSuggestions(
- dummy_key, base::string16(), false, element_bounds);
-
- // Now simulate displaying suggestions matching "John".
- EXPECT_CALL(*autofill_client,
- ShowAutofillPopup(element_bounds, _,
- testing::UnorderedElementsAre(
- additional_username, other_username),
- _, _, _, _));
- password_autofill_manager_->OnShowPasswordSuggestions(
- dummy_key, base::ASCIIToUTF16("John"), false, element_bounds);
-
- // Finally, simulate displaying all suggestions, without any prefix matching.
- EXPECT_CALL(*autofill_client,
- ShowAutofillPopup(
- element_bounds, _,
- testing::UnorderedElementsAre(
- test_username_, additional_username, other_username),
- _, _, _, _));
- password_autofill_manager_->OnShowPasswordSuggestions(
- dummy_key, base::ASCIIToUTF16("xyz"), true, element_bounds);
+ suggestions[0], autofill::POPUP_ITEM_ID_PASSWORD_ENTRY);
}
} // namespace password_manager
« no previous file with comments | « components/password_manager/core/browser/password_autofill_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698