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

Unified Diff: chrome/browser/autofill/autofill_uitest_util.cc

Issue 819193003: Fix list focus after tab key in chrome://settings/autofillEditAddress page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make UI test work for phone list. Created 5 years, 11 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/browser/autofill/autofill_uitest_util.cc
diff --git a/chrome/browser/autofill/autofill_uitest_util.cc b/chrome/browser/autofill/autofill_uitest_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7aeeba49e40b2cae6fe82cad061dfb4e06fa81e7
--- /dev/null
+++ b/chrome/browser/autofill/autofill_uitest_util.cc
@@ -0,0 +1,80 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/autofill/autofill_uitest_util.h"
+#include "chrome/browser/autofill/personal_data_manager_factory.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "components/autofill/core/browser/autofill_test_utils.h"
+#include "components/autofill/core/browser/personal_data_manager.h"
+#include "content/public/test/test_utils.h"
+
+namespace autofill {
+
+WindowedPersonalDataManagerObserver::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::~WindowedPersonalDataManagerObserver() {
+ while (infobar_service_->infobar_count() > 0) {
+ infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0));
+ }
+ infobar_service_->RemoveObserver(this);
+}
+
+void WindowedPersonalDataManagerObserver::OnPersonalDataChanged() {
+ if (has_run_message_loop_) {
+ base::MessageLoopForUI::current()->Quit();
+ has_run_message_loop_ = false;
+ }
+ alerted_ = true;
+}
+
+void WindowedPersonalDataManagerObserver::OnInsufficientFormData() {
+ OnPersonalDataChanged();
+}
+
+void WindowedPersonalDataManagerObserver::Wait() {
+ if (!alerted_) {
+ has_run_message_loop_ = true;
+ content::RunMessageLoop();
+ }
+ PersonalDataManagerFactory::GetForProfile(browser_->profile())->
+ RemoveObserver(this);
+}
+
+void WindowedPersonalDataManagerObserver::OnInfoBarAdded(
+ infobars::InfoBar* infobar) {
+ infobar_service_->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()->
+ Accept();
+}
+
+PersonalDataManager* GetPersonalDataManager(Browser* browser) {
Dan Beam 2015/01/29 19:31:44 nit: ask for a Profile* instead of a Browser*
bondd 2015/01/30 04:10:35 Done.
+ return PersonalDataManagerFactory::GetForProfile(browser->profile());
+}
+
+void CreateTestProfile(Browser* browser) {
+ AutofillProfile profile;
+ test::SetProfileInfo(
Evan Stade 2015/01/29 22:20:11 why not GetFullProfile()?
bondd 2015/01/30 04:10:35 Some tests in autofill_interactive_uitest.cc expec
+ &profile, "Milton", "C.", "Waddams",
+ "red.swingline@initech.com", "Initech", "4120 Freidrich Lane",
+ "Basement", "Austin", "Texas", "78744", "US", "5125551234");
+
+ WindowedPersonalDataManagerObserver observer(browser);
+ GetPersonalDataManager(browser)->AddProfile(profile);
+
+ // AddProfile is asynchronous. Wait for it to finish before continuing the
+ // tests.
+ observer.Wait();
+}
+
+} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698