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

Side by Side 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, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/autofill/autofill_uitest_util.h"
6 #include "chrome/browser/autofill/personal_data_manager_factory.h"
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "components/autofill/core/browser/autofill_test_utils.h"
10 #include "components/autofill/core/browser/personal_data_manager.h"
11 #include "content/public/test/test_utils.h"
12
13 namespace autofill {
14
15 WindowedPersonalDataManagerObserver::WindowedPersonalDataManagerObserver(
16 Browser* browser)
17 : alerted_(false),
18 has_run_message_loop_(false),
19 browser_(browser),
20 infobar_service_(InfoBarService::FromWebContents(
21 browser_->tab_strip_model()->GetActiveWebContents())) {
22 PersonalDataManagerFactory::GetForProfile(browser_->profile())->AddObserver(
23 this);
24 infobar_service_->AddObserver(this);
25 }
26
27 WindowedPersonalDataManagerObserver::~WindowedPersonalDataManagerObserver() {
28 while (infobar_service_->infobar_count() > 0) {
29 infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0));
30 }
31 infobar_service_->RemoveObserver(this);
32 }
33
34 void WindowedPersonalDataManagerObserver::OnPersonalDataChanged() {
35 if (has_run_message_loop_) {
36 base::MessageLoopForUI::current()->Quit();
37 has_run_message_loop_ = false;
38 }
39 alerted_ = true;
40 }
41
42 void WindowedPersonalDataManagerObserver::OnInsufficientFormData() {
43 OnPersonalDataChanged();
44 }
45
46 void WindowedPersonalDataManagerObserver::Wait() {
47 if (!alerted_) {
48 has_run_message_loop_ = true;
49 content::RunMessageLoop();
50 }
51 PersonalDataManagerFactory::GetForProfile(browser_->profile())->
52 RemoveObserver(this);
53 }
54
55 void WindowedPersonalDataManagerObserver::OnInfoBarAdded(
56 infobars::InfoBar* infobar) {
57 infobar_service_->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()->
58 Accept();
59 }
60
61 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.
62 return PersonalDataManagerFactory::GetForProfile(browser->profile());
63 }
64
65 void CreateTestProfile(Browser* browser) {
66 AutofillProfile profile;
67 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
68 &profile, "Milton", "C.", "Waddams",
69 "red.swingline@initech.com", "Initech", "4120 Freidrich Lane",
70 "Basement", "Austin", "Texas", "78744", "US", "5125551234");
71
72 WindowedPersonalDataManagerObserver observer(browser);
73 GetPersonalDataManager(browser)->AddProfile(profile);
74
75 // AddProfile is asynchronous. Wait for it to finish before continuing the
76 // tests.
77 observer.Wait();
78 }
79
80 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698