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

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: 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 MOCK_METHOD0(ClearPreviewedForm, void()); 56 MOCK_METHOD0(ClearPreviewedForm, void());
57 57
58 MOCK_METHOD0(HideAutofillPopup, void()); 58 MOCK_METHOD0(HideAutofillPopup, void());
59 59
60 private: 60 private:
61 virtual void HideAutofillPopupInternal() {}; 61 virtual void HideAutofillPopupInternal() {};
62 }; 62 };
63 63
64 class MockAutofillManager : public AutofillManager { 64 class MockAutofillManager : public AutofillManager {
65 public: 65 public:
66 explicit MockAutofillManager(autofill::AutofillManagerDelegate* delegate, 66 explicit MockAutofillManager(content::WebContents* web_contents,
67 TabContents* tab_contents) 67 autofill::AutofillManagerDelegate* delegate)
68 // Force to use the constructor designated for unit test, but we don't 68 // Force to use the constructor designated for unit test, but we don't
69 // really need personal_data in this test so we pass a NULL pointer. 69 // really need personal_data in this test so we pass a NULL pointer.
70 : AutofillManager(delegate, tab_contents, NULL) { 70 : AutofillManager(web_contents, delegate, NULL) {
71 } 71 }
72 72
73 MOCK_METHOD4(OnFillAutofillFormData, 73 MOCK_METHOD4(OnFillAutofillFormData,
74 void(int query_id, 74 void(int query_id,
75 const webkit::forms::FormData& form, 75 const webkit::forms::FormData& form,
76 const webkit::forms::FormField& field, 76 const webkit::forms::FormField& field,
77 int unique_id)); 77 int unique_id));
78 78
79 protected: 79 protected:
80 virtual ~MockAutofillManager() {} 80 virtual ~MockAutofillManager() {}
81 }; 81 };
82 82
83 } // namespace 83 } // namespace
84 84
85 class AutofillExternalDelegateUnitTest : public TabContentsTestHarness { 85 class AutofillExternalDelegateUnitTest : public TabContentsTestHarness {
86 public: 86 public:
87 AutofillExternalDelegateUnitTest() 87 AutofillExternalDelegateUnitTest()
88 : ui_thread_(BrowserThread::UI, &message_loop_) {} 88 : ui_thread_(BrowserThread::UI, &message_loop_) {}
89 virtual ~AutofillExternalDelegateUnitTest() {} 89 virtual ~AutofillExternalDelegateUnitTest() {}
90 90
91 virtual void SetUp() OVERRIDE { 91 virtual void SetUp() OVERRIDE {
92 TabContentsTestHarness::SetUp(); 92 TabContentsTestHarness::SetUp();
93 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); 93 TabAutofillManagerDelegate::CreateForWebContents(web_contents());
94 autofill_manager_ = new MockAutofillManager( 94 autofill_manager_ = new MockAutofillManager(
95 TabAutofillManagerDelegate::FromWebContents(web_contents()), 95 web_contents(),
96 tab_contents()); 96 TabAutofillManagerDelegate::FromWebContents(web_contents()));
97 external_delegate_.reset(new MockAutofillExternalDelegate( 97 external_delegate_.reset(new MockAutofillExternalDelegate(
98 tab_contents(), 98 tab_contents(),
99 autofill_manager_)); 99 autofill_manager_));
100 } 100 }
101 101
102 protected: 102 protected:
103 // Set up the expectation for a platform specific OnQuery call and then 103 // Set up the expectation for a platform specific OnQuery call and then
104 // execute it with the given QueryId. 104 // execute it with the given QueryId.
105 void IssueOnQuery(int query_id) { 105 void IssueOnQuery(int query_id) {
106 const FormData form; 106 const FormData form;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 external_delegate_->SelectAutofillSuggestionAtIndex(1); 245 external_delegate_->SelectAutofillSuggestionAtIndex(1);
246 } 246 }
247 247
248 // Test that the popup is hidden once we are done editing the autofill field. 248 // Test that the popup is hidden once we are done editing the autofill field.
249 TEST_F(AutofillExternalDelegateUnitTest, 249 TEST_F(AutofillExternalDelegateUnitTest,
250 ExternalDelegateHidePopupAfterEditing) { 250 ExternalDelegateHidePopupAfterEditing) {
251 EXPECT_CALL(*external_delegate_, HideAutofillPopup()); 251 EXPECT_CALL(*external_delegate_, HideAutofillPopup());
252 252
253 external_delegate_->DidEndTextFieldEditing(); 253 external_delegate_->DidEndTextFieldEditing();
254 } 254 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698