Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 gtest. | |
|
Ilya Sherman
2013/07/16 21:21:56
I'm confused... you're not using gtest in this fil
groby-ooo-7-16
2013/07/16 23:05:07
Done.
| |
| 6 #include "grit/generated_resources.h" | 7 #include "grit/generated_resources.h" |
| 7 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
|
Ilya Sherman
2013/07/16 21:21:56
nit: Already included in the header.
groby-ooo-7-16
2013/07/16 23:05:07
Done.
| |
| 9 #include "ui/gfx/rect.h" // Only needed because gtest needs complete types. | |
|
Ilya Sherman
2013/07/16 21:21:56
Ditto
groby-ooo-7-16
2013/07/16 23:05:07
Done.
| |
| 8 | 10 |
| 9 namespace autofill { | 11 namespace autofill { |
| 10 | 12 |
| 13 using namespace testing; | |
|
Ilya Sherman
2013/07/16 21:21:56
nit: "using namespace" is disallowed by the style
groby-ooo-7-16
2013/07/16 23:05:07
Done. TMYK.
| |
| 14 | |
| 11 MockAutofillDialogController::MockAutofillDialogController() { | 15 MockAutofillDialogController::MockAutofillDialogController() { |
| 12 testing::DefaultValue<const DetailInputs&>::Set(default_inputs_); | 16 DefaultValue<const DetailInputs&>::Set(default_inputs_); |
| 13 testing::DefaultValue<ui::ComboboxModel*>::Set(NULL); | 17 DefaultValue<DialogSignedInState>::Set(REQUIRES_RESPONSE); |
| 14 testing::DefaultValue<ValidityData>::Set(ValidityData()); | |
| 15 | 18 |
| 16 // SECTION_CC *must* have a CREDIT_CARD_VERIFICATION_CODE field. | 19 // SECTION_CC *must* have a CREDIT_CARD_VERIFICATION_CODE field. |
| 17 const DetailInput kCreditCardInputs[] = { | 20 const DetailInput kCreditCardInputs[] = { |
| 18 { 2, CREDIT_CARD_VERIFICATION_CODE, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC } | 21 { 2, CREDIT_CARD_VERIFICATION_CODE, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC } |
| 19 }; | 22 }; |
| 20 cc_default_inputs_.push_back(kCreditCardInputs[0]); | 23 cc_default_inputs_.push_back(kCreditCardInputs[0]); |
| 21 ON_CALL(*this, RequestedFieldsForSection(SECTION_CC)) | 24 ON_CALL(*this, RequestedFieldsForSection(SECTION_CC)) |
| 22 .WillByDefault(testing::ReturnRef(cc_default_inputs_)); | 25 .WillByDefault(ReturnRef(cc_default_inputs_)); |
| 26 | |
| 27 ON_CALL(*this, GetDialogButtons()) | |
| 28 .WillByDefault(Return(ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL)); | |
| 29 ON_CALL(*this, LegalDocumentLinks()).WillByDefault(ReturnRef(range_)); | |
| 23 | 30 |
| 24 // Activate all sections but CC_BILLING - default for the real | 31 // Activate all sections but CC_BILLING - default for the real |
| 25 // controller implementation, too. | 32 // controller implementation, too. |
| 26 ON_CALL(*this, SectionIsActive(testing::_)) | 33 ON_CALL(*this, SectionIsActive(_)).WillByDefault(Return(true)); |
| 27 .WillByDefault(testing::Return(true)); | |
| 28 ON_CALL(*this, SectionIsActive(SECTION_CC_BILLING)) | 34 ON_CALL(*this, SectionIsActive(SECTION_CC_BILLING)) |
| 29 .WillByDefault(testing::Return(false)); | 35 .WillByDefault(Return(false)); |
| 30 } | 36 } |
| 31 | 37 |
| 32 MockAutofillDialogController::~MockAutofillDialogController() { | 38 MockAutofillDialogController::~MockAutofillDialogController() { |
| 33 testing::DefaultValue<ValidityData>::Clear(); | 39 DefaultValue<DialogSignedInState>::Clear(); |
| 34 testing::DefaultValue<ui::ComboboxModel*>::Clear(); | 40 DefaultValue<const DetailInputs&>::Clear(); |
| 35 testing::DefaultValue<const DetailInputs&>::Clear(); | |
| 36 } | |
| 37 | |
| 38 string16 MockAutofillDialogController::DialogTitle() const { | |
| 39 return string16(); | |
| 40 } | |
| 41 | |
| 42 string16 MockAutofillDialogController::AccountChooserText() const { | |
| 43 return string16(); | |
| 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 bool MockAutofillDialogController::ShouldOfferToSaveInChrome() const { | |
| 79 return false; | |
| 80 } | |
| 81 | |
| 82 gfx::Image MockAutofillDialogController::AccountChooserImage() { | |
| 83 return gfx::Image(); | |
| 84 } | |
| 85 | |
| 86 bool MockAutofillDialogController::ShouldShowDetailArea() const { | |
| 87 return false; | |
| 88 } | |
| 89 | |
| 90 bool MockAutofillDialogController::ShouldShowProgressBar() const { | |
| 91 return false; | |
| 92 } | |
| 93 | |
| 94 int MockAutofillDialogController::GetDialogButtons() const { | |
| 95 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; | |
| 96 } | |
| 97 | |
| 98 bool MockAutofillDialogController::IsDialogButtonEnabled( | |
| 99 ui::DialogButton button) const { | |
| 100 return false; | |
| 101 } | |
| 102 | |
| 103 DialogOverlayState MockAutofillDialogController::GetDialogOverlay() const { | |
| 104 return DialogOverlayState(); | |
| 105 } | |
| 106 | |
| 107 const std::vector<ui::Range>& | |
| 108 MockAutofillDialogController::LegalDocumentLinks() { | |
| 109 return range_; | |
| 110 } | |
| 111 | |
| 112 string16 MockAutofillDialogController::LabelForSection( | |
| 113 DialogSection section) const { | |
| 114 return string16(); | |
| 115 } | |
| 116 | |
| 117 SuggestionState MockAutofillDialogController::SuggestionStateForSection( | |
| 118 DialogSection section) { | |
| 119 return SuggestionState(string16(), | |
| 120 gfx::Font::NORMAL, | |
| 121 gfx::Image(), | |
| 122 string16(), | |
| 123 gfx::Image()); | |
| 124 } | |
| 125 | |
| 126 void MockAutofillDialogController::EditClickedForSection( | |
| 127 DialogSection section) {} | |
| 128 | |
| 129 void MockAutofillDialogController::EditCancelledForSection( | |
| 130 DialogSection section) {} | |
| 131 | |
| 132 gfx::Image MockAutofillDialogController::IconForField( | |
| 133 AutofillFieldType type, const string16& user_input) const { | |
| 134 return gfx::Image(); | |
| 135 } | |
| 136 | |
| 137 string16 MockAutofillDialogController::InputValidityMessage( | |
| 138 DialogSection section, | |
| 139 AutofillFieldType type, | |
| 140 const string16& value) { | |
| 141 return string16(); | |
| 142 } | |
| 143 | |
| 144 void MockAutofillDialogController::UserEditedOrActivatedInput( | |
| 145 DialogSection section, | |
| 146 const DetailInput* input, | |
| 147 gfx::NativeView parent_view, | |
| 148 const gfx::Rect& content_bounds, | |
| 149 const string16& field_contents, | |
| 150 bool was_edit) {} | |
| 151 | |
| 152 bool MockAutofillDialogController::HandleKeyPressEventInInput( | |
| 153 const content::NativeWebKeyboardEvent& event) { | |
| 154 return false; | |
| 155 } | |
| 156 | |
| 157 void MockAutofillDialogController::FocusMoved() {} | |
| 158 | |
| 159 gfx::Image MockAutofillDialogController::SplashPageImage() const { | |
| 160 return gfx::Image(); | |
| 161 } | |
| 162 | |
| 163 void MockAutofillDialogController::ViewClosed() {} | |
| 164 | |
| 165 std::vector<DialogNotification> MockAutofillDialogController:: | |
| 166 CurrentNotifications() { | |
| 167 return std::vector<DialogNotification>(); | |
| 168 } | |
| 169 | |
| 170 std::vector<DialogAutocheckoutStep> MockAutofillDialogController:: | |
| 171 CurrentAutocheckoutSteps() const { | |
| 172 return std::vector<DialogAutocheckoutStep>(); | |
| 173 } | |
| 174 | |
| 175 void MockAutofillDialogController::SignInLinkClicked() {} | |
| 176 | |
| 177 void MockAutofillDialogController::NotificationCheckboxStateChanged( | |
| 178 DialogNotification::Type type, | |
| 179 bool checked) {} | |
| 180 | |
| 181 void MockAutofillDialogController::LegalDocumentLinkClicked( | |
| 182 const ui::Range& range) {} | |
| 183 | |
| 184 void MockAutofillDialogController::OverlayButtonPressed() {} | |
| 185 | |
| 186 void MockAutofillDialogController::OnCancel() {} | |
| 187 | |
| 188 void MockAutofillDialogController::OnAccept() {} | |
| 189 | |
| 190 content::WebContents* MockAutofillDialogController::web_contents() { | |
| 191 return NULL; | |
| 192 } | 41 } |
| 193 | 42 |
| 194 } // namespace autofill | 43 } // namespace autofill |
| OLD | NEW |