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

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

Issue 10222017: Make password generation switched by a preference in chrome settings rather than a command line fla… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make MockAutofillManager to use the constructor designated for unit tests to avoid dangling pref_ob… Created 8 years, 7 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
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/autofill/autofill_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 MOCK_METHOD0(ClearPreviewedForm, void()); 49 MOCK_METHOD0(ClearPreviewedForm, void());
50 50
51 MOCK_METHOD0(HideAutofillPopup, void()); 51 MOCK_METHOD0(HideAutofillPopup, void());
52 52
53 private: 53 private:
54 virtual void HideAutofillPopupInternal() {}; 54 virtual void HideAutofillPopupInternal() {};
55 }; 55 };
56 56
57 class MockAutofillManager : public AutofillManager { 57 class MockAutofillManager : public AutofillManager {
58 public: 58 public:
59 explicit MockAutofillManager(TabContentsWrapper* tab_contents) 59 MockAutofillManager(TabContentsWrapper* tab_contents,
60 : AutofillManager(tab_contents) {} 60 PersonalDataManager* personal_data)
61 : AutofillManager(tab_contents, personal_data) {}
Ilya Sherman 2012/05/16 18:10:38 nit: Rather than adding a new parameter for |perso
zysxqn 2012/05/16 18:25:03 Done.
61 62
62 MOCK_METHOD4(OnFillAutofillFormData, 63 MOCK_METHOD4(OnFillAutofillFormData,
63 void(int query_id, 64 void(int query_id,
64 const webkit::forms::FormData& form, 65 const webkit::forms::FormData& form,
65 const webkit::forms::FormField& field, 66 const webkit::forms::FormField& field,
66 int unique_id)); 67 int unique_id));
67 68
68 protected: 69 protected:
69 virtual ~MockAutofillManager() {} 70 virtual ~MockAutofillManager() {}
70 }; 71 };
71 72
72 } // namespace 73 } // namespace
73 74
74 class AutofillExternalDelegateUnitTest : public TabContentsWrapperTestHarness { 75 class AutofillExternalDelegateUnitTest : public TabContentsWrapperTestHarness {
75 public: 76 public:
76 AutofillExternalDelegateUnitTest() 77 AutofillExternalDelegateUnitTest()
77 : ui_thread_(BrowserThread::UI, &message_loop_) {} 78 : ui_thread_(BrowserThread::UI, &message_loop_) {}
78 virtual ~AutofillExternalDelegateUnitTest() {} 79 virtual ~AutofillExternalDelegateUnitTest() {}
79 80
80 virtual void SetUp() OVERRIDE { 81 virtual void SetUp() OVERRIDE {
81 TabContentsWrapperTestHarness::SetUp(); 82 TabContentsWrapperTestHarness::SetUp();
82 autofill_manager_ = new MockAutofillManager(contents_wrapper()); 83 // Force to use the constructor designated for unit test, but we don't
84 // really need personal_data in this test so we pass a NULL pointer.
85 autofill_manager_ = new MockAutofillManager(contents_wrapper(), NULL);
83 external_delegate_.reset(new MockAutofillExternalDelegate( 86 external_delegate_.reset(new MockAutofillExternalDelegate(
84 contents_wrapper(), 87 contents_wrapper(),
85 autofill_manager_)); 88 autofill_manager_));
86 } 89 }
87 90
88 protected: 91 protected:
89 scoped_refptr<MockAutofillManager> autofill_manager_; 92 scoped_refptr<MockAutofillManager> autofill_manager_;
90 scoped_ptr<MockAutofillExternalDelegate> external_delegate_; 93 scoped_ptr<MockAutofillExternalDelegate> external_delegate_;
91 94
92 private: 95 private:
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 external_delegate_->SelectAutofillSuggestionAtIndex(1); 167 external_delegate_->SelectAutofillSuggestionAtIndex(1);
165 } 168 }
166 169
167 // Test that the popup is hidden once we are done editing the autofill field. 170 // Test that the popup is hidden once we are done editing the autofill field.
168 TEST_F(AutofillExternalDelegateUnitTest, 171 TEST_F(AutofillExternalDelegateUnitTest,
169 ExternalDelegateHidePopupAfterEditing) { 172 ExternalDelegateHidePopupAfterEditing) {
170 EXPECT_CALL(*external_delegate_, HideAutofillPopup()); 173 EXPECT_CALL(*external_delegate_, HideAutofillPopup());
171 174
172 external_delegate_->DidEndTextFieldEditing(); 175 external_delegate_->DidEndTextFieldEditing();
173 } 176 }
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/autofill/autofill_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698