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

Side by Side Diff: chrome/browser/ui/autofill/mock_autofill_dialog_controller.cc

Issue 19278007: [rAC] Complete controller mock object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to HEAD. Created 7 years, 5 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/browser/ui/autofill/mock_autofill_dialog_controller.h ('k') | no next file » | 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) 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 "chrome/browser/ui/autofill/mock_autofill_dialog_controller.h" 5 #include "chrome/browser/ui/autofill/mock_autofill_dialog_controller.h"
6 #include "content/public/browser/native_web_keyboard_event.h" // For gmock.
6 #include "grit/generated_resources.h" 7 #include "grit/generated_resources.h"
7 #include "testing/gmock/include/gmock/gmock.h" 8 #include "ui/gfx/rect.h" // Only needed because gmock needs complete types.
8 9
9 namespace autofill { 10 namespace autofill {
10 11
11 MockAutofillDialogController::MockAutofillDialogController() { 12 MockAutofillDialogController::MockAutofillDialogController() {
12 testing::DefaultValue<const DetailInputs&>::Set(default_inputs_); 13 using testing::DefaultValue;
13 testing::DefaultValue<ui::ComboboxModel*>::Set(NULL); 14 using testing::_;
14 testing::DefaultValue<ValidityData>::Set(ValidityData()); 15 using testing::Return;
16 using testing::ReturnRef;
17
18 // N.B. Setting DefaultValue in the ctor and deleting it in the dtor will
19 // only work if this Mock is not used together with other mock code that
20 // sets different defaults. If tests utilizing the MockController start
21 // breaking because of this, use ON_CALL instead.
22 DefaultValue<const DetailInputs&>::Set(default_inputs_);
23 DefaultValue<string16>::Set(string16());
24 DefaultValue<ValidityData>::Set(ValidityData());
25 DefaultValue<DialogSignedInState>::Set(REQUIRES_RESPONSE);
26 DefaultValue<gfx::Image>::Set(gfx::Image());
27 DefaultValue<SuggestionState>::Set(SuggestionState(string16(),
28 gfx::Font::NORMAL,
29 gfx::Image(),
30 string16(),
31 gfx::Image()));
15 32
16 // SECTION_CC *must* have a CREDIT_CARD_VERIFICATION_CODE field. 33 // SECTION_CC *must* have a CREDIT_CARD_VERIFICATION_CODE field.
17 const DetailInput kCreditCardInputs[] = { 34 const DetailInput kCreditCardInputs[] = {
18 { 2, CREDIT_CARD_VERIFICATION_CODE, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC } 35 { 2, CREDIT_CARD_VERIFICATION_CODE, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC }
19 }; 36 };
20 cc_default_inputs_.push_back(kCreditCardInputs[0]); 37 cc_default_inputs_.push_back(kCreditCardInputs[0]);
21 ON_CALL(*this, RequestedFieldsForSection(SECTION_CC)) 38 ON_CALL(*this, RequestedFieldsForSection(SECTION_CC))
22 .WillByDefault(testing::ReturnRef(cc_default_inputs_)); 39 .WillByDefault(ReturnRef(cc_default_inputs_));
40
41 ON_CALL(*this, GetDialogButtons())
42 .WillByDefault(Return(ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL));
43 ON_CALL(*this, LegalDocumentLinks()).WillByDefault(ReturnRef(range_));
23 44
24 // Activate all sections but CC_BILLING - default for the real 45 // Activate all sections but CC_BILLING - default for the real
25 // controller implementation, too. 46 // controller implementation, too.
26 ON_CALL(*this, SectionIsActive(testing::_)) 47 ON_CALL(*this, SectionIsActive(_)).WillByDefault(Return(true));
27 .WillByDefault(testing::Return(true));
28 ON_CALL(*this, SectionIsActive(SECTION_CC_BILLING)) 48 ON_CALL(*this, SectionIsActive(SECTION_CC_BILLING))
29 .WillByDefault(testing::Return(false)); 49 .WillByDefault(Return(false));
30 } 50 }
31 51
32 MockAutofillDialogController::~MockAutofillDialogController() { 52 MockAutofillDialogController::~MockAutofillDialogController() {
33 testing::DefaultValue<ValidityData>::Clear(); 53 using testing::DefaultValue;
34 testing::DefaultValue<ui::ComboboxModel*>::Clear();
35 testing::DefaultValue<const DetailInputs&>::Clear();
36 }
37 54
38 string16 MockAutofillDialogController::DialogTitle() const { 55 DefaultValue<SuggestionState>::Clear();
39 return string16(); 56 DefaultValue<gfx::Image>::Clear();
40 } 57 DefaultValue<DialogSignedInState>::Clear();
41 58 DefaultValue<ValidityData>::Clear();
42 string16 MockAutofillDialogController::AccountChooserText() const { 59 DefaultValue<string16>::Clear();
43 return string16(); 60 DefaultValue<const DetailInputs&>::Clear();
44 }
45
46 string16 MockAutofillDialogController::SignInLinkText() const {
47 return string16();
48 }
49
50 string16 MockAutofillDialogController::EditSuggestionText() const {
51 return string16();
52 }
53
54 string16 MockAutofillDialogController::CancelButtonText() const {
55 return string16();
56 }
57
58 string16 MockAutofillDialogController::ConfirmButtonText() const {
59 return string16();
60 }
61
62 string16 MockAutofillDialogController::SaveLocallyText() const {
63 return string16();
64 }
65
66 string16 MockAutofillDialogController::LegalDocumentsText() {
67 return string16();
68 }
69
70 DialogSignedInState MockAutofillDialogController::SignedInState() const {
71 return REQUIRES_RESPONSE;
72 }
73
74 bool MockAutofillDialogController::ShouldShowSpinner() const {
75 return false;
76 }
77
78 gfx::Image MockAutofillDialogController::AccountChooserImage() {
79 return gfx::Image();
80 }
81
82 bool MockAutofillDialogController::ShouldShowDetailArea() const {
83 return false;
84 }
85
86 bool MockAutofillDialogController::ShouldShowProgressBar() const {
87 return false;
88 }
89
90 int MockAutofillDialogController::GetDialogButtons() const {
91 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
92 }
93
94 bool MockAutofillDialogController::IsDialogButtonEnabled(
95 ui::DialogButton button) const {
96 return false;
97 }
98
99 DialogOverlayState MockAutofillDialogController::GetDialogOverlay() const {
100 return DialogOverlayState();
101 }
102
103 const std::vector<ui::Range>&
104 MockAutofillDialogController::LegalDocumentLinks() {
105 return range_;
106 }
107
108 string16 MockAutofillDialogController::LabelForSection(
109 DialogSection section) const {
110 return string16();
111 }
112
113 SuggestionState MockAutofillDialogController::SuggestionStateForSection(
114 DialogSection section) {
115 return SuggestionState(string16(),
116 gfx::Font::NORMAL,
117 gfx::Image(),
118 string16(),
119 gfx::Image());
120 }
121
122 void MockAutofillDialogController::EditClickedForSection(
123 DialogSection section) {}
124
125 void MockAutofillDialogController::EditCancelledForSection(
126 DialogSection section) {}
127
128 gfx::Image MockAutofillDialogController::IconForField(
129 AutofillFieldType type, const string16& user_input) const {
130 return gfx::Image();
131 }
132
133 string16 MockAutofillDialogController::InputValidityMessage(
134 DialogSection section,
135 AutofillFieldType type,
136 const string16& value) {
137 return string16();
138 }
139
140 void MockAutofillDialogController::UserEditedOrActivatedInput(
141 DialogSection section,
142 const DetailInput* input,
143 gfx::NativeView parent_view,
144 const gfx::Rect& content_bounds,
145 const string16& field_contents,
146 bool was_edit) {}
147
148 bool MockAutofillDialogController::HandleKeyPressEventInInput(
149 const content::NativeWebKeyboardEvent& event) {
150 return false;
151 }
152
153 void MockAutofillDialogController::FocusMoved() {}
154
155 gfx::Image MockAutofillDialogController::SplashPageImage() const {
156 return gfx::Image();
157 }
158
159 void MockAutofillDialogController::ViewClosed() {}
160
161 std::vector<DialogNotification> MockAutofillDialogController::
162 CurrentNotifications() {
163 return std::vector<DialogNotification>();
164 }
165
166 std::vector<DialogAutocheckoutStep> MockAutofillDialogController::
167 CurrentAutocheckoutSteps() const {
168 return std::vector<DialogAutocheckoutStep>();
169 }
170
171 void MockAutofillDialogController::SignInLinkClicked() {}
172
173 void MockAutofillDialogController::NotificationCheckboxStateChanged(
174 DialogNotification::Type type,
175 bool checked) {}
176
177 void MockAutofillDialogController::LegalDocumentLinkClicked(
178 const ui::Range& range) {}
179
180 void MockAutofillDialogController::OverlayButtonPressed() {}
181
182 void MockAutofillDialogController::OnCancel() {}
183
184 void MockAutofillDialogController::OnAccept() {}
185
186 content::WebContents* MockAutofillDialogController::web_contents() {
187 return NULL;
188 } 61 }
189 62
190 } // namespace autofill 63 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/mock_autofill_dialog_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698