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

Unified Diff: components/autofill/content/browser/content_autofill_driver_unittest.cc

Issue 223133003: Allow deleting autofill password suggestions on Shift+Delete (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bug fixed Created 6 years, 8 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/autofill/content/browser/content_autofill_driver_unittest.cc
diff --git a/components/autofill/content/browser/content_autofill_driver_unittest.cc b/components/autofill/content/browser/content_autofill_driver_unittest.cc
index c116cfcc1ddc158db62ff1894770e5fe78612bb6..01a3fd555f58b1affc4bd2792d6e5568be3aa379 100644
--- a/components/autofill/content/browser/content_autofill_driver_unittest.cc
+++ b/components/autofill/content/browser/content_autofill_driver_unittest.cc
@@ -16,6 +16,7 @@
#include "components/autofill/core/browser/test_autofill_manager_delegate.h"
#include "components/autofill/core/common/autofill_switches.h"
#include "components/autofill/core/common/form_data_predictions.h"
+#include "components/autofill/core/common/password_form.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/web_contents.h"
@@ -146,6 +147,26 @@ class ContentAutofillDriverTest : public content::RenderViewHostTestHarness {
return true;
}
+ // Searches for an |AutofillMsg_RemoveSavedPassword| message in the queue
+ // of sent IPC messages. If none is present, returns false. Otherwise,
+ // extracts the first |AutofillMsg_RemoveSavedPassword| message, fills
+ // the output parameters with the values of the message's parameter, and
+ // clears the queue of sent messages.
+ bool GetRemoveSavedPasswordMessage(base::string16* username_to_remove) {
+ const uint32 kMsgID = AutofillMsg_RemoveSavedPassword::ID;
+ const IPC::Message* message =
+ process()->sink().GetFirstMessageMatching(kMsgID);
+ if (!message)
+ return false;
+ Tuple1<base::string16> autofill_param;
+ if (!AutofillMsg_RemoveSavedPassword::Read(message, &autofill_param))
+ return false;
+ if (username_to_remove)
+ *username_to_remove = autofill_param.a;
+ process()->sink().ClearMessages();
+ return true;
+ }
+
// Searches for a message matching |messageID| in the queue of sent IPC
// messages. If none is present, returns false. Otherwise, extracts the first
// matching message, fills the output parameter with the string16 from the
@@ -243,6 +264,17 @@ TEST_F(ContentAutofillDriverTest, FormDataSentToRenderer_FillForm) {
EXPECT_EQ(input_form_data, output_form_data);
}
+TEST_F(ContentAutofillDriverTest, RemoveSavedPasswordSentToRenderer) {
+ base::string16 input_username(base::ASCIIToUTF16("username"));
+
+ driver_->RemovePasswordAutofillSuggestion(input_username);
+
+ base::string16 output_username;
+ EXPECT_TRUE(GetRemoveSavedPasswordMessage(&output_username));
+
+ EXPECT_EQ(input_username, output_username);
+}
+
TEST_F(ContentAutofillDriverTest, FormDataSentToRenderer_PreviewForm) {
int input_page_id = 42;
FormData input_form_data;

Powered by Google App Engine
This is Rietveld 408576698