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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc

Issue 15697010: Autofill:requestAutocomplete: Enable prompting for complete address when instrument being used does… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/guid.h" 5 #include "base/guid.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 10 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 194 }
195 195
196 TestWalletClient* GetTestingWalletClient() { 196 TestWalletClient* GetTestingWalletClient() {
197 return &test_wallet_client_; 197 return &test_wallet_client_;
198 } 198 }
199 199
200 void set_is_first_run(bool is_first_run) { is_first_run_ = is_first_run; } 200 void set_is_first_run(bool is_first_run) { is_first_run_ = is_first_run; }
201 201
202 const GURL& open_tab_url() { return open_tab_url_; } 202 const GURL& open_tab_url() { return open_tab_url_; }
203 203
204 bool IsSectionInEditState(DialogSection section) {
205 std::map<DialogSection, bool> state = section_editing_state();
206 return state[section];
207 }
208
204 protected: 209 protected:
205 virtual PersonalDataManager* GetManager() OVERRIDE { 210 virtual PersonalDataManager* GetManager() OVERRIDE {
206 return &test_manager_; 211 return &test_manager_;
207 } 212 }
208 213
209 virtual wallet::WalletClient* GetWalletClient() OVERRIDE { 214 virtual wallet::WalletClient* GetWalletClient() OVERRIDE {
210 return &test_wallet_client_; 215 return &test_wallet_client_;
211 } 216 }
212 217
213 virtual bool IsFirstRun() const OVERRIDE { 218 virtual bool IsFirstRun() const OVERRIDE {
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress()); 538 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress());
534 wallet_items->AddAddress(wallet::GetTestShippingAddress()); 539 wallet_items->AddAddress(wallet::GetTestShippingAddress());
535 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress()); 540 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress());
536 541
537 controller()->OnDidGetWalletItems(wallet_items.Pass()); 542 controller()->OnDidGetWalletItems(wallet_items.Pass());
538 // "add", "manage", and 4 suggestions. 543 // "add", "manage", and 4 suggestions.
539 EXPECT_EQ(6, 544 EXPECT_EQ(6,
540 controller()->MenuModelForSection(SECTION_CC_BILLING)->GetItemCount()); 545 controller()->MenuModelForSection(SECTION_CC_BILLING)->GetItemCount());
541 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_CC_BILLING)-> 546 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_CC_BILLING)->
542 IsItemCheckedAt(2)); 547 IsItemCheckedAt(2));
548 ASSERT_FALSE(controller()->IsSectionInEditState(SECTION_CC_BILLING));
543 // "use billing", "add", "manage", and 5 suggestions. 549 // "use billing", "add", "manage", and 5 suggestions.
544 EXPECT_EQ(8, 550 EXPECT_EQ(8,
545 controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); 551 controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount());
546 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_SHIPPING)-> 552 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_SHIPPING)->
547 IsItemCheckedAt(4)); 553 IsItemCheckedAt(4));
554 ASSERT_FALSE(controller()->IsSectionInEditState(SECTION_SHIPPING));
548 } 555 }
549 556
550 TEST_F(AutofillDialogControllerTest, SaveAddress) { 557 TEST_F(AutofillDialogControllerTest, SaveAddress) {
551 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); 558 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1);
552 EXPECT_CALL(*controller()->GetTestingWalletClient(), 559 EXPECT_CALL(*controller()->GetTestingWalletClient(),
553 SaveAddress(_, _)).Times(1); 560 SaveAddress(_, _)).Times(1);
554 561
555 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); 562 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
556 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); 563 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
557 controller()->OnDidGetWalletItems(wallet_items.Pass()); 564 controller()->OnDidGetWalletItems(wallet_items.Pass());
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 controller()->EditCancelledForSection(SECTION_EMAIL); 1170 controller()->EditCancelledForSection(SECTION_EMAIL);
1164 EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome()); 1171 EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome());
1165 1172
1166 controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(1); 1173 controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(1);
1167 EXPECT_TRUE(controller()->ShouldOfferToSaveInChrome()); 1174 EXPECT_TRUE(controller()->ShouldOfferToSaveInChrome());
1168 1175
1169 profile()->set_incognito(true); 1176 profile()->set_incognito(true);
1170 EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome()); 1177 EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome());
1171 } 1178 }
1172 1179
1180 // Tests that user is prompted when using instrument with minimal address.
1181 TEST_F(AutofillDialogControllerTest, UpgradeMinimalAddress) {
1182 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
1183 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentWithIdAndAddress(
1184 "id", wallet::GetTestMinimalAddress()));
1185 scoped_ptr<wallet::Address> address(wallet::GetTestShippingAddress());
1186 address->set_is_complete_address(false);
1187 wallet_items->AddAddress(address.Pass());
1188 controller()->OnDidGetWalletItems(wallet_items.Pass());
1189
1190 // Assert that dialog's SECTION_CC_BILLING section is in edit mode.
1191 ASSERT_TRUE(controller()->IsSectionInEditState(SECTION_CC_BILLING));
1192 // Shipping section should be in edit mode because of
1193 // is_minimal_shipping_address.
1194 ASSERT_TRUE(controller()->IsSectionInEditState(SECTION_SHIPPING));
1195 }
1196
1173 } // namespace autofill 1197 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698