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

Unified Diff: chrome/renderer/autofill/autofill_renderer_browsertest.cc

Issue 563313004: [Password Manager] Unfriend PasswordAutofillAgentTest from PasswordAutofillAgent (clean-up). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated review comments. Created 6 years, 3 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
« no previous file with comments | « no previous file | chrome/renderer/autofill/password_autofill_agent_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/autofill/autofill_renderer_browsertest.cc
diff --git a/chrome/renderer/autofill/autofill_renderer_browsertest.cc b/chrome/renderer/autofill/autofill_renderer_browsertest.cc
index 75ff742a75d4cd4c4eb168d591c27621aed5389f..66e3a6c24220c94b2b6513412f0afcd3e15a3466 100644
--- a/chrome/renderer/autofill/autofill_renderer_browsertest.cc
+++ b/chrome/renderer/autofill/autofill_renderer_browsertest.cc
@@ -54,6 +54,14 @@ class AutofillRendererTest : public ChromeRenderViewTest {
SendContentStateImmediately();
}
+ void SimulateRequestAutocompleteResult(
+ const blink::WebFormElement::AutocompleteResult& result,
+ const base::string16& message) {
+ AutofillMsg_RequestAutocompleteResult msg(0, result, message, FormData());
+ static_cast<content::RenderViewObserver*>(autofill_agent_)
+ ->OnMessageReceived(msg);
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(AutofillRendererTest);
};
@@ -199,7 +207,8 @@ TEST_F(AutofillRendererTest, ShowAutofillWarning) {
// Simulate attempting to Autofill the form from the first element, which
// specifies autocomplete="off". This should still trigger an IPC which
// shouldn't display warnings.
- autofill_agent_->FormControlElementClicked(firstname, true);
+ static_cast<PageClickListener*>(autofill_agent_)
+ ->FormControlElementClicked(firstname, true);
const IPC::Message* message1 = render_thread_->sink().GetFirstMessageMatching(
AutofillHostMsg_QueryFormFieldAutofill::ID);
EXPECT_NE(static_cast<IPC::Message*>(NULL), message1);
@@ -213,7 +222,8 @@ TEST_F(AutofillRendererTest, ShowAutofillWarning) {
// does not specify autocomplete="off". This should trigger an IPC that will
// show warnings, as we *do* show warnings for elements that don't themselves
// set autocomplete="off", but for which the form does.
- autofill_agent_->FormControlElementClicked(middlename, true);
+ static_cast<PageClickListener*>(autofill_agent_)
+ ->FormControlElementClicked(middlename, true);
const IPC::Message* message2 = render_thread_->sink().GetFirstMessageMatching(
AutofillHostMsg_QueryFormFieldAutofill::ID);
ASSERT_NE(static_cast<IPC::Message*>(NULL), message2);
@@ -277,7 +287,8 @@ class RequestAutocompleteRendererTest : public AutofillRendererTest {
render_thread_->sink().ClearMessages();
// Invoke requestAutocomplete to show the dialog.
- autofill_agent_->didRequestAutocomplete(invoking_form());
+ static_cast<blink::WebAutofillClient*>(autofill_agent_)
+ ->didRequestAutocomplete(invoking_form());
ASSERT_TRUE(render_thread_->sink().GetFirstMessageMatching(
AutofillHostMsg_RequestAutocomplete::ID));
@@ -329,10 +340,9 @@ TEST_F(RequestAutocompleteRendererTest, MainFrameNavigateCancels) {
TEST_F(RequestAutocompleteRendererTest, NoCancelOnSubframeNavigateAfterDone) {
// Pretend that the dialog was cancelled.
- autofill_agent_->OnRequestAutocompleteResult(
+ SimulateRequestAutocompleteResult(
WebFormElement::AutocompleteResultErrorCancel,
- base::ASCIIToUTF16("Print me to the console"),
- FormData());
+ base::ASCIIToUTF16("Print me to the console"));
// Additional navigations should not crash nor send cancels.
NavigateFrame(invoking_frame());
@@ -342,10 +352,9 @@ TEST_F(RequestAutocompleteRendererTest, NoCancelOnSubframeNavigateAfterDone) {
TEST_F(RequestAutocompleteRendererTest, NoCancelOnMainFrameNavigateAfterDone) {
// Pretend that the dialog was cancelled.
- autofill_agent_->OnRequestAutocompleteResult(
+ SimulateRequestAutocompleteResult(
WebFormElement::AutocompleteResultErrorCancel,
- base::ASCIIToUTF16("Print me to the console"),
- FormData());
+ base::ASCIIToUTF16("Print me to the console"));
// Additional navigations should not crash nor send cancels.
NavigateFrame(GetMainFrame());
@@ -355,7 +364,8 @@ TEST_F(RequestAutocompleteRendererTest, NoCancelOnMainFrameNavigateAfterDone) {
TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) {
// Attempting to show the requestAutocomplete dialog again should be ignored.
- autofill_agent_->didRequestAutocomplete(invoking_form());
+ static_cast<blink::WebAutofillClient*>(autofill_agent_)
+ ->didRequestAutocomplete(invoking_form());
EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
AutofillHostMsg_RequestAutocomplete::ID));
}
« no previous file with comments | « no previous file | chrome/renderer/autofill/password_autofill_agent_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698