BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / views / autofill / autofill_dialog_view_tester_views.cc
blob3a4019bf9f29121a826fa251b4287b289e2c369a
1 // Copyright 2014 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/views/autofill/autofill_dialog_view_tester_views.h"
7 #include "base/logging.h"
8 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h"
9 #include "chrome/browser/ui/views/autofill/expanding_textfield.h"
10 #include "ui/base/models/combobox_model.h"
11 #include "ui/views/controls/combobox/combobox.h"
12 #include "ui/views/controls/textfield/textfield.h"
13 #include "ui/views/controls/webview/webview.h"
14 #include "ui/views/widget/widget.h"
15 #include "ui/views/window/dialog_client_view.h"
17 namespace autofill {
19 scoped_ptr<AutofillDialogViewTester> AutofillDialogViewTester::For(
20 AutofillDialogView* view) {
21 return scoped_ptr<AutofillDialogViewTester>(new
22 AutofillDialogViewTesterViews(static_cast<AutofillDialogViews*>(view)));
25 AutofillDialogViewTesterViews::AutofillDialogViewTesterViews(
26 AutofillDialogViews* view)
27 : view_(view) {}
29 AutofillDialogViewTesterViews::~AutofillDialogViewTesterViews() {}
31 void AutofillDialogViewTesterViews::SubmitForTesting() {
32 view_->Accept();
35 void AutofillDialogViewTesterViews::CancelForTesting() {
36 view_->GetDialogClientView()->CancelWindow();
39 base::string16 AutofillDialogViewTesterViews::GetTextContentsOfInput(
40 ServerFieldType type) {
41 ExpandingTextfield* textfield = view_->TextfieldForType(type);
42 if (textfield)
43 return textfield->GetText();
45 views::Combobox* combobox = view_->ComboboxForType(type);
46 if (combobox)
47 return combobox->model()->GetItemAt(combobox->selected_index());
49 NOTREACHED();
50 return base::string16();
53 void AutofillDialogViewTesterViews::SetTextContentsOfInput(
54 ServerFieldType type,
55 const base::string16& contents) {
56 ExpandingTextfield* textfield = view_->TextfieldForType(type);
57 if (textfield) {
58 textfield->SetText(contents);
59 return;
62 views::Combobox* combobox = view_->ComboboxForType(type);
63 if (combobox) {
64 if (!combobox->SelectValue(contents))
65 combobox->SetSelectedIndex(combobox->model()->GetDefaultIndex());
66 return;
69 NOTREACHED();
72 void AutofillDialogViewTesterViews::SetTextContentsOfSuggestionInput(
73 DialogSection section,
74 const base::string16& text) {
75 view_->GroupForSection(section)->suggested_info->textfield()->SetText(text);
78 void AutofillDialogViewTesterViews::ActivateInput(ServerFieldType type) {
79 view_->InputEditedOrActivated(type, gfx::Rect(), false);
82 gfx::Size AutofillDialogViewTesterViews::GetSize() const {
83 return view_->GetWidget() ? view_->GetWidget()->GetRootView()->size() :
84 gfx::Size();
87 bool AutofillDialogViewTesterViews::IsShowingSection(DialogSection section)
88 const {
89 return view_->GroupForSection(section)->container->visible();
92 } // namespace autofill