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

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

Issue 112663005: Add autofill preview support for Textarea (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test code Created 6 years, 12 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: chrome/renderer/autofill/form_autofill_browsertest.cc
diff --git a/chrome/renderer/autofill/form_autofill_browsertest.cc b/chrome/renderer/autofill/form_autofill_browsertest.cc
index ba454f1f067ecbb13e0fda119f2b34c0a94f96ed..611a0c2402eb31636a0f93a5631d9de5b20ad94b 100644
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc
@@ -160,7 +160,7 @@ class FormAutofillTest : public ChromeRenderViewTest {
typedef void (*FillFormFunction)(const FormData& form,
const WebInputElement& element);
- typedef WebString (WebInputElement::*GetValueFunction)(void) const;
+ typedef WebString (*GetValueFunction)(WebFormControlElement element);
// Test FormFillxxx functions.
void TestFormFillFunctions(const char* html,
@@ -234,13 +234,11 @@ class FormAutofillTest : public ChromeRenderViewTest {
if (element.formControlType() == "select-one") {
value = element.to<WebSelectElement>().value();
} else if (element.formControlType() == "textarea") {
- value = element.to<WebTextAreaElement>().value();
+ value = get_value_function(element);
} else {
ASSERT_TRUE(element.formControlType() == "text" ||
element.formControlType() == "month");
- WebInputElement input_element = GetMainFrame()->document().getElementById(
- ASCIIToUTF16(field_case.name)).to<WebInputElement>();
- value = (input_element.*get_value_function)();
+ value = get_value_function(element);
}
const WebString expected_value = ASCIIToUTF16(field_case.expected_value);
@@ -263,6 +261,24 @@ class FormAutofillTest : public ChromeRenderViewTest {
FillFormIncludingNonFocusableElements(form, element.form());
}
+ static WebString GetValueWrapper(WebFormControlElement element) {
+ WebString value;
+ if (element.formControlType() == "textarea")
+ value = element.to<WebTextAreaElement>().value();
+ else
+ value = element.to<WebInputElement>().value();
+ return value;
Ilya Sherman 2014/01/07 01:09:38 nit: No need for the local variable value, i.e. yo
ziran.sun 2014/01/07 16:40:41 Done.
+ }
+
+ static WebString GetSuggestedValueWrapper(WebFormControlElement element) {
+ WebString suggested_value;
+ if (element.formControlType() == "textarea")
+ suggested_value = element.to<WebTextAreaElement>().suggestedValue();
+ else
+ suggested_value = element.to<WebInputElement>().suggestedValue();
+ return suggested_value;
+ }
Ilya Sherman 2014/01/07 01:09:38 Likewise for this method.
ziran.sun 2014/01/07 16:40:41 Done.
+
private:
DISALLOW_COPY_AND_ASSIGN(FormAutofillTest);
};
@@ -1114,7 +1130,7 @@ TEST_F(FormAutofillTest, FillForm) {
"some multi-\nline value", "Go\naway!"},
};
TestFormFillFunctions(kFormHtml, field_cases, arraysize(field_cases),
- FillForm, &WebInputElement::value);
+ FillForm, &GetValueWrapper);
// Verify preview selection.
WebInputElement firstname = GetMainFrame()->document().
getElementById("firstname").to<WebInputElement>();
@@ -1164,7 +1180,7 @@ TEST_F(FormAutofillTest, FillFormIncludingNonFocusableElements) {
};
TestFormFillFunctions(kFormHtml, field_cases, arraysize(field_cases),
&FillFormIncludingNonFocusableElementsWrapper,
- &WebInputElement::value);
+ &GetValueWrapper);
}
TEST_F(FormAutofillTest, PreviewForm) {
@@ -1175,6 +1191,7 @@ TEST_F(FormAutofillTest, PreviewForm) {
" <INPUT type=\"text\" id=\"notempty\" value=\"Hi\"/>"
" <INPUT type=\"text\" autocomplete=\"off\" id=\"noautocomplete\"/>"
" <INPUT type=\"text\" disabled=\"disabled\" id=\"notenabled\"/>"
+ " <TEXTAREA id=\"textarea\"></TEXTAREA>"
" <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>"
"</FORM>";
Ilya Sherman 2014/01/07 01:09:38 Please update this test to use kFormHtml rather th
ziran.sun 2014/01/07 16:40:41 I think selection preview is not supported from th
Ilya Sherman 2014/01/08 04:13:47 That's true, but I think we could still have test
ziran.sun 2014/01/08 17:02:39 I've made a note on <select> fields saying that pr
ziran.sun 2014/01/08 17:02:39 Done.
@@ -1189,9 +1206,12 @@ TEST_F(FormAutofillTest, PreviewForm) {
// "noautocomplete" should not be extracted to form_data.
// Disabled fields should not be previewed.
{"text", "notenabled", "", "", false, "filled notenabled", ""},
+ // Normal textarea elements should be previewed.
+ {"textarea", "textarea", "", "", true, "suggested multi-\nline value",
+ "suggested multi-\nline value"},
};
TestFormFillFunctions(html, field_cases, arraysize(field_cases), &PreviewForm,
- &WebInputElement::suggestedValue);
+ &GetSuggestedValueWrapper);
// Verify preview selection.
WebInputElement firstname = GetMainFrame()->document().

Powered by Google App Engine
This is Rietveld 408576698