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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc

Issue 15871004: Handle failed signin when setting kAutofillDialogPayWithoutWallet pref. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try to upload again Created 7 years, 7 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
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
Dan Beam 2013/05/31 22:39:13 just do this for now, i'll fix the order of GetWal
EXPECT_TRUE(profile()->GetPrefs()->HasPrefPath(
::prefs::kAutofillDialogPayWithoutWallet));
- EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(
+ EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(
::prefs::kAutofillDialogPayWithoutWallet));
}
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698