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

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

Issue 15500008: Persist the choice of AutofillDataModel when using the requestAutocomplete dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better comment 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
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 ba836b06cf3203df1ae9509c05504ddd34920f30..610c041ef0e3b1a4ccc142b64f5dcdeb6252cb03 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
@@ -425,6 +425,38 @@ TEST_F(AutofillDialogControllerTest, AutofillProfiles) {
EXPECT_TRUE(!!controller()->MenuModelForSection(SECTION_EMAIL));
}
+// Makes sure that the choice of which Autofill profile to use for each section
+// is sticky.
+TEST_F(AutofillDialogControllerTest, AutofillProfileDefaults) {
+ AutofillProfile full_profile(test::GetFullProfile());
+ full_profile.set_origin(kSettingsOrigin);
+ controller()->GetTestingManager()->AddTestingProfile(&full_profile);
+ AutofillProfile full_profile2(test::GetFullProfile2());
+ full_profile2.set_origin(kSettingsOrigin);
+ controller()->GetTestingManager()->AddTestingProfile(&full_profile2);
+
+ // Until a selection has been made, the defauilt shipping suggestion is the
Ilya Sherman 2013/05/21 03:54:35 nit: "default"
Evan Stade 2013/05/21 17:34:41 Done.
+ // first one (after "use billing").
+ SuggestionsMenuModel* shipping_model = static_cast<SuggestionsMenuModel*>(
+ controller()->MenuModelForSection(SECTION_SHIPPING));
+ EXPECT_EQ(1, shipping_model->checked_item());
+
+ for (int i = 2; i >= 0; --i) {
+ SuggestionsMenuModel* shipping_model = static_cast<SuggestionsMenuModel*>(
+ controller()->MenuModelForSection(SECTION_SHIPPING));
+ shipping_model->ExecuteCommand(i, 0);
+ controller()->OnAccept();
+
+ TearDown();
+ SetUp();
Ilya Sherman 2013/05/21 03:54:35 Hmm, these methods aren't really meant to be calle
Evan Stade 2013/05/21 17:34:41 If the contents of SetUp and TearDown evolve, we p
+ controller()->GetTestingManager()->AddTestingProfile(&full_profile);
+ controller()->GetTestingManager()->AddTestingProfile(&full_profile2);
Ilya Sherman 2013/05/21 03:54:35 Please add a test verifying the behavior when the
Evan Stade 2013/05/21 17:34:41 Done. Also improved the behavior in that case (ins
+ shipping_model = static_cast<SuggestionsMenuModel*>(
+ controller()->MenuModelForSection(SECTION_SHIPPING));
+ EXPECT_EQ(i, shipping_model->checked_item());
+ }
+}
+
TEST_F(AutofillDialogControllerTest, AutofillProfileVariants) {
EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1);
ui::MenuModel* email_model =
@@ -453,6 +485,11 @@ TEST_F(AutofillDialogControllerTest, AutofillProfileVariants) {
ASSERT_TRUE(!!email_model);
EXPECT_EQ(4, email_model->GetItemCount());
+ // The first one is the default.
+ SuggestionsMenuModel* email_suggestions = static_cast<SuggestionsMenuModel*>(
+ controller()->MenuModelForSection(SECTION_EMAIL));
+ EXPECT_EQ(0, email_suggestions->checked_item());
+
email_model->ActivatedAt(0);
EXPECT_EQ(kEmail1,
controller()->SuggestionStateForSection(SECTION_EMAIL).text);
@@ -464,6 +501,18 @@ TEST_F(AutofillDialogControllerTest, AutofillProfileVariants) {
const DetailInputs& inputs =
controller()->RequestedFieldsForSection(SECTION_EMAIL);
EXPECT_EQ(kEmail2, inputs[0].initial_value);
+
+ // The choice of variant is persisted across runs of the dialog.
+ email_model->ActivatedAt(0);
+ email_model->ActivatedAt(1);
+ controller()->OnAccept();
+
+ TearDown();
+ SetUp();
+ controller()->GetTestingManager()->AddTestingProfile(&full_profile);
+ email_suggestions = static_cast<SuggestionsMenuModel*>(
+ controller()->MenuModelForSection(SECTION_EMAIL));
+ EXPECT_EQ(1, email_suggestions->checked_item());
}
// Test selecting a shipping address different from billing as address.

Powered by Google App Engine
This is Rietveld 408576698