BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / autofill / mock_autofill_dialog_view_delegate.cc
blob5f16b9cbc68be9ab356ecc6ed1bda37e6ec1dcc5
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.
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 "ui/base/l10n/l10n_util.h"
9 #include "ui/gfx/geometry/rect.h" // Only needed because gmock needs complete types.
11 namespace autofill {
13 MockAutofillDialogViewDelegate::MockAutofillDialogViewDelegate() {
14 using testing::DefaultValue;
15 using testing::_;
16 using testing::Return;
17 using testing::ReturnRef;
19 // N.B. Setting DefaultValue in the ctor and deleting it in the dtor will
20 // only work if this Mock is not used together with other mock code that
21 // sets different defaults. If tests utilizing the MockController start
22 // breaking because of this, use ON_CALL instead.
23 DefaultValue<const DetailInputs&>::Set(default_inputs_);
24 DefaultValue<base::string16>::Set(base::string16());
25 DefaultValue<GURL>::Set(GURL());
26 DefaultValue<ValidityMessages>::Set(ValidityMessages());
27 DefaultValue<gfx::Image>::Set(gfx::Image());
28 DefaultValue<SuggestionState>::Set(SuggestionState(false,
29 base::string16(),
30 base::string16(),
31 gfx::Image(),
32 base::string16(),
33 gfx::Image()));
34 DefaultValue<FieldIconMap>::Set(FieldIconMap());
35 DefaultValue<std::vector<DialogNotification> >::Set(
36 std::vector<DialogNotification>());
38 // SECTION_CC *must* have a CREDIT_CARD_VERIFICATION_CODE field.
39 const DetailInput kCreditCardInputs[] = {
40 { DetailInput::SHORT,
41 CREDIT_CARD_VERIFICATION_CODE,
42 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC) }
44 cc_default_inputs_.push_back(kCreditCardInputs[0]);
45 ON_CALL(*this, RequestedFieldsForSection(SECTION_CC))
46 .WillByDefault(ReturnRef(cc_default_inputs_));
48 ON_CALL(*this, GetDialogButtons())
49 .WillByDefault(Return(ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL));
50 ON_CALL(*this, LegalDocumentLinks()).WillByDefault(ReturnRef(range_));
52 // Activate all sections but CC_BILLING - default for the real
53 // controller implementation, too.
54 ON_CALL(*this, SectionIsActive(_)).WillByDefault(Return(true));
57 void MockAutofillDialogViewDelegate::SetWebContents(
58 content::WebContents* contents) {
59 testing::DefaultValue<content::WebContents*>::Set(contents);
62 void MockAutofillDialogViewDelegate::SetProfile(Profile* profile) {
63 testing::DefaultValue<Profile*>::Set(profile);
66 MockAutofillDialogViewDelegate::~MockAutofillDialogViewDelegate() {
67 using testing::DefaultValue;
69 DefaultValue<SuggestionState>::Clear();
70 DefaultValue<gfx::Image>::Clear();
71 DefaultValue<ValidityMessages>::Clear();
72 DefaultValue<base::string16>::Clear();
73 DefaultValue<GURL>::Clear();
74 DefaultValue<const DetailInputs&>::Clear();
75 DefaultValue<FieldIconMap>::Clear();
76 DefaultValue<std::vector<DialogNotification> >::Clear();
77 DefaultValue<content::WebContents*>::Clear();
78 DefaultValue<Profile*>::Clear();
81 } // namespace autofill