Index: chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm |
=================================================================== |
--- chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm (revision 54215) |
+++ chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm (working copy) |
@@ -383,6 +383,9 @@ |
[controller_ addNewAddress:nil]; |
AutoFillAddressSheetController* sheet = [controller_ addressSheetController]; |
ASSERT_TRUE(sheet != nil); |
+ AutoFillAddressModel* model = [sheet addressModel]; |
+ ASSERT_TRUE(model != nil); |
+ [model setFullName:@"Don"]; |
[sheet save:nil]; |
[controller_ save:nil]; |
@@ -393,8 +396,10 @@ |
ASSERT_NE(observer_.profiles_.size(), profiles().size()); |
ASSERT_EQ(observer_.profiles_.size(), 2UL); |
- // New address should match. |
+ // New address should match. Don't compare labels. |
AutoFillProfile new_profile; |
+ new_profile.SetInfo(AutoFillType(NAME_FULL), ASCIIToUTF16("Don")); |
+ observer_.profiles_[1].set_label(string16()); |
ASSERT_EQ(observer_.profiles_[1], new_profile); |
} |
@@ -407,6 +412,9 @@ |
AutoFillCreditCardSheetController* sheet = |
[controller_ creditCardSheetController]; |
ASSERT_TRUE(sheet != nil); |
+ AutoFillCreditCardModel* model = [sheet creditCardModel]; |
+ ASSERT_TRUE(model != nil); |
+ [model setNameOnCard:@"Don"]; |
[sheet save:nil]; |
[controller_ save:nil]; |
@@ -417,11 +425,60 @@ |
ASSERT_NE(observer_.credit_cards_.size(), credit_cards().size()); |
ASSERT_EQ(observer_.credit_cards_.size(), 2UL); |
- // New address should match. |
+ // New credit card should match. Don't compare labels. |
CreditCard new_credit_card; |
+ new_credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Don")); |
+ observer_.credit_cards_[1].set_label(string16()); |
ASSERT_EQ(observer_.credit_cards_[1], new_credit_card); |
} |
+TEST_F(AutoFillDialogControllerTest, AddNewEmptyProfile) { |
+ AutoFillProfile profile(string16(), 1); |
+ profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Joe")); |
+ profiles().push_back(&profile); |
+ LoadDialog(); |
+ [controller_ addNewAddress:nil]; |
+ AutoFillAddressSheetController* sheet = [controller_ addressSheetController]; |
+ ASSERT_TRUE(sheet != nil); |
+ [sheet save:nil]; |
+ [controller_ save:nil]; |
+ |
+ // Should hit our observer. |
+ ASSERT_TRUE(observer_.hit_); |
+ |
+ // Sizes should be same. Empty profile should not be saved. |
+ ASSERT_EQ(observer_.profiles_.size(), profiles().size()); |
+ ASSERT_EQ(observer_.profiles_.size(), 1UL); |
+ |
+ // Profile should match original. |
+ observer_.profiles_[0].set_label(string16()); |
+ ASSERT_EQ(observer_.profiles_[0], profile); |
+} |
+ |
+TEST_F(AutoFillDialogControllerTest, AddNewEmptyCreditCard) { |
+ CreditCard credit_card(string16(), 1); |
+ credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Joe")); |
+ credit_cards().push_back(&credit_card); |
+ LoadDialog(); |
+ [controller_ addNewCreditCard:nil]; |
+ AutoFillCreditCardSheetController* sheet = |
+ [controller_ creditCardSheetController]; |
+ ASSERT_TRUE(sheet != nil); |
+ [sheet save:nil]; |
+ [controller_ save:nil]; |
+ |
+ // Should hit our observer. |
+ ASSERT_TRUE(observer_.hit_); |
+ |
+ // Sizes should be same. Empty credit card should not be saved. |
+ ASSERT_EQ(observer_.credit_cards_.size(), credit_cards().size()); |
+ ASSERT_EQ(observer_.credit_cards_.size(), 1UL); |
+ |
+ // Credit card should match original. |
+ observer_.credit_cards_[0].set_label(string16()); |
+ ASSERT_EQ(observer_.credit_cards_[0], credit_card); |
+} |
+ |
TEST_F(AutoFillDialogControllerTest, DeleteProfile) { |
AutoFillProfile profile(ASCIIToUTF16("One"), 1); |
profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Joe")); |