Chromium Code Reviews| Index: chrome/browser/ui/views/autofill/autofill_dialog_view_tester_views.cc |
| diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_view_tester_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_view_tester_views.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bac6ac5729af18d238135a9e466b5e37a5834137 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/autofill/autofill_dialog_view_tester_views.cc |
| @@ -0,0 +1,96 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/views/autofill/autofill_dialog_view_tester_views.h" |
| + |
| +#include "base/logging.h" |
| +#include "chrome/browser/ui/views/autofill/autofill_dialog_views.h" |
| +#include "chrome/browser/ui/views/autofill/decorated_textfield.h" |
| +#include "ui/base/models/combobox_model.h" |
| +#include "ui/views/controls/combobox/combobox.h" |
| +#include "ui/views/controls/textfield/textfield.h" |
| +#include "ui/views/controls/webview/webview.h" |
| +#include "ui/views/widget/widget.h" |
| +#include "ui/views/window/dialog_client_view.h" |
| + |
| +namespace autofill { |
| + |
| +scoped_ptr<AutofillDialogViewTester> AutofillDialogViewTester::For( |
| + AutofillDialogView* view) { |
| + return scoped_ptr<AutofillDialogViewTester>(new |
|
Dan Beam
2014/01/28 18:04:48
nit: a dangling new is odd looking to me
Evan Stade
2014/01/28 18:45:26
better than an extra line imo
|
| + AutofillDialogViewTesterViews(static_cast<AutofillDialogViews*>(view))); |
| +} |
| + |
| +AutofillDialogViewTesterViews::AutofillDialogViewTesterViews( |
| + AutofillDialogViews* view) |
| + : view_(view) {} |
| + |
| +AutofillDialogViewTesterViews::~AutofillDialogViewTesterViews() {} |
| + |
| +void AutofillDialogViewTesterViews::SubmitForTesting() { |
| + view_->Accept(); |
| +} |
| + |
| +void AutofillDialogViewTesterViews::CancelForTesting() { |
| + view_->GetDialogClientView()->CancelWindow(); |
| +} |
| + |
| +base::string16 AutofillDialogViewTesterViews::GetTextContentsOfInput( |
| + ServerFieldType type) { |
| + views::Textfield* textfield = view_->TextfieldForType(type); |
| + if (textfield) |
| + return textfield->text(); |
| + |
| + views::Combobox* combobox = view_->ComboboxForType(type); |
| + if (combobox) |
| + return combobox->model()->GetItemAt(combobox->selected_index()); |
| + |
| + NOTREACHED(); |
| + return base::string16(); |
| +} |
| + |
| +void AutofillDialogViewTesterViews::SetTextContentsOfInput( |
| + ServerFieldType type, |
| + const base::string16& contents) { |
| + views::Textfield* textfield = view_->TextfieldForType(type); |
| + if (textfield) { |
| + textfield->SetText(contents); |
| + return; |
| + } |
| + |
| + views::Combobox* combobox = view_->ComboboxForType(type); |
| + if (combobox) { |
| + if (!combobox->SelectValue(contents)) |
| + combobox->SetSelectedIndex(combobox->model()->GetDefaultIndex()); |
| + return; |
| + } |
| + |
| + NOTREACHED(); |
| +} |
| + |
| +void AutofillDialogViewTesterViews::SetTextContentsOfSuggestionInput( |
| + DialogSection section, |
| + const base::string16& text) { |
| + view_->GroupForSection(section)->suggested_info->decorated_textfield()-> |
| + SetText(text); |
| +} |
| + |
| +void AutofillDialogViewTesterViews::ActivateInput(ServerFieldType type) { |
| + view_->InputEditedOrActivated(type, gfx::Rect(), false); |
| +} |
| + |
| +gfx::Size AutofillDialogViewTesterViews::GetSize() const { |
| + return view_->GetWidget() ? view_->GetWidget()->GetRootView()->size() : |
| + gfx::Size(); |
| +} |
| + |
| +content::WebContents* AutofillDialogViewTesterViews::GetSignInWebContents() { |
| + return view_->sign_in_web_view_->web_contents(); |
| +} |
| + |
| +bool AutofillDialogViewTesterViews::IsShowingOverlay() const { |
| + return view_->overlay_view_->visible(); |
| +} |
| + |
| +} // namespace autofill |