summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-30 07:58:11 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-30 07:58:11 +0000
commitd8497113ef014f0d82f69fcc318e1182b7e4acfb (patch)
tree16a18f03c4878d385978760092cde33c78858d57
parente03e8f960b1e353bb88bd2c403595dd145dab9b7 (diff)
downloadchromium_src-d8497113ef014f0d82f69fcc318e1182b7e4acfb.zip
chromium_src-d8497113ef014f0d82f69fcc318e1182b7e4acfb.tar.gz
chromium_src-d8497113ef014f0d82f69fcc318e1182b7e4acfb.tar.bz2
rAc: split TestableAutofillDialogView implementation into its own class
This: - makes use of a funky downcast - moves TestableAutofillDialogViews code out of the production binary - makes it impossible to accidentally call testing code from production code mac implementation by groby@chromium.org BUG=306200 Review URL: https://codereview.chromium.org/135933003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247886 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc70
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc4
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_impl.h5
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc3
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_view.cc2
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_view.h5
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_view_tester.h (renamed from chrome/browser/ui/autofill/testable_autofill_dialog_view.h)30
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h22
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm57
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_dialog_view_tester_cocoa.h48
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_dialog_view_tester_cocoa.mm135
-rw-r--r--chrome/browser/ui/views/autofill/autofill_dialog_view_tester_views.cc96
-rw-r--r--chrome/browser/ui/views/autofill/autofill_dialog_view_tester_views.h42
-rw-r--r--chrome/browser/ui/views/autofill/autofill_dialog_views.cc78
-rw-r--r--chrome/browser/ui/views/autofill/autofill_dialog_views.h19
-rw-r--r--chrome/chrome_tests.gypi5
16 files changed, 401 insertions, 220 deletions
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
index 2d57be8..3dfe808 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
@@ -17,10 +17,10 @@
#include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
#include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
#include "chrome/browser/ui/autofill/autofill_dialog_view.h"
+#include "chrome/browser/ui/autofill/autofill_dialog_view_tester.h"
#include "chrome/browser/ui/autofill/data_model_wrapper.h"
#include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h"
#include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controller.h"
-#include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -341,6 +341,10 @@ class AutofillDialogControllerTest : public InProcessBrowserTest {
return browser()->tab_strip_model()->GetActiveWebContents();
}
+ scoped_ptr<AutofillDialogViewTester> GetViewTester() {
+ return AutofillDialogViewTester::For(controller()->view()).Pass();
+ }
+
const MockAutofillMetrics& metric_logger() { return metric_logger_; }
TestAutofillDialogController* controller() { return controller_; }
@@ -497,7 +501,7 @@ class AutofillDialogControllerTest : public InProcessBrowserTest {
#if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX)
// Submit the form data.
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) {
- controller()->GetTestableView()->SubmitForTesting();
+ GetViewTester()->SubmitForTesting();
RunMessageLoop();
@@ -507,7 +511,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) {
// Cancel out of the dialog.
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Cancel) {
- controller()->GetTestableView()->CancelForTesting();
+ GetViewTester()->CancelForTesting();
RunMessageLoop();
@@ -548,7 +552,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, CloseDuringSignin) {
EXPECT_CALL(metric_logger(),
LogDialogDismissalState(
AutofillMetrics::DIALOG_CANCELED_DURING_SIGNIN));
- controller()->GetTestableView()->CancelForTesting();
+ GetViewTester()->CancelForTesting();
RunMessageLoop();
@@ -569,7 +573,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) {
controller()->RequestedFieldsForSection(SECTION_SHIPPING);
const ServerFieldType triggering_type = inputs[0].type;
base::string16 value = full_profile.GetRawInfo(triggering_type);
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
view->SetTextContentsOfInput(triggering_type,
value.substr(0, value.size() / 2));
view->ActivateInput(triggering_type);
@@ -633,7 +637,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
controller()->RequestedFieldsForSection(SECTION_SHIPPING);
const ServerFieldType triggering_type = inputs[0].type;
base::string16 value = full_profile.GetRawInfo(triggering_type);
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
view->SetTextContentsOfInput(triggering_type,
value.substr(0, value.size() / 2));
view->ActivateInput(triggering_type);
@@ -706,7 +710,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
controller()->RequestedFieldsForSection(SECTION_BILLING);
const ServerFieldType triggering_type = inputs[0].type;
EXPECT_EQ(NAME_BILLING_FULL, triggering_type);
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
view->ActivateInput(triggering_type);
ASSERT_EQ(triggering_type, controller()->popup_input_type());
@@ -752,7 +756,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
controller()->RequestedFieldsForSection(SECTION_CC);
const ServerFieldType triggering_type = inputs[0].type;
base::string16 value = card1.GetRawInfo(triggering_type);
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
view->SetTextContentsOfInput(triggering_type,
value.substr(0, value.size() / 2));
view->ActivateInput(triggering_type);
@@ -827,7 +831,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ShouldShowErrorBubble) {
ASSERT_FALSE(card.IsVerified());
controller()->GetTestingManager()->AddTestingCreditCard(&card);
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
view->SetTextContentsOfInput(
CREDIT_CARD_NUMBER,
card.GetRawInfo(CREDIT_CARD_NUMBER).substr(0, 1));
@@ -870,8 +874,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ExpiredCard) {
// Notifications with long message text should not make the dialog bigger.
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) {
- const gfx::Size no_notification_size =
- controller()->GetTestableView()->GetSize();
+ const gfx::Size no_notification_size = GetViewTester()->GetSize();
ASSERT_GT(no_notification_size.width(), 0);
std::vector<DialogNotification> notifications;
@@ -888,7 +891,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) {
controller()->view()->UpdateNotificationArea();
EXPECT_EQ(no_notification_size.width(),
- controller()->GetTestableView()->GetSize().width());
+ GetViewTester()->GetSize().width());
}
// http://crbug.com/318526
@@ -906,7 +909,9 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_AutocompleteEvent) {
AddAutofillProfileToProfile(controller->profile(),
test::GetVerifiedProfile());
- TestableAutofillDialogView* view = controller->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view =
+ AutofillDialogViewTester::For(
+ static_cast<TestAutofillDialogController*>(controller)->view());
view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123"));
view->SubmitForTesting();
ExpectDomMessage("success");
@@ -934,7 +939,9 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
AddAutofillProfileToProfile(controller->profile(),
test::GetVerifiedProfile());
- TestableAutofillDialogView* view = controller->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view =
+ AutofillDialogViewTester::For(
+ static_cast<TestAutofillDialogController*>(controller)->view());
view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123"));
view->SubmitForTesting();
ExpectDomMessage("error: invalid");
@@ -953,7 +960,9 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
AutofillDialogControllerImpl* controller =
SetUpHtmlAndInvoke("<input autocomplete='cc-name'>");
ASSERT_TRUE(controller);
- controller->GetTestableView()->CancelForTesting();
+ AutofillDialogViewTester::For(
+ static_cast<TestAutofillDialogController*>(controller)->view())->
+ CancelForTesting();
ExpectDomMessage("error: cancel");
}
@@ -964,8 +973,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) {
controller()->GetTestingManager()->AddTestingCreditCard(&credit_card);
EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC));
- ASSERT_NO_FATAL_FAILURE(
- controller()->GetTestableView()->SubmitForTesting());
+ ASSERT_NO_FATAL_FAILURE(GetViewTester()->SubmitForTesting());
}
// Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314.
@@ -977,7 +985,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) {
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_PreservedSections) {
controller()->set_use_validation(true);
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
view->SetTextContentsOfInput(CREDIT_CARD_NUMBER,
ASCIIToUTF16("4111111111111111"));
@@ -1021,7 +1029,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
wallet_items->instruments()[0]->TypeAndLastFourDigits();
controller()->OnDidGetWalletItems(wallet_items.Pass());
- TestableAutofillDialogView* test_view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> test_view = GetViewTester();
EXPECT_FALSE(test_view->IsShowingOverlay());
EXPECT_CALL(*controller(), LoadRiskFingerprintData());
controller()->OnAccept();
@@ -1085,7 +1093,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, SimulateSuccessfulSignIn) {
controller()->SignInLinkClicked();
EXPECT_TRUE(controller()->ShouldShowSignInWebView());
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
content::WebContents* sign_in_contents = view->GetSignInWebContents();
ASSERT_TRUE(sign_in_contents);
@@ -1150,7 +1158,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddAccount) {
account_chooser_model->GetItemCount() - 2);
EXPECT_TRUE(controller()->ShouldShowSignInWebView());
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
content::WebContents* sign_in_contents = view->GetSignInWebContents();
ASSERT_TRUE(sign_in_contents);
@@ -1211,7 +1219,9 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
AddAutofillProfileToProfile(controller->profile(),
test::GetVerifiedProfile());
- TestableAutofillDialogView* view = controller->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view =
+ AutofillDialogViewTester::For(
+ static_cast<TestAutofillDialogController*>(controller)->view());
view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123"));
view->SubmitForTesting();
ExpectDomMessage("success");
@@ -1238,7 +1248,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddNewClearsComboboxes) {
EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC));
// Get the contents of the combobox of the credit card's expiration month.
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
base::string16 cc_exp_month_text =
view->GetTextContentsOfInput(CREDIT_CARD_EXP_MONTH);
@@ -1308,8 +1318,8 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
controller()->SignInLinkClicked();
- TestableAutofillDialogView* view = controller()->GetTestableView();
- content::WebContents* sign_in_contents = view->GetSignInWebContents();
+ content::WebContents* sign_in_contents =
+ GetViewTester()->GetSignInWebContents();
ASSERT_TRUE(sign_in_contents);
sign_in_page_observer.Wait();
@@ -1465,7 +1475,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest,
controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1);
// Add some valid user input that should be preserved when country changes.
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
view->SetTextContentsOfInput(NAME_FULL, ASCIIToUTF16("B. Loblaw"));
// Change both sections' countries.
@@ -1504,7 +1514,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest,
controller()->MenuModelForSection(SECTION_CC_BILLING)->ActivatedAt(1);
controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2);
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
ASSERT_EQ(ASCIIToUTF16("United States"),
view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY));
ASSERT_EQ(ASCIIToUTF16("United States"),
@@ -1552,7 +1562,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest, AddNewResetsCountry) {
controller()->MenuModelForSection(SECTION_BILLING)->ActivatedAt(1);
controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2);
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
ASSERT_EQ(ASCIIToUTF16("United States"),
view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY));
ASSERT_EQ(ASCIIToUTF16("United States"),
@@ -1583,7 +1593,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest,
// Select "Add new shipping address...".
controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1);
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
ASSERT_EQ(ASCIIToUTF16("United States"),
view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY));
ASSERT_EQ(ASCIIToUTF16("United States"),
@@ -1610,7 +1620,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerI18nTest,
// Select "Add new shipping address...".
controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1);
- TestableAutofillDialogView* view = controller()->GetTestableView();
+ scoped_ptr<AutofillDialogViewTester> view = GetViewTester();
view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("France"));
view->ActivateInput(ADDRESS_BILLING_COUNTRY);
view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("Belarus"));
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
index 03c9f9f..4005cd6 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -646,10 +646,6 @@ void AutofillDialogControllerImpl::TabActivated() {
}
}
-TestableAutofillDialogView* AutofillDialogControllerImpl::GetTestableView() {
- return view_ ? view_->GetTestableView() : NULL;
-}
-
////////////////////////////////////////////////////////////////////////////////
// AutofillDialogViewDelegate implementation.
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h
index 23cc807..7b9a086 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h
@@ -54,7 +54,6 @@ class AutofillDataModel;
class AutofillDialogView;
class AutofillPopupControllerImpl;
class DataModelWrapper;
-class TestableAutofillDialogView;
namespace risk {
class Fingerprint;
@@ -91,10 +90,6 @@ class AutofillDialogControllerImpl : public AutofillDialogViewDelegate,
virtual void Hide() OVERRIDE;
virtual void TabActivated() OVERRIDE;
- // Returns |view_| as a testable version of itself (if |view_| exists and
- // actually implements |AutofillDialogView::GetTestableView()|).
- TestableAutofillDialogView* GetTestableView();
-
// AutofillDialogViewDelegate implementation.
virtual base::string16 DialogTitle() const OVERRIDE;
virtual base::string16 AccountChooserText() const OVERRIDE;
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
index 3632109..7a4bb23 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
@@ -186,9 +186,6 @@ class TestAutofillDialogView : public AutofillDialogView {
OVERRIDE {
*output = outputs_[section];
}
- virtual TestableAutofillDialogView* GetTestableView() OVERRIDE {
- return NULL;
- }
virtual base::string16 GetCvc() OVERRIDE { return base::string16(); }
virtual bool HitTestInput(ServerFieldType type,
diff --git a/chrome/browser/ui/autofill/autofill_dialog_view.cc b/chrome/browser/ui/autofill/autofill_dialog_view.cc
index 10024d2..7a738b7 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_view.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_view.cc
@@ -6,8 +6,6 @@
#include "chrome/browser/ui/autofill/autofill_dialog_view.h"
-#include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h"
-
namespace autofill {
AutofillDialogView::~AutofillDialogView() {}
diff --git a/chrome/browser/ui/autofill/autofill_dialog_view.h b/chrome/browser/ui/autofill/autofill_dialog_view.h
index d074769..764b0ba 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_view.h
+++ b/chrome/browser/ui/autofill/autofill_dialog_view.h
@@ -19,7 +19,6 @@ class Size;
namespace autofill {
class AutofillDialogViewDelegate;
-class TestableAutofillDialogView;
// An interface for the dialog that appears when a site initiates an Autofill
// action via the imperative autocomplete API.
@@ -98,10 +97,6 @@ class AutofillDialogView {
// Called when the active suggestions data model changed.
virtual void ModelChanged() = 0;
- // Returns an object that can be used to test that the view is behaving as
- // expected.
- virtual TestableAutofillDialogView* GetTestableView() = 0;
-
// Called by AutofillDialogSignInDelegate when the sign-in page experiences a
// resize. |pref_size| is the new preferred size of the sign-in page.
virtual void OnSignInResize(const gfx::Size& pref_size) = 0;
diff --git a/chrome/browser/ui/autofill/testable_autofill_dialog_view.h b/chrome/browser/ui/autofill/autofill_dialog_view_tester.h
index 13a23db..56cd42a 100644
--- a/chrome/browser/ui/autofill/testable_autofill_dialog_view.h
+++ b/chrome/browser/ui/autofill/autofill_dialog_view_tester.h
@@ -1,17 +1,31 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// 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.
-#ifndef CHROME_BROWSER_UI_AUTOFILL_TESTABLE_AUTOFILL_DIALOG_VIEW_H_
-#define CHROME_BROWSER_UI_AUTOFILL_TESTABLE_AUTOFILL_DIALOG_VIEW_H_
+#ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_VIEW_TESTER_H_
+#define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_VIEW_TESTER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/strings/string16.h"
+#include "chrome/browser/ui/autofill/autofill_dialog_types.h"
+#include "components/autofill/core/browser/field_types.h"
+#include "ui/gfx/size.h"
+
+namespace content {
+class WebContents;
+}
namespace autofill {
-// Functions that an AutofillDialogView implementation should implement in order
-// to assist in unit testing.
-class TestableAutofillDialogView {
+class AutofillDialogView;
+
+// Functionality that helps to test an AutofillDialogView.
+class AutofillDialogViewTester {
public:
- virtual ~TestableAutofillDialogView() {}
+ // Gets a AutofillDialogViewTester for |view|.
+ static scoped_ptr<AutofillDialogViewTester> For(AutofillDialogView* view);
+
+ virtual ~AutofillDialogViewTester() {}
// Simulates the user pressing 'Submit' to accept the dialog.
virtual void SubmitForTesting() = 0;
@@ -45,4 +59,4 @@ class TestableAutofillDialogView {
} // namespace autofill
-#endif // CHROME_BROWSER_UI_AUTOFILL_TESTABLE_AUTOFILL_DIALOG_VIEW_H_
+#endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_VIEW_TESTER_H_
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h
index 37119f9..30ffe73 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h
+++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h
@@ -10,7 +10,6 @@
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/autofill/autofill_dialog_types.h"
#include "chrome/browser/ui/autofill/autofill_dialog_view.h"
-#include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h"
#include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
#include "ui/gfx/size.h"
@@ -20,6 +19,7 @@ class NavigationController;
namespace autofill {
class AutofillDialogViewDelegate;
+class AutofillDialogViewTesterCocoa;
}
@class AutofillDialogWindowController;
@@ -27,7 +27,6 @@ class AutofillDialogViewDelegate;
namespace autofill {
class AutofillDialogCocoa : public AutofillDialogView,
- public TestableAutofillDialogView,
public ConstrainedWindowMacDelegate {
public:
explicit AutofillDialogCocoa(AutofillDialogViewDelegate* delegate);
@@ -57,25 +56,8 @@ class AutofillDialogCocoa : public AutofillDialogView,
virtual const content::NavigationController* ShowSignIn() OVERRIDE;
virtual void HideSignIn() OVERRIDE;
virtual void ModelChanged() OVERRIDE;
- virtual TestableAutofillDialogView* GetTestableView() OVERRIDE;
virtual void OnSignInResize(const gfx::Size& pref_size) OVERRIDE;
- // TestableAutofillDialogView implementation:
- // TODO(groby): Create a separate class to implement the testable interface:
- // http://crbug.com/256864
- virtual void SubmitForTesting() OVERRIDE;
- virtual void CancelForTesting() OVERRIDE;
- virtual base::string16 GetTextContentsOfInput(ServerFieldType type) OVERRIDE;
- virtual void SetTextContentsOfInput(ServerFieldType type,
- const base::string16& contents) OVERRIDE;
- virtual void SetTextContentsOfSuggestionInput(
- DialogSection section,
- const base::string16& text) OVERRIDE;
- virtual void ActivateInput(ServerFieldType type) OVERRIDE;
- virtual gfx::Size GetSize() const OVERRIDE;
- virtual content::WebContents* GetSignInWebContents() OVERRIDE;
- virtual bool IsShowingOverlay() const OVERRIDE;
-
// ConstrainedWindowMacDelegate implementation:
virtual void OnConstrainedWindowClosed(
ConstrainedWindowMac* window) OVERRIDE;
@@ -86,6 +68,8 @@ class AutofillDialogCocoa : public AutofillDialogView,
void PerformClose();
private:
+ friend class AutofillDialogViewTesterCocoa;
+
// Closes the sheet and ends the modal loop. Triggers cleanup sequence.
void CloseNow();
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm
index f07d4c8..e559f45 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm
@@ -134,68 +134,11 @@ void AutofillDialogCocoa::UpdateErrorBubble() {
[sheet_delegate_ updateErrorBubble];
}
-TestableAutofillDialogView* AutofillDialogCocoa::GetTestableView() {
- return this;
-}
-
void AutofillDialogCocoa::OnSignInResize(const gfx::Size& pref_size) {
[sheet_delegate_ onSignInResize:
NSMakeSize(pref_size.width(), pref_size.height())];
}
-void AutofillDialogCocoa::SubmitForTesting() {
- [sheet_delegate_ accept:nil];
-}
-
-void AutofillDialogCocoa::CancelForTesting() {
- [sheet_delegate_ cancel:nil];
-}
-
-base::string16 AutofillDialogCocoa::GetTextContentsOfInput(
- ServerFieldType type) {
- for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) {
- DialogSection section = static_cast<DialogSection>(i);
- FieldValueMap contents;
- [sheet_delegate_ getInputs:&contents forSection:section];
- FieldValueMap::const_iterator it = contents.find(type);
- if (it != contents.end())
- return it->second;
- }
-
- NOTREACHED();
- return base::string16();
-}
-
-void AutofillDialogCocoa::SetTextContentsOfInput(
- ServerFieldType type,
- const base::string16& contents) {
- [sheet_delegate_ setTextContents:base::SysUTF16ToNSString(contents)
- forType:type];
-}
-
-void AutofillDialogCocoa::SetTextContentsOfSuggestionInput(
- DialogSection section,
- const base::string16& text) {
- [sheet_delegate_ setTextContents:base::SysUTF16ToNSString(text)
- ofSuggestionForSection:section];
-}
-
-void AutofillDialogCocoa::ActivateInput(ServerFieldType type) {
- [sheet_delegate_ activateFieldForType:type];
-}
-
-gfx::Size AutofillDialogCocoa::GetSize() const {
- return gfx::Size(NSSizeToCGSize([[sheet_delegate_ window] frame].size));
-}
-
-content::WebContents* AutofillDialogCocoa::GetSignInWebContents() {
- return [sheet_delegate_ getSignInWebContents];
-}
-
-
-bool AutofillDialogCocoa::IsShowingOverlay() const {
- return [sheet_delegate_ isShowingOverlay];
-}
void AutofillDialogCocoa::OnConstrainedWindowClosed(
ConstrainedWindowMac* window) {
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_view_tester_cocoa.h b/chrome/browser/ui/cocoa/autofill/autofill_dialog_view_tester_cocoa.h
new file mode 100644
index 0000000..697a41a
--- /dev/null
+++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_view_tester_cocoa.h
@@ -0,0 +1,48 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_VIEW_TESTER_COCOA_H_
+#define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_VIEW_TESTER_COCOA_H_
+
+#include "base/basictypes.h"
+#include "chrome/browser/ui/autofill/autofill_dialog_view_tester.h"
+
+@class AutofillDialogWindowController;
+
+namespace autofill {
+
+class AutofillDialogCocoa;
+
+class AutofillDialogViewTesterCocoa: public AutofillDialogViewTester {
+ public:
+ explicit AutofillDialogViewTesterCocoa(AutofillDialogCocoa* dialog);
+ virtual ~AutofillDialogViewTesterCocoa();
+
+ // TestableAutofillDialogView implementation:
+ virtual void SubmitForTesting() OVERRIDE;
+ virtual void CancelForTesting() OVERRIDE;
+ virtual base::string16 GetTextContentsOfInput(ServerFieldType type) OVERRIDE;
+ virtual void SetTextContentsOfInput(ServerFieldType type,
+ const base::string16& contents) OVERRIDE;
+ virtual void SetTextContentsOfSuggestionInput(
+ DialogSection section,
+ const base::string16& text) OVERRIDE;
+ virtual void ActivateInput(ServerFieldType type) OVERRIDE;
+ virtual gfx::Size GetSize() const OVERRIDE;
+ virtual content::WebContents* GetSignInWebContents() OVERRIDE;
+ virtual bool IsShowingOverlay() const OVERRIDE;
+
+ private:
+ AutofillDialogWindowController* controller() const;
+
+ AutofillDialogCocoa* dialog_;
+
+ DISALLOW_COPY_AND_ASSIGN(AutofillDialogViewTesterCocoa);
+};
+
+
+} // autofill
+
+#endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_VIEW_TESTER_COCOA_H_
+
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_view_tester_cocoa.mm b/chrome/browser/ui/cocoa/autofill/autofill_dialog_view_tester_cocoa.mm
new file mode 100644
index 0000000..2e55fe2
--- /dev/null
+++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_view_tester_cocoa.mm
@@ -0,0 +1,135 @@
+// 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/cocoa/autofill/autofill_dialog_view_tester_cocoa.h"
+
+#include "base/strings/sys_string_conversions.h"
+#include "chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h"
+#import "chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.h"
+#import "chrome/browser/ui/cocoa/autofill/autofill_main_container.h"
+#import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h"
+#import "chrome/browser/ui/cocoa/autofill/autofill_sign_in_container.h"
+
+
+// Mirrors the AutofillDialogViewTester API on the C++ side.
+@interface AutofillDialogWindowController (AutofillDialogViewTesterCocoa)
+
+- (void)setTextContents:(NSString*)text
+ forType:(autofill::ServerFieldType)type;
+- (void)setTextContents:(NSString*)text
+ ofSuggestionForSection:(autofill::DialogSection)section;
+- (void)activateFieldForType:(autofill::ServerFieldType)type;
+- (content::WebContents*)getSignInWebContents;
+- (BOOL)isShowingOverlay;
+
+@end
+
+
+@implementation AutofillDialogWindowController (AutofillDialogViewTesterCocoa)
+
+- (void)setTextContents:(NSString*)text
+ forType:(autofill::ServerFieldType)type {
+ for (size_t i = autofill::SECTION_MIN; i <= autofill::SECTION_MAX; ++i) {
+ autofill::DialogSection section = static_cast<autofill::DialogSection>(i);
+ // TODO(groby): Need to find the section for an input directly - wasteful.
+ [[mainContainer_ sectionForId:section] setFieldValue:text forType:type];
+ }
+}
+
+- (void)setTextContents:(NSString*)text
+ ofSuggestionForSection:(autofill::DialogSection)section {
+ [[mainContainer_ sectionForId:section] setSuggestionFieldValue:text];
+}
+
+- (void)activateFieldForType:(autofill::ServerFieldType)type {
+ for (size_t i = autofill::SECTION_MIN; i <= autofill::SECTION_MAX; ++i) {
+ autofill::DialogSection section = static_cast<autofill::DialogSection>(i);
+ [[mainContainer_ sectionForId:section] activateFieldForType:type];
+ }
+}
+
+- (content::WebContents*)getSignInWebContents {
+ return [signInContainer_ webContents];
+}
+
+- (BOOL)isShowingOverlay {
+ return ![[overlayController_ view] isHidden];
+}
+
+@end
+
+namespace autofill {
+
+scoped_ptr<AutofillDialogViewTester> AutofillDialogViewTester::For(
+ AutofillDialogView* dialog) {
+ return scoped_ptr<AutofillDialogViewTester>(
+ new AutofillDialogViewTesterCocoa(
+ static_cast<AutofillDialogCocoa*>(dialog)));
+}
+
+AutofillDialogViewTesterCocoa::AutofillDialogViewTesterCocoa(
+ AutofillDialogCocoa* dialog)
+ : dialog_(dialog) {}
+
+AutofillDialogViewTesterCocoa::~AutofillDialogViewTesterCocoa() {}
+
+void AutofillDialogViewTesterCocoa::SubmitForTesting() {
+ [controller() accept:nil];
+}
+
+void AutofillDialogViewTesterCocoa::CancelForTesting() {
+ [controller() cancel:nil];
+}
+
+base::string16 AutofillDialogViewTesterCocoa::GetTextContentsOfInput(
+ ServerFieldType type) {
+ for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) {
+ DialogSection section = static_cast<DialogSection>(i);
+ FieldValueMap contents;
+ [controller() getInputs:&contents forSection:section];
+ FieldValueMap::const_iterator it = contents.find(type);
+ if (it != contents.end())
+ return it->second;
+ }
+
+ NOTREACHED();
+ return base::string16();
+}
+
+void AutofillDialogViewTesterCocoa::SetTextContentsOfInput(
+ ServerFieldType type,
+ const base::string16& contents) {
+ [controller() setTextContents:base::SysUTF16ToNSString(contents)
+ forType:type];
+}
+
+void AutofillDialogViewTesterCocoa::SetTextContentsOfSuggestionInput(
+ DialogSection section,
+ const base::string16& text) {
+ [controller() setTextContents:base::SysUTF16ToNSString(text)
+ ofSuggestionForSection:section];
+}
+
+void AutofillDialogViewTesterCocoa::ActivateInput(ServerFieldType type) {
+ [controller() activateFieldForType:type];
+}
+
+gfx::Size AutofillDialogViewTesterCocoa::GetSize() const {
+ return gfx::Size(NSSizeToCGSize([[controller() window] frame].size));
+}
+
+content::WebContents* AutofillDialogViewTesterCocoa::GetSignInWebContents() {
+ return [controller() getSignInWebContents];
+}
+
+bool AutofillDialogViewTesterCocoa::IsShowingOverlay() const {
+ return [controller() isShowingOverlay];
+}
+
+AutofillDialogWindowController*
+ AutofillDialogViewTesterCocoa::controller() const {
+ return dialog_->sheet_delegate_;
+}
+
+} // namespace autofill
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 0000000..bac6ac5
--- /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
diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_view_tester_views.h b/chrome/browser/ui/views/autofill/autofill_dialog_view_tester_views.h
new file mode 100644
index 0000000..ac1bc5d
--- /dev/null
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_view_tester_views.h
@@ -0,0 +1,42 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEW_TESTER_VIEWS_H_
+#define CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEW_TESTER_VIEWS_H_
+
+#include "base/basictypes.h"
+#include "chrome/browser/ui/autofill/autofill_dialog_view_tester.h"
+
+namespace autofill {
+
+class AutofillDialogViews;
+
+class AutofillDialogViewTesterViews : public AutofillDialogViewTester {
+ public:
+ explicit AutofillDialogViewTesterViews(AutofillDialogViews* view);
+ virtual ~AutofillDialogViewTesterViews();
+
+ // TestableAutofillDialogView implementation:
+ virtual void SubmitForTesting() OVERRIDE;
+ virtual void CancelForTesting() OVERRIDE;
+ virtual base::string16 GetTextContentsOfInput(ServerFieldType type) OVERRIDE;
+ virtual void SetTextContentsOfInput(ServerFieldType type,
+ const base::string16& contents) OVERRIDE;
+ virtual void SetTextContentsOfSuggestionInput(
+ DialogSection section,
+ const base::string16& text) OVERRIDE;
+ virtual void ActivateInput(ServerFieldType type) OVERRIDE;
+ virtual gfx::Size GetSize() const OVERRIDE;
+ virtual content::WebContents* GetSignInWebContents() OVERRIDE;
+ virtual bool IsShowingOverlay() const OVERRIDE;
+
+ private:
+ AutofillDialogViews* view_;
+
+ DISALLOW_COPY_AND_ASSIGN(AutofillDialogViewTesterViews);
+};
+
+} // namespace autofill
+
+#endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_AUTOFILL_DIALOG_VIEW_TESTER_VIEWS_H_
diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
index cf629d5..9ff9ffd 100644
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
@@ -1441,78 +1441,11 @@ void AutofillDialogViews::ModelChanged() {
}
}
-TestableAutofillDialogView* AutofillDialogViews::GetTestableView() {
- return this;
-}
-
void AutofillDialogViews::OnSignInResize(const gfx::Size& pref_size) {
sign_in_web_view_->SetPreferredSize(pref_size);
ContentsPreferredSizeChanged();
}
-void AutofillDialogViews::SubmitForTesting() {
- Accept();
-}
-
-void AutofillDialogViews::CancelForTesting() {
- GetDialogClientView()->CancelWindow();
-}
-
-base::string16 AutofillDialogViews::GetTextContentsOfInput(
- ServerFieldType type) {
- views::Textfield* textfield = TextfieldForType(type);
- if (textfield)
- return textfield->text();
-
- views::Combobox* combobox = ComboboxForType(type);
- if (combobox)
- return combobox->model()->GetItemAt(combobox->selected_index());
-
- NOTREACHED();
- return base::string16();
-}
-
-void AutofillDialogViews::SetTextContentsOfInput(
- ServerFieldType type,
- const base::string16& contents) {
- views::Textfield* textfield = TextfieldForType(type);
- if (textfield) {
- textfield->SetText(contents);
- return;
- }
-
- views::Combobox* combobox = ComboboxForType(type);
- if (combobox) {
- SelectComboboxValueOrSetToDefault(combobox, contents);
- return;
- }
-
- NOTREACHED();
-}
-
-void AutofillDialogViews::SetTextContentsOfSuggestionInput(
- DialogSection section,
- const base::string16& text) {
- GroupForSection(section)->suggested_info->decorated_textfield()->
- SetText(text);
-}
-
-void AutofillDialogViews::ActivateInput(ServerFieldType type) {
- InputEditedOrActivated(type, gfx::Rect(), false);
-}
-
-gfx::Size AutofillDialogViews::GetSize() const {
- return GetWidget() ? GetWidget()->GetRootView()->size() : gfx::Size();
-}
-
-content::WebContents* AutofillDialogViews::GetSignInWebContents() {
- return sign_in_web_view_->web_contents();
-}
-
-bool AutofillDialogViews::IsShowingOverlay() const {
- return overlay_view_->visible();
-}
-
gfx::Size AutofillDialogViews::GetPreferredSize() {
if (preferred_size_.IsEmpty())
preferred_size_ = CalculatePreferredSize(false);
@@ -2284,15 +2217,20 @@ void AutofillDialogViews::InputEditedOrActivated(ServerFieldType type,
DCHECK_NE(UNKNOWN_TYPE, type);
DecoratedTextfield* decorated = TextfieldForType(type);
- DetailsGroup* group = decorated ?
- GroupForView(decorated) : GroupForView(ComboboxForType(type));
+ views::Combobox* combobox = ComboboxForType(type);
+ DCHECK_NE(!!combobox, !!decorated);
+ DetailsGroup* group = decorated ? GroupForView(decorated) :
+ GroupForView(combobox);
+ base::string16 text = decorated ?
+ decorated->text() :
+ combobox->model()->GetItemAt(combobox->selected_index());
DCHECK(group);
delegate_->UserEditedOrActivatedInput(group->section,
type,
GetWidget()->GetNativeView(),
bounds,
- GetTextContentsOfInput(type),
+ text,
was_edit);
// If the field is a textfield and is invalid, check if the text is now valid.
diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.h b/chrome/browser/ui/views/autofill/autofill_dialog_views.h
index 5d7b580..e1d7b18 100644
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views.h
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.h
@@ -14,7 +14,6 @@
#include "chrome/browser/ui/autofill/autofill_dialog_types.h"
#include "chrome/browser/ui/autofill/autofill_dialog_view.h"
#include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h"
-#include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/button/menu_button_listener.h"
@@ -61,7 +60,6 @@ class InfoBubble;
// Views toolkit implementation of the Autofill dialog that handles the
// imperative autocomplete API call.
class AutofillDialogViews : public AutofillDialogView,
- public TestableAutofillDialogView,
public views::DialogDelegateView,
public views::WidgetObserver,
public views::TextfieldController,
@@ -97,23 +95,8 @@ class AutofillDialogViews : public AutofillDialogView,
virtual const content::NavigationController* ShowSignIn() OVERRIDE;
virtual void HideSignIn() OVERRIDE;
virtual void ModelChanged() OVERRIDE;
- virtual TestableAutofillDialogView* GetTestableView() OVERRIDE;
virtual void OnSignInResize(const gfx::Size& pref_size) OVERRIDE;
- // TestableAutofillDialogView implementation:
- virtual void SubmitForTesting() OVERRIDE;
- virtual void CancelForTesting() OVERRIDE;
- virtual base::string16 GetTextContentsOfInput(ServerFieldType type) OVERRIDE;
- virtual void SetTextContentsOfInput(ServerFieldType type,
- const base::string16& contents) OVERRIDE;
- virtual void SetTextContentsOfSuggestionInput(
- DialogSection section,
- const base::string16& text) OVERRIDE;
- virtual void ActivateInput(ServerFieldType type) OVERRIDE;
- virtual gfx::Size GetSize() const OVERRIDE;
- virtual content::WebContents* GetSignInWebContents() OVERRIDE;
- virtual bool IsShowingOverlay() const OVERRIDE;
-
// views::View implementation.
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual gfx::Size GetMinimumSize() OVERRIDE;
@@ -178,6 +161,8 @@ class AutofillDialogViews : public AutofillDialogView,
views::View* GetScrollableAreaForTesting();
private:
+ friend class AutofillDialogViewTesterViews;
+
// What the entire dialog should be doing (e.g. gathering info from the user,
// asking the user to sign in, etc.).
enum DialogMode {
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 710dd1a..50eef15 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1410,6 +1410,7 @@
'browser/ui/autofill/test_generated_credit_card_bubble_view.h',
'browser/ui/autofill/test_generated_credit_card_bubble_controller.cc',
'browser/ui/autofill/test_generated_credit_card_bubble_controller.h',
+ 'browser/ui/autofill/autofill_dialog_view_tester.h',
'browser/ui/blocked_content/popup_blocker_browsertest.cc',
'browser/ui/bookmarks/bookmark_browsertest.cc',
'browser/ui/browser_browsertest.cc',
@@ -1423,6 +1424,8 @@
'browser/ui/cocoa/apps/app_shim_menu_controller_mac_browsertest.mm',
'browser/ui/cocoa/apps/native_app_window_cocoa_browsertest.mm',
'browser/ui/cocoa/autofill/autofill_dialog_cocoa_browsertest.mm',
+ 'browser/ui/cocoa/autofill/autofill_dialog_view_tester_cocoa.mm',
+ 'browser/ui/cocoa/autofill/autofill_dialog_view_tester_cocoa.h',
'browser/ui/cocoa/browser_window_cocoa_browsertest.mm',
'browser/ui/cocoa/browser_window_controller_browsertest.mm',
'browser/ui/cocoa/certificate_viewer_mac_browsertest.mm',
@@ -1464,6 +1467,8 @@
'browser/ui/toolbar/test_toolbar_model.cc',
'browser/ui/toolbar/test_toolbar_model.h',
'browser/ui/views/avatar_menu_button_browsertest.cc',
+ 'browser/ui/views/autofill/autofill_dialog_view_tester_views.cc',
+ 'browser/ui/views/autofill/autofill_dialog_view_tester_views.h',
'browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc',
'browser/ui/views/frame/browser_view_browsertest.cc',
'browser/ui/views/frame/browser_window_property_manager_browsertest_win.cc',