OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 " <input type=\"text\" id=\"phone\"><br>" | 92 " <input type=\"text\" id=\"phone\"><br>" |
93 "</form>"; | 93 "</form>"; |
94 | 94 |
95 | 95 |
96 // AutofillManagerTestDelegateImpl -------------------------------------------- | 96 // AutofillManagerTestDelegateImpl -------------------------------------------- |
97 | 97 |
98 class AutofillManagerTestDelegateImpl | 98 class AutofillManagerTestDelegateImpl |
99 : public autofill::AutofillManagerTestDelegate { | 99 : public autofill::AutofillManagerTestDelegate { |
100 public: | 100 public: |
101 AutofillManagerTestDelegateImpl() {} | 101 AutofillManagerTestDelegateImpl() {} |
102 virtual ~AutofillManagerTestDelegateImpl() {} | 102 ~AutofillManagerTestDelegateImpl() override {} |
103 | 103 |
104 // autofill::AutofillManagerTestDelegate: | 104 // autofill::AutofillManagerTestDelegate: |
105 virtual void DidPreviewFormData() override { | 105 void DidPreviewFormData() override { |
106 ASSERT_TRUE(loop_runner_->loop_running()); | 106 ASSERT_TRUE(loop_runner_->loop_running()); |
107 loop_runner_->Quit(); | 107 loop_runner_->Quit(); |
108 } | 108 } |
109 | 109 |
110 virtual void DidFillFormData() override { | 110 void DidFillFormData() override { |
111 ASSERT_TRUE(loop_runner_->loop_running()); | 111 ASSERT_TRUE(loop_runner_->loop_running()); |
112 loop_runner_->Quit(); | 112 loop_runner_->Quit(); |
113 } | 113 } |
114 | 114 |
115 virtual void DidShowSuggestions() override { | 115 void DidShowSuggestions() override { |
116 ASSERT_TRUE(loop_runner_->loop_running()); | 116 ASSERT_TRUE(loop_runner_->loop_running()); |
117 loop_runner_->Quit(); | 117 loop_runner_->Quit(); |
118 } | 118 } |
119 | 119 |
120 void Reset() { | 120 void Reset() { |
121 loop_runner_ = new content::MessageLoopRunner(); | 121 loop_runner_ = new content::MessageLoopRunner(); |
122 } | 122 } |
123 | 123 |
124 void Wait() { | 124 void Wait() { |
125 loop_runner_->Run(); | 125 loop_runner_->Run(); |
(...skipping 16 matching lines...) Expand all Loading... |
142 : alerted_(false), | 142 : alerted_(false), |
143 has_run_message_loop_(false), | 143 has_run_message_loop_(false), |
144 browser_(browser), | 144 browser_(browser), |
145 infobar_service_(InfoBarService::FromWebContents( | 145 infobar_service_(InfoBarService::FromWebContents( |
146 browser_->tab_strip_model()->GetActiveWebContents())) { | 146 browser_->tab_strip_model()->GetActiveWebContents())) { |
147 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> | 147 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> |
148 AddObserver(this); | 148 AddObserver(this); |
149 infobar_service_->AddObserver(this); | 149 infobar_service_->AddObserver(this); |
150 } | 150 } |
151 | 151 |
152 virtual ~WindowedPersonalDataManagerObserver() { | 152 ~WindowedPersonalDataManagerObserver() override { |
153 while (infobar_service_->infobar_count() > 0) { | 153 while (infobar_service_->infobar_count() > 0) { |
154 infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0)); | 154 infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0)); |
155 } | 155 } |
156 infobar_service_->RemoveObserver(this); | 156 infobar_service_->RemoveObserver(this); |
157 } | 157 } |
158 | 158 |
159 // PersonalDataManagerObserver: | 159 // PersonalDataManagerObserver: |
160 virtual void OnPersonalDataChanged() override { | 160 void OnPersonalDataChanged() override { |
161 if (has_run_message_loop_) { | 161 if (has_run_message_loop_) { |
162 base::MessageLoopForUI::current()->Quit(); | 162 base::MessageLoopForUI::current()->Quit(); |
163 has_run_message_loop_ = false; | 163 has_run_message_loop_ = false; |
164 } | 164 } |
165 alerted_ = true; | 165 alerted_ = true; |
166 } | 166 } |
167 | 167 |
168 virtual void OnInsufficientFormData() override { | 168 void OnInsufficientFormData() override { OnPersonalDataChanged(); } |
169 OnPersonalDataChanged(); | |
170 } | |
171 | 169 |
172 | 170 |
173 void Wait() { | 171 void Wait() { |
174 if (!alerted_) { | 172 if (!alerted_) { |
175 has_run_message_loop_ = true; | 173 has_run_message_loop_ = true; |
176 content::RunMessageLoop(); | 174 content::RunMessageLoop(); |
177 } | 175 } |
178 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> | 176 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> |
179 RemoveObserver(this); | 177 RemoveObserver(this); |
180 } | 178 } |
181 | 179 |
182 private: | 180 private: |
183 // infobars::InfoBarManager::Observer: | 181 // infobars::InfoBarManager::Observer: |
184 virtual void OnInfoBarAdded(infobars::InfoBar* infobar) override { | 182 void OnInfoBarAdded(infobars::InfoBar* infobar) override { |
185 infobar_service_->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()-> | 183 infobar_service_->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()-> |
186 Accept(); | 184 Accept(); |
187 } | 185 } |
188 | 186 |
189 bool alerted_; | 187 bool alerted_; |
190 bool has_run_message_loop_; | 188 bool has_run_message_loop_; |
191 Browser* browser_; | 189 Browser* browser_; |
192 InfoBarService* infobar_service_; | 190 InfoBarService* infobar_service_; |
193 | 191 |
194 DISALLOW_COPY_AND_ASSIGN(WindowedPersonalDataManagerObserver); | 192 DISALLOW_COPY_AND_ASSIGN(WindowedPersonalDataManagerObserver); |
195 }; | 193 }; |
196 | 194 |
197 // AutofillInteractiveTest ---------------------------------------------------- | 195 // AutofillInteractiveTest ---------------------------------------------------- |
198 | 196 |
199 class AutofillInteractiveTest : public InProcessBrowserTest { | 197 class AutofillInteractiveTest : public InProcessBrowserTest { |
200 protected: | 198 protected: |
201 AutofillInteractiveTest() : | 199 AutofillInteractiveTest() : |
202 key_press_event_sink_( | 200 key_press_event_sink_( |
203 base::Bind(&AutofillInteractiveTest::HandleKeyPressEvent, | 201 base::Bind(&AutofillInteractiveTest::HandleKeyPressEvent, |
204 base::Unretained(this))) {} | 202 base::Unretained(this))) {} |
205 virtual ~AutofillInteractiveTest() {} | 203 virtual ~AutofillInteractiveTest() {} |
206 | 204 |
207 // InProcessBrowserTest: | 205 // InProcessBrowserTest: |
208 virtual void SetUpOnMainThread() override { | 206 void SetUpOnMainThread() override { |
209 // Don't want Keychain coming up on Mac. | 207 // Don't want Keychain coming up on Mac. |
210 test::DisableSystemServices(browser()->profile()->GetPrefs()); | 208 test::DisableSystemServices(browser()->profile()->GetPrefs()); |
211 | 209 |
212 // Inject the test delegate into the AutofillManager. | 210 // Inject the test delegate into the AutofillManager. |
213 content::WebContents* web_contents = GetWebContents(); | 211 content::WebContents* web_contents = GetWebContents(); |
214 ContentAutofillDriver* autofill_driver = | 212 ContentAutofillDriver* autofill_driver = |
215 ContentAutofillDriver::FromWebContents(web_contents); | 213 ContentAutofillDriver::FromWebContents(web_contents); |
216 AutofillManager* autofill_manager = autofill_driver->autofill_manager(); | 214 AutofillManager* autofill_manager = autofill_driver->autofill_manager(); |
217 autofill_manager->SetTestDelegate(&test_delegate_); | 215 autofill_manager->SetTestDelegate(&test_delegate_); |
218 | 216 |
219 // If the mouse happened to be over where the suggestions are shown, then | 217 // If the mouse happened to be over where the suggestions are shown, then |
220 // the preview will show up and will fail the tests. We need to give it a | 218 // the preview will show up and will fail the tests. We need to give it a |
221 // point that's within the browser frame, or else the method hangs. | 219 // point that's within the browser frame, or else the method hangs. |
222 gfx::Point reset_mouse(GetWebContents()->GetContainerBounds().origin()); | 220 gfx::Point reset_mouse(GetWebContents()->GetContainerBounds().origin()); |
223 reset_mouse = gfx::Point(reset_mouse.x() + 5, reset_mouse.y() + 5); | 221 reset_mouse = gfx::Point(reset_mouse.x() + 5, reset_mouse.y() + 5); |
224 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(reset_mouse)); | 222 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(reset_mouse)); |
225 } | 223 } |
226 | 224 |
227 virtual void TearDownOnMainThread() override { | 225 void TearDownOnMainThread() override { |
228 // Make sure to close any showing popups prior to tearing down the UI. | 226 // Make sure to close any showing popups prior to tearing down the UI. |
229 content::WebContents* web_contents = GetWebContents(); | 227 content::WebContents* web_contents = GetWebContents(); |
230 AutofillManager* autofill_manager = ContentAutofillDriver::FromWebContents( | 228 AutofillManager* autofill_manager = ContentAutofillDriver::FromWebContents( |
231 web_contents)->autofill_manager(); | 229 web_contents)->autofill_manager(); |
232 autofill_manager->client()->HideAutofillPopup(); | 230 autofill_manager->client()->HideAutofillPopup(); |
233 } | 231 } |
234 | 232 |
235 PersonalDataManager* GetPersonalDataManager() { | 233 PersonalDataManager* GetPersonalDataManager() { |
236 return PersonalDataManagerFactory::GetForProfile(browser()->profile()); | 234 return PersonalDataManagerFactory::GetForProfile(browser()->profile()); |
237 } | 235 } |
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 ASSERT_TRUE(content::ExecuteScript( | 1447 ASSERT_TRUE(content::ExecuteScript( |
1450 GetRenderViewHost(), | 1448 GetRenderViewHost(), |
1451 "document.querySelector('input').autocomplete = 'off';")); | 1449 "document.querySelector('input').autocomplete = 'off';")); |
1452 | 1450 |
1453 // Press the down arrow to select the suggestion and attempt to preview the | 1451 // Press the down arrow to select the suggestion and attempt to preview the |
1454 // autofilled form. | 1452 // autofilled form. |
1455 SendKeyToPopupAndWait(ui::VKEY_DOWN); | 1453 SendKeyToPopupAndWait(ui::VKEY_DOWN); |
1456 } | 1454 } |
1457 | 1455 |
1458 } // namespace autofill | 1456 } // namespace autofill |
OLD | NEW |