summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-04 21:11:14 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-04 21:11:14 +0000
commit2511466dd15750f2ab0e5cecc30010f0a3f7949c (patch)
tree43684f81641ff74ac452679029a18fd65cd03e79 /chrome/browser/autofill
parent9381ee13d3cb8d4531a37d4b31cbae5068bb46d5 (diff)
downloadchromium_src-2511466dd15750f2ab0e5cecc30010f0a3f7949c.zip
chromium_src-2511466dd15750f2ab0e5cecc30010f0a3f7949c.tar.gz
chromium_src-2511466dd15750f2ab0e5cecc30010f0a3f7949c.tar.bz2
Convert the autofill interactive browser test to a normal browser_test. I added testing methods to fake input events that don't depend on the OS and being at the front.
BUG=121574 Review URL: https://chromiumcodereview.appspot.com/10368010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135432 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/autofill_browsertest.cc68
1 files changed, 27 insertions, 41 deletions
diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc
index 99d6c2d..248795e 100644
--- a/chrome/browser/autofill/autofill_browsertest.cc
+++ b/chrome/browser/autofill/autofill_browsertest.cc
@@ -186,10 +186,7 @@ class AutofillTest : public InProcessBrowserTest {
void FocusFirstNameField() {
LOG(WARNING) << "Clicking on the tab.";
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::ClickOnView(browser(),
- VIEW_ID_TAB_CONTAINER));
- ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(),
- VIEW_ID_TAB_CONTAINER));
+ ui_test_utils::SimulateMouseClick(browser()->GetSelectedWebContents());
LOG(WARNING) << "Focusing the first name field.";
bool result = false;
@@ -215,24 +212,28 @@ class AutofillTest : public InProcessBrowserTest {
ExpectFieldValue(L"phone", "5125551234");
}
+ void SendKeyAndWait(ui::KeyboardCode key, int notification_type) {
+ ui_test_utils::WindowedNotificationObserver observer(
+ notification_type, content::Source<RenderViewHost>(render_view_host()));
+ ui_test_utils::SimulateKeyPress(
+ browser()->GetSelectedWebContents(), key, false, false, false, false);
+ observer.Wait();
+ }
+
void TryBasicFormFill() {
FocusFirstNameField();
// Start filling the first name field with "M" and wait for the popup to be
// shown.
LOG(WARNING) << "Typing 'M' to bring up the Autofill popup.";
- ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
- browser(), ui::VKEY_M, false, true, false, false,
- chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS,
- content::Source<RenderViewHost>(render_view_host())));
+ SendKeyAndWait(
+ ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS);
// Press the down arrow to select the suggestion and preview the autofilled
// form.
LOG(WARNING) << "Simulating down arrow press to initiate Autofill preview.";
- ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
- browser(), ui::VKEY_DOWN, false, false, false, false,
- chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
- content::Source<RenderViewHost>(render_view_host())));
+ SendKeyAndWait(
+ ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA);
// The previewed values should not be accessible to JavaScript.
ExpectFieldValue(L"firstname", "M");
@@ -249,10 +250,8 @@ class AutofillTest : public InProcessBrowserTest {
// Press Enter to accept the autofill suggestions.
LOG(WARNING) << "Simulating Return press to fill the form.";
- ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
- browser(), ui::VKEY_RETURN, false, false, false, false,
- chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
- content::Source<RenderViewHost>(render_view_host())));
+ SendKeyAndWait(
+ ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA);
// The form should be filled.
ExpectFilledTestForm();
@@ -267,7 +266,6 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, BasicFormFill) {
CreateTestProfile();
// Load the test page.
- ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
GURL(std::string(kDataURIPrefix) + kTestFormString)));
@@ -289,23 +287,17 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, AutofillViaDownArrow) {
// Press the down arrow to initiate Autofill and wait for the popup to be
// shown.
- ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
- browser(), ui::VKEY_DOWN, false, false, false, false,
- chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS,
- content::Source<RenderViewHost>(render_view_host())));
+ SendKeyAndWait(
+ ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS);
// Press the down arrow to select the suggestion and preview the autofilled
// form.
- ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
- browser(), ui::VKEY_DOWN, false, false, false, false,
- chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
- content::Source<RenderViewHost>(render_view_host())));
+ SendKeyAndWait(
+ ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA);
// Press Enter to accept the autofill suggestions.
- ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
- browser(), ui::VKEY_RETURN, false, false, false, false,
- chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
- content::Source<RenderViewHost>(render_view_host())));
+ SendKeyAndWait(
+ ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA);
// The form should be filled.
ExpectFilledTestForm();
@@ -346,23 +338,17 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, OnChangeAfterAutofill) {
// Start filling the first name field with "M" and wait for the popup to be
// shown.
- ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
- browser(), ui::VKEY_M, false, true, false, false,
- chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS,
- content::Source<RenderViewHost>(render_view_host())));
+ SendKeyAndWait(
+ ui::VKEY_M, chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS);
// Press the down arrow to select the suggestion and preview the autofilled
// form.
- ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
- browser(), ui::VKEY_DOWN, false, false, false, false,
- chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
- content::Source<RenderViewHost>(render_view_host())));
+ SendKeyAndWait(
+ ui::VKEY_DOWN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA);
// Press Enter to accept the autofill suggestions.
- ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
- browser(), ui::VKEY_RETURN, false, false, false, false,
- chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
- content::Source<RenderViewHost>(render_view_host())));
+ SendKeyAndWait(
+ ui::VKEY_RETURN, chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA);
// The form should be filled.
ExpectFilledTestForm();