| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/autofill/mock_autofill_dialog_view_delegate.h" | |
| 6 #include "chrome/grit/generated_resources.h" | |
| 7 #include "content/public/browser/native_web_keyboard_event.h" // For gmock. | |
| 8 #include "grit/components_strings.h" | |
| 9 #include "ui/base/l10n/l10n_util.h" | |
| 10 #include "ui/gfx/geometry/rect.h" // Only needed because gmock needs complete t
ypes. | |
| 11 | |
| 12 namespace autofill { | |
| 13 | |
| 14 MockAutofillDialogViewDelegate::MockAutofillDialogViewDelegate() { | |
| 15 using testing::DefaultValue; | |
| 16 using testing::_; | |
| 17 using testing::Return; | |
| 18 using testing::ReturnRef; | |
| 19 | |
| 20 // N.B. Setting DefaultValue in the ctor and deleting it in the dtor will | |
| 21 // only work if this Mock is not used together with other mock code that | |
| 22 // sets different defaults. If tests utilizing the MockController start | |
| 23 // breaking because of this, use ON_CALL instead. | |
| 24 DefaultValue<const DetailInputs&>::Set(default_inputs_); | |
| 25 DefaultValue<base::string16>::Set(base::string16()); | |
| 26 DefaultValue<GURL>::Set(GURL()); | |
| 27 DefaultValue<ValidityMessages>::Set(ValidityMessages()); | |
| 28 DefaultValue<gfx::Image>::Set(gfx::Image()); | |
| 29 DefaultValue<SuggestionState>::Set(SuggestionState(false, | |
| 30 base::string16(), | |
| 31 base::string16(), | |
| 32 gfx::Image(), | |
| 33 base::string16(), | |
| 34 gfx::Image())); | |
| 35 DefaultValue<FieldIconMap>::Set(FieldIconMap()); | |
| 36 DefaultValue<std::vector<DialogNotification> >::Set( | |
| 37 std::vector<DialogNotification>()); | |
| 38 | |
| 39 // SECTION_CC *must* have a CREDIT_CARD_VERIFICATION_CODE field. | |
| 40 const DetailInput kCreditCardInputs[] = { | |
| 41 { DetailInput::SHORT, | |
| 42 CREDIT_CARD_VERIFICATION_CODE, | |
| 43 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC) } | |
| 44 }; | |
| 45 cc_default_inputs_.push_back(kCreditCardInputs[0]); | |
| 46 ON_CALL(*this, RequestedFieldsForSection(SECTION_CC)) | |
| 47 .WillByDefault(ReturnRef(cc_default_inputs_)); | |
| 48 | |
| 49 ON_CALL(*this, GetDialogButtons()) | |
| 50 .WillByDefault(Return(ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL)); | |
| 51 ON_CALL(*this, LegalDocumentLinks()).WillByDefault(ReturnRef(range_)); | |
| 52 | |
| 53 // Activate all sections but CC_BILLING - default for the real | |
| 54 // controller implementation, too. | |
| 55 ON_CALL(*this, SectionIsActive(_)).WillByDefault(Return(true)); | |
| 56 } | |
| 57 | |
| 58 void MockAutofillDialogViewDelegate::SetWebContents( | |
| 59 content::WebContents* contents) { | |
| 60 testing::DefaultValue<content::WebContents*>::Set(contents); | |
| 61 } | |
| 62 | |
| 63 void MockAutofillDialogViewDelegate::SetProfile(Profile* profile) { | |
| 64 testing::DefaultValue<Profile*>::Set(profile); | |
| 65 } | |
| 66 | |
| 67 MockAutofillDialogViewDelegate::~MockAutofillDialogViewDelegate() { | |
| 68 using testing::DefaultValue; | |
| 69 | |
| 70 DefaultValue<SuggestionState>::Clear(); | |
| 71 DefaultValue<gfx::Image>::Clear(); | |
| 72 DefaultValue<ValidityMessages>::Clear(); | |
| 73 DefaultValue<base::string16>::Clear(); | |
| 74 DefaultValue<GURL>::Clear(); | |
| 75 DefaultValue<const DetailInputs&>::Clear(); | |
| 76 DefaultValue<FieldIconMap>::Clear(); | |
| 77 DefaultValue<std::vector<DialogNotification> >::Clear(); | |
| 78 DefaultValue<content::WebContents*>::Clear(); | |
| 79 DefaultValue<Profile*>::Clear(); | |
| 80 } | |
| 81 | |
| 82 } // namespace autofill | |
| OLD | NEW |