| Index: chrome/browser/autofill/autofill_interactive_uitest.cc
|
| diff --git a/chrome/browser/autofill/autofill_interactive_uitest.cc b/chrome/browser/autofill/autofill_interactive_uitest.cc
|
| index 379b449bb9be40c8fda557f0bed00585ade666a5..7f629d2b847e051724bfb984873924e0dfbe6e4b 100644
|
| --- a/chrome/browser/autofill/autofill_interactive_uitest.cc
|
| +++ b/chrome/browser/autofill/autofill_interactive_uitest.cc
|
| @@ -15,13 +15,11 @@
|
| #include "base/strings/string_split.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/time/time.h"
|
| -#include "chrome/browser/autofill/personal_data_manager_factory.h"
|
| +#include "chrome/browser/autofill/autofill_uitest_util.h"
|
| #include "chrome/browser/chrome_notification_types.h"
|
| -#include "chrome/browser/infobars/infobar_service.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/translate/chrome_translate_client.h"
|
| #include "chrome/browser/translate/translate_service.h"
|
| -#include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_window.h"
|
| #include "chrome/browser/ui/tabs/tab_strip_model.h"
|
| #include "chrome/common/render_messages.h"
|
| @@ -35,11 +33,7 @@
|
| #include "components/autofill/core/browser/autofill_manager_test_delegate.h"
|
| #include "components/autofill/core/browser/autofill_profile.h"
|
| #include "components/autofill/core/browser/autofill_test_utils.h"
|
| -#include "components/autofill/core/browser/personal_data_manager.h"
|
| -#include "components/autofill/core/browser/personal_data_manager_observer.h"
|
| #include "components/autofill/core/browser/validation.h"
|
| -#include "components/infobars/core/confirm_infobar_delegate.h"
|
| -#include "components/infobars/core/infobar.h"
|
| #include "components/infobars/core/infobar_manager.h"
|
| #include "components/translate/core/browser/translate_infobar_delegate.h"
|
| #include "content/public/browser/navigation_controller.h"
|
| @@ -51,7 +45,6 @@
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/test/browser_test_utils.h"
|
| #include "content/public/test/test_renderer_host.h"
|
| -#include "content/public/test/test_utils.h"
|
| #include "net/url_request/test_url_fetcher_factory.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| @@ -132,67 +125,6 @@ class AutofillManagerTestDelegateImpl
|
| DISALLOW_COPY_AND_ASSIGN(AutofillManagerTestDelegateImpl);
|
| };
|
|
|
| -
|
| -// WindowedPersonalDataManagerObserver ----------------------------------------
|
| -
|
| -class WindowedPersonalDataManagerObserver
|
| - : public PersonalDataManagerObserver,
|
| - public infobars::InfoBarManager::Observer {
|
| - public:
|
| - explicit WindowedPersonalDataManagerObserver(Browser* browser)
|
| - : alerted_(false),
|
| - has_run_message_loop_(false),
|
| - browser_(browser),
|
| - infobar_service_(InfoBarService::FromWebContents(
|
| - browser_->tab_strip_model()->GetActiveWebContents())) {
|
| - PersonalDataManagerFactory::GetForProfile(browser_->profile())->
|
| - AddObserver(this);
|
| - infobar_service_->AddObserver(this);
|
| - }
|
| -
|
| - ~WindowedPersonalDataManagerObserver() override {
|
| - while (infobar_service_->infobar_count() > 0) {
|
| - infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0));
|
| - }
|
| - infobar_service_->RemoveObserver(this);
|
| - }
|
| -
|
| - // PersonalDataManagerObserver:
|
| - void OnPersonalDataChanged() override {
|
| - if (has_run_message_loop_) {
|
| - base::MessageLoopForUI::current()->Quit();
|
| - has_run_message_loop_ = false;
|
| - }
|
| - alerted_ = true;
|
| - }
|
| -
|
| - void OnInsufficientFormData() override { OnPersonalDataChanged(); }
|
| -
|
| -
|
| - void Wait() {
|
| - if (!alerted_) {
|
| - has_run_message_loop_ = true;
|
| - content::RunMessageLoop();
|
| - }
|
| - PersonalDataManagerFactory::GetForProfile(browser_->profile())->
|
| - RemoveObserver(this);
|
| - }
|
| -
|
| - private:
|
| - // infobars::InfoBarManager::Observer:
|
| - void OnInfoBarAdded(infobars::InfoBar* infobar) override {
|
| - infobar_service_->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()->
|
| - Accept();
|
| - }
|
| -
|
| - bool alerted_;
|
| - bool has_run_message_loop_;
|
| - Browser* browser_;
|
| - InfoBarService* infobar_service_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(WindowedPersonalDataManagerObserver);
|
| -};
|
| -
|
| // AutofillInteractiveTest ----------------------------------------------------
|
|
|
| class AutofillInteractiveTest : public InProcessBrowserTest {
|
| @@ -234,10 +166,6 @@ class AutofillInteractiveTest : public InProcessBrowserTest {
|
| autofill_manager->client()->HideAutofillPopup();
|
| }
|
|
|
| - PersonalDataManager* GetPersonalDataManager() {
|
| - return PersonalDataManagerFactory::GetForProfile(browser()->profile());
|
| - }
|
| -
|
| content::WebContents* GetWebContents() {
|
| return browser()->tab_strip_model()->GetActiveWebContents();
|
| }
|
| @@ -246,24 +174,9 @@ class AutofillInteractiveTest : public InProcessBrowserTest {
|
| return GetWebContents()->GetRenderViewHost();
|
| }
|
|
|
| - void CreateTestProfile() {
|
| - AutofillProfile profile;
|
| - test::SetProfileInfo(
|
| - &profile, "Milton", "C.", "Waddams",
|
| - "red.swingline@initech.com", "Initech", "4120 Freidrich Lane",
|
| - "Basement", "Austin", "Texas", "78744", "US", "5125551234");
|
| -
|
| - WindowedPersonalDataManagerObserver observer(browser());
|
| - GetPersonalDataManager()->AddProfile(profile);
|
| -
|
| - // AddProfile is asynchronous. Wait for it to finish before continuing the
|
| - // tests.
|
| - observer.Wait();
|
| - }
|
| -
|
| void SetProfiles(std::vector<AutofillProfile>* profiles) {
|
| WindowedPersonalDataManagerObserver observer(browser());
|
| - GetPersonalDataManager()->SetProfiles(profiles);
|
| + GetPersonalDataManager(browser())->SetProfiles(profiles);
|
| observer.Wait();
|
| }
|
|
|
| @@ -500,7 +413,7 @@ class AutofillInteractiveTest : public InProcessBrowserTest {
|
|
|
| // Test that basic form fill is working.
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, BasicFormFill) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| // Load the test page.
|
| ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
|
| @@ -512,7 +425,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, BasicFormFill) {
|
|
|
| // Test that form filling can be initiated by pressing the down arrow.
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillViaDownArrow) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| // Load the test page.
|
| ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
|
| @@ -537,7 +450,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillViaDownArrow) {
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillSelectViaTab) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| // Load the test page.
|
| ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
|
| @@ -562,7 +475,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillSelectViaTab) {
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillViaClick) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| // Load the test page.
|
| ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(
|
| @@ -588,7 +501,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillViaClick) {
|
|
|
| // Makes sure that the first click does *not* activate the popup.
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DontAutofillForFirstClick) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| // Load the test page.
|
| ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(
|
| @@ -610,7 +523,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DontAutofillForFirstClick) {
|
| // Makes sure that clicking outside the focused field doesn't activate
|
| // the popup.
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DontAutofillForOutsideClick) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| // Load the test page.
|
| ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(
|
| @@ -634,7 +547,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DontAutofillForOutsideClick) {
|
| // Test that a field is still autofillable after the previously autofilled
|
| // value is deleted.
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnDeleteValueAfterAutofill) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| // Load the test page.
|
| ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
|
| @@ -699,7 +612,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest,
|
|
|
| // Test that a JavaScript oninput event is fired after auto-filling a form.
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnInputAfterAutofill) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| const char kOnInputScript[] =
|
| "<script>"
|
| @@ -771,7 +684,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnInputAfterAutofill) {
|
|
|
| // Test that a JavaScript onchange event is fired after auto-filling a form.
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnChangeAfterAutofill) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| const char kOnChangeScript[] =
|
| "<script>"
|
| @@ -842,7 +755,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, OnChangeAfterAutofill) {
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, InputFiresBeforeChange) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| const char kInputFiresBeforeChangeScript[] =
|
| "<script>"
|
| @@ -922,7 +835,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, InputFiresBeforeChange) {
|
| // Test that we can autofill forms distinguished only by their |id| attribute.
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest,
|
| AutofillFormsDistinguishedById) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| // Load the test page.
|
| const std::string kURL =
|
| @@ -947,7 +860,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest,
|
| // (duplicated for "confirmation"); or variants that are hot-swapped via
|
| // JavaScript, with only one actually visible at any given time.
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillFormWithRepeatedField) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| // Load the test page.
|
| ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
|
| @@ -993,7 +906,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillFormWithRepeatedField) {
|
| // Test that we properly autofill forms with non-autofillable fields.
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest,
|
| AutofillFormWithNonAutofillableField) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| // Load the test page.
|
| ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
|
| @@ -1036,7 +949,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest,
|
|
|
| // Test that we can Autofill dynamically generated forms.
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DynamicFormFill) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| // Load the test page.
|
| ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
|
| @@ -1124,7 +1037,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DynamicFormFill) {
|
|
|
| // Test that form filling works after reloading the current page.
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillAfterReload) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| // Load the test page.
|
| ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
|
| @@ -1144,7 +1057,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, AutofillAfterTranslate) {
|
| if (TranslateService::IsTranslateBubbleEnabled())
|
| return;
|
|
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| GURL url(std::string(kDataURIPrefix) +
|
| "<form action=\"http://www.example.com/\" method=\"POST\">"
|
| @@ -1296,7 +1209,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, NoAutofillForReadOnlyFields) {
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, DISABLED_FormFillableOnReset) {
|
| ASSERT_TRUE(test_server()->Start());
|
|
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| GURL url = test_server()->GetURL("files/autofill/autofill_test_form.html");
|
| ui_test_utils::NavigateToURL(browser(), url);
|
| @@ -1324,7 +1237,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest,
|
| DISABLED_DistinguishMiddleInitialWithinName) {
|
| ASSERT_TRUE(test_server()->Start());
|
|
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| GURL url = test_server()->GetURL(
|
| "files/autofill/autofill_middleinit_form.html");
|
| @@ -1435,7 +1348,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest,
|
| // http://crbug.com/160476
|
| IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest,
|
| DisableAutocompleteWhileFilling) {
|
| - CreateTestProfile();
|
| + CreateTestProfile(browser());
|
|
|
| // Load the test page.
|
| ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
|
|
|