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

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

Issue 10987100: Switch AutofillManager to be UserData on WebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix external delegate Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <vector> 5 #include <vector>
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "chrome/browser/autofill/autofill_manager.h" 10 #include "chrome/browser/autofill/autofill_manager.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 MOCK_METHOD0(ClearPreviewedForm, void()); 54 MOCK_METHOD0(ClearPreviewedForm, void());
55 55
56 MOCK_METHOD0(HideAutofillPopup, void()); 56 MOCK_METHOD0(HideAutofillPopup, void());
57 57
58 private: 58 private:
59 virtual void HideAutofillPopupInternal() {}; 59 virtual void HideAutofillPopupInternal() {};
60 }; 60 };
61 61
62 class MockAutofillManager : public AutofillManager { 62 class MockAutofillManager : public AutofillManager {
63 public: 63 public:
64 explicit MockAutofillManager(autofill::AutofillManagerDelegate* delegate, 64 explicit MockAutofillManager(content::WebContents* web_contents,
65 TabContents* tab_contents) 65 autofill::AutofillManagerDelegate* delegate)
66 // Force to use the constructor designated for unit test, but we don't 66 // Force to use the constructor designated for unit test, but we don't
67 // really need personal_data in this test so we pass a NULL pointer. 67 // really need personal_data in this test so we pass a NULL pointer.
68 : AutofillManager(delegate, tab_contents, NULL) { 68 : AutofillManager(web_contents, delegate, NULL) {
69 } 69 }
70 70
71 MOCK_METHOD4(OnFillAutofillFormData, 71 MOCK_METHOD4(OnFillAutofillFormData,
72 void(int query_id, 72 void(int query_id,
73 const FormData& form, 73 const FormData& form,
74 const FormFieldData& field, 74 const FormFieldData& field,
75 int unique_id)); 75 int unique_id));
76 76
77 protected: 77 protected:
78 virtual ~MockAutofillManager() {} 78 virtual ~MockAutofillManager() {}
79 }; 79 };
80 80
81 } // namespace 81 } // namespace
82 82
83 class AutofillExternalDelegateUnitTest : public TabContentsTestHarness { 83 class AutofillExternalDelegateUnitTest : public TabContentsTestHarness {
84 public: 84 public:
85 AutofillExternalDelegateUnitTest() 85 AutofillExternalDelegateUnitTest()
86 : ui_thread_(BrowserThread::UI, &message_loop_) {} 86 : ui_thread_(BrowserThread::UI, &message_loop_) {}
87 virtual ~AutofillExternalDelegateUnitTest() {} 87 virtual ~AutofillExternalDelegateUnitTest() {}
88 88
89 virtual void SetUp() OVERRIDE { 89 virtual void SetUp() OVERRIDE {
90 TabContentsTestHarness::SetUp(); 90 TabContentsTestHarness::SetUp();
91 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); 91 TabAutofillManagerDelegate::CreateForWebContents(web_contents());
92 autofill_manager_ = new MockAutofillManager( 92 autofill_manager_ = new MockAutofillManager(
93 TabAutofillManagerDelegate::FromWebContents(web_contents()), 93 web_contents(),
94 tab_contents()); 94 TabAutofillManagerDelegate::FromWebContents(web_contents()));
95 external_delegate_.reset(new MockAutofillExternalDelegate( 95 external_delegate_.reset(new MockAutofillExternalDelegate(
96 tab_contents(), 96 tab_contents(),
97 autofill_manager_)); 97 autofill_manager_));
98 } 98 }
99 99
100 protected: 100 protected:
101 // Set up the expectation for a platform specific OnQuery call and then 101 // Set up the expectation for a platform specific OnQuery call and then
102 // execute it with the given QueryId. 102 // execute it with the given QueryId.
103 void IssueOnQuery(int query_id) { 103 void IssueOnQuery(int query_id) {
104 const FormData form; 104 const FormData form;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 external_delegate_->SelectAutofillSuggestionAtIndex(1); 243 external_delegate_->SelectAutofillSuggestionAtIndex(1);
244 } 244 }
245 245
246 // Test that the popup is hidden once we are done editing the autofill field. 246 // Test that the popup is hidden once we are done editing the autofill field.
247 TEST_F(AutofillExternalDelegateUnitTest, 247 TEST_F(AutofillExternalDelegateUnitTest,
248 ExternalDelegateHidePopupAfterEditing) { 248 ExternalDelegateHidePopupAfterEditing) {
249 EXPECT_CALL(*external_delegate_, HideAutofillPopup()); 249 EXPECT_CALL(*external_delegate_, HideAutofillPopup());
250 250
251 external_delegate_->DidEndTextFieldEditing(); 251 external_delegate_->DidEndTextFieldEditing();
252 } 252 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_external_delegate.cc ('k') | chrome/browser/autofill/autofill_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698