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

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: Rebase to head instead of using lkgr 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 void set_is_first_run(bool is_first_run) { is_first_run_ = is_first_run; } 215 void set_is_first_run(bool is_first_run) { is_first_run_ = is_first_run; }
216 216
217 const GURL& open_tab_url() { return open_tab_url_; } 217 const GURL& open_tab_url() { return open_tab_url_; }
218 218
219 virtual DialogType GetDialogType() const OVERRIDE { 219 virtual DialogType GetDialogType() const OVERRIDE {
220 return dialog_type_; 220 return dialog_type_;
221 } 221 }
222 222
223 void set_dialog_type(DialogType dialog_type) { dialog_type_ = dialog_type; } 223 void set_dialog_type(DialogType dialog_type) { dialog_type_ = dialog_type; }
224 224
225 bool IsSectionInEditState(DialogSection section) {
226 std::map<DialogSection, bool> state = section_editing_state();
227 return state[section];
228 }
229
225 protected: 230 protected:
226 virtual PersonalDataManager* GetManager() OVERRIDE { 231 virtual PersonalDataManager* GetManager() OVERRIDE {
227 return &test_manager_; 232 return &test_manager_;
228 } 233 }
229 234
230 virtual wallet::WalletClient* GetWalletClient() OVERRIDE { 235 virtual wallet::WalletClient* GetWalletClient() OVERRIDE {
231 return &test_wallet_client_; 236 return &test_wallet_client_;
232 } 237 }
233 238
234 virtual bool IsFirstRun() const OVERRIDE { 239 virtual bool IsFirstRun() const OVERRIDE {
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress()); 670 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress());
666 wallet_items->AddAddress(wallet::GetTestShippingAddress()); 671 wallet_items->AddAddress(wallet::GetTestShippingAddress());
667 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress()); 672 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress());
668 673
669 controller()->OnDidGetWalletItems(wallet_items.Pass()); 674 controller()->OnDidGetWalletItems(wallet_items.Pass());
670 // "add", "manage", and 4 suggestions. 675 // "add", "manage", and 4 suggestions.
671 EXPECT_EQ(6, 676 EXPECT_EQ(6,
672 controller()->MenuModelForSection(SECTION_CC_BILLING)->GetItemCount()); 677 controller()->MenuModelForSection(SECTION_CC_BILLING)->GetItemCount());
673 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_CC_BILLING)-> 678 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_CC_BILLING)->
674 IsItemCheckedAt(2)); 679 IsItemCheckedAt(2));
680 ASSERT_FALSE(controller()->IsSectionInEditState(SECTION_CC_BILLING));
675 // "use billing", "add", "manage", and 5 suggestions. 681 // "use billing", "add", "manage", and 5 suggestions.
676 EXPECT_EQ(8, 682 EXPECT_EQ(8,
677 controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); 683 controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount());
678 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_SHIPPING)-> 684 EXPECT_TRUE(controller()->MenuModelForSection(SECTION_SHIPPING)->
679 IsItemCheckedAt(4)); 685 IsItemCheckedAt(4));
686 ASSERT_FALSE(controller()->IsSectionInEditState(SECTION_SHIPPING));
680 } 687 }
681 688
682 // Tests that invalid and AMEX default instruments are ignored. 689 // Tests that invalid and AMEX default instruments are ignored.
683 TEST_F(AutofillDialogControllerTest, SelectInstrument) { 690 TEST_F(AutofillDialogControllerTest, SelectInstrument) {
684 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); 691 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
685 // Tests if default instrument is invalid, then, the first valid instrument is 692 // Tests if default instrument is invalid, then, the first valid instrument is
686 // selected instead of the default instrument. 693 // selected instead of the default instrument.
687 wallet_items->AddInstrument(wallet::GetTestNonDefaultMaskedInstrument()); 694 wallet_items->AddInstrument(wallet::GetTestNonDefaultMaskedInstrument());
688 wallet_items->AddInstrument(wallet::GetTestNonDefaultMaskedInstrument()); 695 wallet_items->AddInstrument(wallet::GetTestNonDefaultMaskedInstrument());
689 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentInvalid()); 696 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentInvalid());
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 controller()->EditCancelledForSection(SECTION_EMAIL); 1404 controller()->EditCancelledForSection(SECTION_EMAIL);
1398 EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome()); 1405 EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome());
1399 1406
1400 controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(1); 1407 controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(1);
1401 EXPECT_TRUE(controller()->ShouldOfferToSaveInChrome()); 1408 EXPECT_TRUE(controller()->ShouldOfferToSaveInChrome());
1402 1409
1403 profile()->set_incognito(true); 1410 profile()->set_incognito(true);
1404 EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome()); 1411 EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome());
1405 } 1412 }
1406 1413
1414 // Tests that user is prompted when using instrument with minimal address.
1415 TEST_F(AutofillDialogControllerTest, UpgradeMinimalAddress) {
1416 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
1417 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentWithIdAndAddress(
1418 "id", wallet::GetTestMinimalAddress()));
1419 scoped_ptr<wallet::Address> address(wallet::GetTestShippingAddress());
1420 address->set_is_complete_address(false);
1421 wallet_items->AddAddress(address.Pass());
1422 controller()->OnDidGetWalletItems(wallet_items.Pass());
1423
1424 // Assert that dialog's SECTION_CC_BILLING section is in edit mode.
1425 ASSERT_TRUE(controller()->IsSectionInEditState(SECTION_CC_BILLING));
1426 // Shipping section should be in edit mode because of
1427 // is_minimal_shipping_address.
1428 ASSERT_TRUE(controller()->IsSectionInEditState(SECTION_SHIPPING));
1429 }
1430
1407 } // namespace autofill 1431 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller_impl.h ('k') | chrome/browser/ui/autofill/data_model_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698