| Index: chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
|
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
|
| index 7bc71593b892413d6e20e2c23696ec81283a8d7c..39bb5ee4a7de1a3daca47d46d2fc49310eef34a3 100644
|
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
|
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
|
| @@ -248,6 +248,10 @@ class TestAutofillDialogController
|
| MOCK_METHOD0(LoadRiskFingerprintData, void());
|
| using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData;
|
|
|
| + void SimulateSigninError() {
|
| + OnWalletSigninError();
|
| + }
|
| +
|
| protected:
|
| virtual PersonalDataManager* GetManager() OVERRIDE {
|
| return &test_manager_;
|
| @@ -297,18 +301,11 @@ class AutofillDialogControllerTest : public testing::Test {
|
|
|
| // testing::Test implementation:
|
| virtual void SetUp() OVERRIDE {
|
| - FormData form_data;
|
| - for (size_t i = 0; i < arraysize(kFieldsFromPage); ++i) {
|
| - FormFieldData field;
|
| - field.autocomplete_attribute = kFieldsFromPage[i];
|
| - form_data.fields.push_back(field);
|
| - }
|
| -
|
| profile()->CreateRequestContext();
|
| test_web_contents_.reset(
|
| content::WebContentsTester::CreateTestWebContents(profile(), NULL));
|
|
|
| - SetUpControllerWithFormData(form_data);
|
| + SetUpControllerWithFormData(DefaultFormData());
|
| }
|
|
|
| virtual void TearDown() OVERRIDE {
|
| @@ -317,6 +314,16 @@ class AutofillDialogControllerTest : public testing::Test {
|
| }
|
|
|
| protected:
|
| + FormData DefaultFormData() {
|
| + FormData form_data;
|
| + for (size_t i = 0; i < arraysize(kFieldsFromPage); ++i) {
|
| + FormFieldData field;
|
| + field.autocomplete_attribute = kFieldsFromPage[i];
|
| + form_data.fields.push_back(field);
|
| + }
|
| + return form_data;
|
| + }
|
| +
|
| void SetUpControllerWithFormData(const FormData& form_data) {
|
| if (controller_)
|
| controller_->ViewClosed();
|
| @@ -368,6 +375,10 @@ class AutofillDialogControllerTest : public testing::Test {
|
| TestAccountChooserModel::kActiveWalletItemId);
|
| }
|
|
|
| + void SimulateSigninError() {
|
| + controller_->SimulateSigninError();
|
| + }
|
| +
|
| void UseBillingForShipping() {
|
| controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(0);
|
| }
|
| @@ -1637,20 +1648,61 @@ TEST_F(AutofillDialogControllerTest, ViewCancelDoesntSetPref) {
|
| ::prefs::kAutofillDialogPayWithoutWallet));
|
| }
|
|
|
| +TEST_F(AutofillDialogControllerTest, SubmitWithSigninErrorDoesntSetPref) {
|
| + ASSERT_FALSE(profile()->GetPrefs()->HasPrefPath(
|
| + ::prefs::kAutofillDialogPayWithoutWallet));
|
| +
|
| + SimulateSigninError();
|
| + FillCreditCardInputs();
|
| + controller()->OnAccept();
|
| +
|
| + EXPECT_FALSE(profile()->GetPrefs()->HasPrefPath(
|
| + ::prefs::kAutofillDialogPayWithoutWallet));
|
| +}
|
| +
|
| TEST_F(AutofillDialogControllerTest, ViewSubmitSetsPref) {
|
| ASSERT_FALSE(profile()->GetPrefs()->HasPrefPath(
|
| ::prefs::kAutofillDialogPayWithoutWallet));
|
|
|
| SwitchToAutofill();
|
| + FillCreditCardInputs();
|
| + controller()->OnAccept();
|
|
|
| - // We also have to simulate CC inputs to keep the controller happy.
|
| + EXPECT_TRUE(profile()->GetPrefs()->HasPrefPath(
|
| + ::prefs::kAutofillDialogPayWithoutWallet));
|
| + EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(
|
| + ::prefs::kAutofillDialogPayWithoutWallet));
|
| +
|
| + // Try again with a signin error (just leaves the pref alone).
|
| + SetUpControllerWithFormData(DefaultFormData());
|
| +
|
| + // Setting up the controller again should not change the pref.
|
| + EXPECT_TRUE(profile()->GetPrefs()->HasPrefPath(
|
| + ::prefs::kAutofillDialogPayWithoutWallet));
|
| + EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(
|
| + ::prefs::kAutofillDialogPayWithoutWallet));
|
| +
|
| + SimulateSigninError();
|
| FillCreditCardInputs();
|
| + controller()->OnAccept();
|
| + EXPECT_TRUE(profile()->GetPrefs()->HasPrefPath(
|
| + ::prefs::kAutofillDialogPayWithoutWallet));
|
| + EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(
|
| + ::prefs::kAutofillDialogPayWithoutWallet));
|
| +
|
| + // Succesfully choosing wallet does set the pref.
|
| + SetUpControllerWithFormData(DefaultFormData());
|
|
|
| + SwitchToWallet();
|
| + scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
|
| + wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
|
| + controller()->OnDidGetWalletItems(wallet_items.Pass());
|
| controller()->OnAccept();
|
| + controller()->OnDidGetFullWallet(wallet::GetTestFullWallet());
|
|
|
| EXPECT_TRUE(profile()->GetPrefs()->HasPrefPath(
|
| ::prefs::kAutofillDialogPayWithoutWallet));
|
| - EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(
|
| + EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(
|
| ::prefs::kAutofillDialogPayWithoutWallet));
|
| }
|
|
|
|
|