Chromium Code Reviews| Index: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc |
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc |
| index 8036aeb61156221ba693d3aea2d976af47412616..319250e3a1f748cbe832e044d0f4d8f71a28a6ea 100644 |
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc |
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc |
| @@ -16,10 +16,10 @@ |
| #include "chrome/browser/ui/autofill/account_chooser_model.h" |
| #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.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" |
| @@ -337,6 +337,10 @@ class AutofillDialogControllerTest : public InProcessBrowserTest { |
| return browser()->tab_strip_model()->GetActiveWebContents(); |
| } |
| + scoped_ptr<AutofillDialogViewTester> GetViewTester() { |
| + return AutofillDialogViewTester::Wrap(controller()->view()).Pass(); |
| + } |
| + |
| const MockAutofillMetrics& metric_logger() { return metric_logger_; } |
| TestAutofillDialogController* controller() { return controller_; } |
| @@ -493,7 +497,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(); |
| @@ -503,7 +507,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(); |
| @@ -544,7 +548,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, CloseDuringSignin) { |
| EXPECT_CALL(metric_logger(), |
| LogDialogDismissalState( |
| AutofillMetrics::DIALOG_CANCELED_DURING_SIGNIN)); |
| - controller()->GetTestableView()->CancelForTesting(); |
| + GetViewTester()->CancelForTesting(); |
| RunMessageLoop(); |
| @@ -560,7 +564,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); |
| @@ -613,7 +617,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); |
| @@ -680,7 +684,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()); |
| @@ -726,7 +730,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); |
| @@ -801,7 +805,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)); |
| @@ -845,7 +849,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(); |
| + GetViewTester()->GetSize(); |
|
Dan Beam
2014/01/24 23:37:40
unwrap everything that's now short enough to fit i
Evan Stade
2014/01/27 21:08:35
Done.
|
| ASSERT_GT(no_notification_size.width(), 0); |
| std::vector<DialogNotification> notifications; |
| @@ -862,7 +866,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 |
| @@ -880,7 +884,9 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_AutocompleteEvent) { |
| AddAutofillProfileToProfile(controller->profile(), |
| test::GetVerifiedProfile()); |
| - TestableAutofillDialogView* view = controller->GetTestableView(); |
| + scoped_ptr<AutofillDialogViewTester> view = |
| + AutofillDialogViewTester::Wrap( |
| + static_cast<TestAutofillDialogController*>(controller)->view()); |
|
Dan Beam
2014/01/24 23:37:40
i don't think this is a valid cast (I don't think
Evan Stade
2014/01/27 21:08:35
yet the code compiles and runs successfully
|
| view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
| view->SubmitForTesting(); |
| ExpectDomMessage("success"); |
| @@ -908,7 +914,9 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
| AddAutofillProfileToProfile(controller->profile(), |
| test::GetVerifiedProfile()); |
| - TestableAutofillDialogView* view = controller->GetTestableView(); |
| + scoped_ptr<AutofillDialogViewTester> view = |
| + AutofillDialogViewTester::Wrap( |
| + static_cast<TestAutofillDialogController*>(controller)->view()); |
| view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
| view->SubmitForTesting(); |
| ExpectDomMessage("error: invalid"); |
| @@ -927,7 +935,9 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
| AutofillDialogControllerImpl* controller = |
| SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); |
| ASSERT_TRUE(controller); |
| - controller->GetTestableView()->CancelForTesting(); |
| + AutofillDialogViewTester::Wrap( |
| + static_cast<TestAutofillDialogController*>(controller)->view())-> |
| + CancelForTesting(); |
| ExpectDomMessage("error: cancel"); |
| } |
| @@ -939,7 +949,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, NoCvcSegfault) { |
| EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); |
| ASSERT_NO_FATAL_FAILURE( |
| - controller()->GetTestableView()->SubmitForTesting()); |
| + GetViewTester()->SubmitForTesting()); |
| } |
| // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314. |
| @@ -951,7 +961,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")); |
| @@ -995,7 +1005,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(); |
| @@ -1059,7 +1069,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); |
| @@ -1125,7 +1135,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); |
| @@ -1186,7 +1196,9 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
| AddAutofillProfileToProfile(controller->profile(), |
| test::GetVerifiedProfile()); |
| - TestableAutofillDialogView* view = controller->GetTestableView(); |
| + scoped_ptr<AutofillDialogViewTester> view = |
| + AutofillDialogViewTester::Wrap( |
| + static_cast<TestAutofillDialogController*>(controller)->view()); |
| view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
| view->SubmitForTesting(); |
| ExpectDomMessage("success"); |
| @@ -1213,7 +1225,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); |
| @@ -1283,8 +1295,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(); |