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

Side by Side Diff: chrome/browser/autofill/autofill_interactive_uitest.cc

Issue 16286020: Abstract WebContentsObserver from Autofill shared code (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to fix conflict Created 7 years, 6 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
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 "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "chrome/browser/autofill/personal_data_manager_factory.h" 7 #include "chrome/browser/autofill/personal_data_manager_factory.h"
8 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 8 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 #include "chrome/common/chrome_notification_types.h" 11 #include "chrome/common/chrome_notification_types.h"
12 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chrome/test/base/ui_test_utils.h" 13 #include "chrome/test/base/ui_test_utils.h"
14 #include "components/autofill/browser/autofill_common_test.h" 14 #include "components/autofill/browser/autofill_common_test.h"
15 #include "components/autofill/browser/autofill_external_delegate.h" 15 #include "components/autofill/browser/autofill_external_delegate.h"
16 #include "components/autofill/browser/autofill_manager.h" 16 #include "components/autofill/browser/autofill_manager.h"
17 #include "components/autofill/browser/autofill_manager_test_delegate.h" 17 #include "components/autofill/browser/autofill_manager_test_delegate.h"
18 #include "components/autofill/browser/autofill_profile.h" 18 #include "components/autofill/browser/autofill_profile.h"
19 #include "components/autofill/browser/personal_data_manager.h" 19 #include "components/autofill/browser/personal_data_manager.h"
20 #include "components/autofill/browser/personal_data_manager_observer.h" 20 #include "components/autofill/browser/personal_data_manager_observer.h"
21 #include "components/autofill/content/browser/autofill_driver_impl.h"
21 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
23 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
25 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
26 #include "content/public/test/browser_test_utils.h" 27 #include "content/public/test/browser_test_utils.h"
27 #include "content/public/test/test_utils.h" 28 #include "content/public/test/test_utils.h"
28 #include "ui/base/keycodes/keyboard_codes.h" 29 #include "ui/base/keycodes/keyboard_codes.h"
29 30
30 using content::RenderViewHost; 31 using content::RenderViewHost;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 200
200 virtual void SetUpOnMainThread() OVERRIDE { 201 virtual void SetUpOnMainThread() OVERRIDE {
201 // Don't want Keychain coming up on Mac. 202 // Don't want Keychain coming up on Mac.
202 test::DisableSystemServices(browser()->profile()); 203 test::DisableSystemServices(browser()->profile());
203 204
204 // When testing the native UI, hook up a test external delegate, which 205 // When testing the native UI, hook up a test external delegate, which
205 // allows us to forward keyboard events to the popup directly. 206 // allows us to forward keyboard events to the popup directly.
206 content::WebContents* web_contents = 207 content::WebContents* web_contents =
207 browser()->tab_strip_model()->GetActiveWebContents(); 208 browser()->tab_strip_model()->GetActiveWebContents();
208 AutofillManager* autofill_manager = 209 AutofillManager* autofill_manager =
209 AutofillManager::FromWebContents(web_contents); 210 AutofillDriverImpl::FromWebContents(web_contents)->autofill_manager();
210 if (autofill_manager->IsNativeUiEnabled()) { 211 if (autofill_manager->IsNativeUiEnabled()) {
211 external_delegate_.reset( 212 external_delegate_.reset(
212 new TestAutofillExternalDelegate(web_contents, autofill_manager)); 213 new TestAutofillExternalDelegate(web_contents, autofill_manager));
213 autofill_manager->SetExternalDelegate(external_delegate_.get()); 214 autofill_manager->SetExternalDelegate(external_delegate_.get());
214 } 215 }
215 autofill_manager->SetTestDelegate(&test_delegate_); 216 autofill_manager->SetTestDelegate(&test_delegate_);
216 } 217 }
217 218
218 virtual void CleanUpOnMainThread() OVERRIDE { 219 virtual void CleanUpOnMainThread() OVERRIDE {
219 // Make sure to close any showing popups prior to tearing down the UI. 220 // Make sure to close any showing popups prior to tearing down the UI.
220 content::WebContents* web_contents = 221 content::WebContents* web_contents =
221 browser()->tab_strip_model()->GetActiveWebContents(); 222 browser()->tab_strip_model()->GetActiveWebContents();
222 AutofillManager* autofill_manager = 223 AutofillManager* autofill_manager =
223 AutofillManager::FromWebContents(web_contents); 224 AutofillDriverImpl::FromWebContents(web_contents)->autofill_manager();
224 autofill_manager->delegate()->HideAutofillPopup(); 225 autofill_manager->delegate()->HideAutofillPopup();
225 } 226 }
226 227
227 PersonalDataManager* personal_data_manager() { 228 PersonalDataManager* personal_data_manager() {
228 return PersonalDataManagerFactory::GetForProfile(browser()->profile()); 229 return PersonalDataManagerFactory::GetForProfile(browser()->profile());
229 } 230 }
230 231
231 void CreateTestProfile() { 232 void CreateTestProfile() {
232 AutofillProfile profile; 233 AutofillProfile profile;
233 test::SetProfileInfo( 234 test::SetProfileInfo(
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 SendKeyToPopupAndWait(ui::VKEY_DOWN); 346 SendKeyToPopupAndWait(ui::VKEY_DOWN);
346 347
347 // Press tab to accept the autofill suggestions. 348 // Press tab to accept the autofill suggestions.
348 SendKeyToPopupAndWait(ui::VKEY_TAB); 349 SendKeyToPopupAndWait(ui::VKEY_TAB);
349 350
350 // The form should be filled. 351 // The form should be filled.
351 ExpectFilledTestForm(); 352 ExpectFilledTestForm();
352 } 353 }
353 354
354 } // namespace autofill 355 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698