Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: chrome/browser/ui/views/autofill/autofill_dialog_view_tester_views.cc

Issue 135933003: rAc: split TestableAutofillDialogView implementation into its own class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: with mac nits fixed Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
+ 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

Powered by Google App Engine
This is Rietveld 408576698