| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/ref_counted.h" | 5 #include "base/ref_counted.h" |
| 6 #import "chrome/browser/autofill/autofill_address_model_mac.h" | 6 #import "chrome/browser/autofill/autofill_address_model_mac.h" |
| 7 #import "chrome/browser/autofill/autofill_address_view_controller_mac.h" | 7 #import "chrome/browser/autofill/autofill_address_sheet_controller_mac.h" |
| 8 #import "chrome/browser/autofill/autofill_credit_card_model_mac.h" | 8 #import "chrome/browser/autofill/autofill_credit_card_model_mac.h" |
| 9 #import "chrome/browser/autofill/autofill_credit_card_view_controller_mac.h" | 9 #import "chrome/browser/autofill/autofill_credit_card_sheet_controller_mac.h" |
| 10 #import "chrome/browser/autofill/autofill_dialog_controller_mac.h" | 10 #import "chrome/browser/autofill/autofill_dialog_controller_mac.h" |
| 11 #include "chrome/browser/autofill/autofill_profile.h" | 11 #include "chrome/browser/autofill/autofill_profile.h" |
| 12 #include "chrome/browser/autofill/personal_data_manager.h" | 12 #include "chrome/browser/autofill/personal_data_manager.h" |
| 13 #include "chrome/browser/cocoa/browser_test_helper.h" | 13 #include "chrome/browser/cocoa/browser_test_helper.h" |
| 14 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 14 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 15 #include "chrome/browser/pref_service.h" | 15 #include "chrome/browser/pref_service.h" |
| 16 #include "chrome/browser/profile.h" | 16 #include "chrome/browser/profile.h" |
| 17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // Contents should not match a different profile. | 233 // Contents should not match a different profile. |
| 234 CreditCard different_credit_card(ASCIIToUTF16("different"), 0); | 234 CreditCard different_credit_card(ASCIIToUTF16("different"), 0); |
| 235 different_credit_card.SetInfo( | 235 different_credit_card.SetInfo( |
| 236 AutoFillType(CREDIT_CARD_NUMBER), ASCIIToUTF16("1234")); | 236 AutoFillType(CREDIT_CARD_NUMBER), ASCIIToUTF16("1234")); |
| 237 for (i = 0; i < count; i++) | 237 for (i = 0; i < count; i++) |
| 238 ASSERT_NE(observer_.credit_cards_[i], different_credit_card); | 238 ASSERT_NE(observer_.credit_cards_[i], different_credit_card); |
| 239 } | 239 } |
| 240 | 240 |
| 241 TEST_F(AutoFillDialogControllerTest, AutoFillDataMutation) { | 241 TEST_F(AutoFillDialogControllerTest, AutoFillDataMutation) { |
| 242 AutoFillProfile profile(ASCIIToUTF16("Home"), 17); | 242 AutoFillProfile profile(ASCIIToUTF16("Home"), 17); |
| 243 profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("David")); | 243 profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("John")); |
| 244 profile.SetInfo(AutoFillType(NAME_MIDDLE), ASCIIToUTF16("C")); | 244 profile.SetInfo(AutoFillType(NAME_MIDDLE), ASCIIToUTF16("C")); |
| 245 profile.SetInfo(AutoFillType(NAME_LAST), ASCIIToUTF16("Holloway")); | 245 profile.SetInfo(AutoFillType(NAME_LAST), ASCIIToUTF16("Smith")); |
| 246 profile.SetInfo(AutoFillType(EMAIL_ADDRESS), | 246 profile.SetInfo(AutoFillType(EMAIL_ADDRESS), |
| 247 ASCIIToUTF16("dhollowa@chromium.org")); | 247 ASCIIToUTF16("john@chromium.org")); |
| 248 profile.SetInfo(AutoFillType(COMPANY_NAME), ASCIIToUTF16("Google Inc.")); | 248 profile.SetInfo(AutoFillType(COMPANY_NAME), ASCIIToUTF16("Google Inc.")); |
| 249 profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE1), | 249 profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE1), |
| 250 ASCIIToUTF16("1122 Mountain View Road")); | 250 ASCIIToUTF16("1122 Mountain View Road")); |
| 251 profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE2), ASCIIToUTF16("Suite #1")); | 251 profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE2), ASCIIToUTF16("Suite #1")); |
| 252 profile.SetInfo(AutoFillType(ADDRESS_HOME_CITY), | 252 profile.SetInfo(AutoFillType(ADDRESS_HOME_CITY), |
| 253 ASCIIToUTF16("Mountain View")); | 253 ASCIIToUTF16("Mountain View")); |
| 254 profile.SetInfo(AutoFillType(ADDRESS_HOME_STATE), ASCIIToUTF16("CA")); | 254 profile.SetInfo(AutoFillType(ADDRESS_HOME_STATE), ASCIIToUTF16("CA")); |
| 255 profile.SetInfo(AutoFillType(ADDRESS_HOME_ZIP), ASCIIToUTF16("94111")); | 255 profile.SetInfo(AutoFillType(ADDRESS_HOME_ZIP), ASCIIToUTF16("94111")); |
| 256 profile.SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("USA")); | 256 profile.SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("USA")); |
| 257 profile.SetInfo( | 257 profile.SetInfo( |
| 258 AutoFillType(PHONE_HOME_WHOLE_NUMBER), ASCIIToUTF16("014155552258")); | 258 AutoFillType(PHONE_HOME_WHOLE_NUMBER), ASCIIToUTF16("014155552258")); |
| 259 profile.SetInfo( | 259 profile.SetInfo( |
| 260 AutoFillType(PHONE_FAX_WHOLE_NUMBER), ASCIIToUTF16("024087172258")); | 260 AutoFillType(PHONE_FAX_WHOLE_NUMBER), ASCIIToUTF16("024087172258")); |
| 261 profiles().push_back(&profile); | 261 profiles().push_back(&profile); |
| 262 | 262 |
| 263 LoadDialog(); | 263 LoadDialog(); |
| 264 [controller_ selectAddressAtIndex:0]; |
| 265 [controller_ editSelection:nil]; |
| 264 | 266 |
| 265 AutoFillAddressModel* am = [[[controller_ addressFormViewControllers] | 267 AutoFillAddressSheetController* sheet = [controller_ addressSheetController]; |
| 266 objectAtIndex:0] addressModel]; | 268 ASSERT_TRUE(sheet != nil); |
| 269 AutoFillAddressModel* am = [sheet addressModel]; |
| 267 EXPECT_TRUE([[am label] isEqualToString:@"Home"]); | 270 EXPECT_TRUE([[am label] isEqualToString:@"Home"]); |
| 268 EXPECT_TRUE([[am firstName] isEqualToString:@"David"]); | 271 EXPECT_TRUE([[am fullName] isEqualToString:@"John C Smith"]); |
| 269 EXPECT_TRUE([[am middleName] isEqualToString:@"C"]); | 272 EXPECT_TRUE([[am email] isEqualToString:@"john@chromium.org"]); |
| 270 EXPECT_TRUE([[am lastName] isEqualToString:@"Holloway"]); | |
| 271 EXPECT_TRUE([[am email] isEqualToString:@"dhollowa@chromium.org"]); | |
| 272 EXPECT_TRUE([[am companyName] isEqualToString:@"Google Inc."]); | 273 EXPECT_TRUE([[am companyName] isEqualToString:@"Google Inc."]); |
| 273 EXPECT_TRUE([[am addressLine1] isEqualToString:@"1122 Mountain View Road"]); | 274 EXPECT_TRUE([[am addressLine1] isEqualToString:@"1122 Mountain View Road"]); |
| 274 EXPECT_TRUE([[am addressLine2] isEqualToString:@"Suite #1"]); | 275 EXPECT_TRUE([[am addressLine2] isEqualToString:@"Suite #1"]); |
| 275 EXPECT_TRUE([[am addressCity] isEqualToString:@"Mountain View"]); | 276 EXPECT_TRUE([[am addressCity] isEqualToString:@"Mountain View"]); |
| 276 EXPECT_TRUE([[am addressState] isEqualToString:@"CA"]); | 277 EXPECT_TRUE([[am addressState] isEqualToString:@"CA"]); |
| 277 EXPECT_TRUE([[am addressZip] isEqualToString:@"94111"]); | 278 EXPECT_TRUE([[am addressZip] isEqualToString:@"94111"]); |
| 278 EXPECT_TRUE([[am phoneWholeNumber] isEqualToString:@"014155552258"]); | 279 EXPECT_TRUE([[am phoneWholeNumber] isEqualToString:@"014155552258"]); |
| 279 EXPECT_TRUE([[am faxWholeNumber] isEqualToString:@"024087172258"]); | 280 EXPECT_TRUE([[am faxWholeNumber] isEqualToString:@"024087172258"]); |
| 280 | 281 |
| 282 [sheet save:nil]; |
| 281 [controller_ save:nil]; | 283 [controller_ save:nil]; |
| 282 | 284 |
| 283 ASSERT_TRUE(observer_.hit_); | 285 ASSERT_TRUE(observer_.hit_); |
| 284 ASSERT_TRUE(observer_.profiles_.size() == 1); | 286 ASSERT_TRUE(observer_.profiles_.size() == 1); |
| 285 | 287 |
| 286 profiles()[0]->set_unique_id(observer_.profiles_[0].unique_id()); | 288 profiles()[0]->set_unique_id(observer_.profiles_[0].unique_id()); |
| 287 ASSERT_EQ(observer_.profiles_[0], *profiles()[0]); | 289 ASSERT_EQ(observer_.profiles_[0], *profiles()[0]); |
| 288 } | 290 } |
| 289 | 291 |
| 290 TEST_F(AutoFillDialogControllerTest, CreditCardDataMutation) { | 292 TEST_F(AutoFillDialogControllerTest, CreditCardDataMutation) { |
| 291 CreditCard credit_card(ASCIIToUTF16("myCC"), 345); | 293 CreditCard credit_card(ASCIIToUTF16("myCC"), 345); |
| 292 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("DCH")); | 294 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("DCH")); |
| 293 credit_card.SetInfo( | 295 credit_card.SetInfo( |
| 294 AutoFillType(CREDIT_CARD_NUMBER), ASCIIToUTF16("1234 5678 9101 1121")); | 296 AutoFillType(CREDIT_CARD_NUMBER), ASCIIToUTF16("1234 5678 9101 1121")); |
| 295 credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("01")); | 297 credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("01")); |
| 296 credit_card.SetInfo( | 298 credit_card.SetInfo( |
| 297 AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), ASCIIToUTF16("2012")); | 299 AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), ASCIIToUTF16("2012")); |
| 298 credit_card.SetInfo( | 300 credit_card.SetInfo( |
| 299 AutoFillType(CREDIT_CARD_VERIFICATION_CODE), ASCIIToUTF16("222")); | 301 AutoFillType(CREDIT_CARD_VERIFICATION_CODE), ASCIIToUTF16("222")); |
| 300 credit_cards().push_back(&credit_card); | 302 credit_cards().push_back(&credit_card); |
| 301 | 303 |
| 302 LoadDialog(); | 304 LoadDialog(); |
| 305 [controller_ selectCreditCardAtIndex:0]; |
| 306 [controller_ editSelection:nil]; |
| 303 | 307 |
| 304 AutoFillCreditCardModel* cm = [[[controller_ creditCardFormViewControllers] | 308 AutoFillCreditCardSheetController* sheet = |
| 305 objectAtIndex:0] creditCardModel]; | 309 [controller_ creditCardSheetController]; |
| 310 ASSERT_TRUE(sheet != nil); |
| 311 AutoFillCreditCardModel* cm = [sheet creditCardModel]; |
| 306 EXPECT_TRUE([[cm label] isEqualToString:@"myCC"]); | 312 EXPECT_TRUE([[cm label] isEqualToString:@"myCC"]); |
| 307 EXPECT_TRUE([[cm nameOnCard] isEqualToString:@"DCH"]); | 313 EXPECT_TRUE([[cm nameOnCard] isEqualToString:@"DCH"]); |
| 308 EXPECT_TRUE([[cm creditCardNumber] isEqualToString:@"1234 5678 9101 1121"]); | 314 EXPECT_TRUE([[cm creditCardNumber] isEqualToString:@"1234 5678 9101 1121"]); |
| 309 EXPECT_TRUE([[cm expirationMonth] isEqualToString:@"01"]); | 315 EXPECT_TRUE([[cm expirationMonth] isEqualToString:@"01"]); |
| 310 EXPECT_TRUE([[cm expirationYear] isEqualToString:@"2012"]); | 316 EXPECT_TRUE([[cm expirationYear] isEqualToString:@"2012"]); |
| 311 EXPECT_TRUE([[cm cvcCode] isEqualToString:@"222"]); | 317 EXPECT_TRUE([[cm cvcCode] isEqualToString:@"222"]); |
| 312 | 318 |
| 319 [sheet save:nil]; |
| 313 [controller_ save:nil]; | 320 [controller_ save:nil]; |
| 314 | 321 |
| 315 ASSERT_TRUE(observer_.hit_); | 322 ASSERT_TRUE(observer_.hit_); |
| 316 ASSERT_TRUE(observer_.credit_cards_.size() == 1); | 323 ASSERT_TRUE(observer_.credit_cards_.size() == 1); |
| 317 | 324 |
| 318 credit_cards()[0]->set_unique_id(observer_.credit_cards_[0].unique_id()); | 325 credit_cards()[0]->set_unique_id(observer_.credit_cards_[0].unique_id()); |
| 319 ASSERT_EQ(observer_.credit_cards_[0], *credit_cards()[0]); | 326 ASSERT_EQ(observer_.credit_cards_[0], *credit_cards()[0]); |
| 320 } | 327 } |
| 321 | 328 |
| 322 TEST_F(AutoFillDialogControllerTest, TwoProfiles) { | 329 TEST_F(AutoFillDialogControllerTest, TwoProfiles) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 ASSERT_EQ(observer_.credit_cards_[i], *credit_cards()[i]); | 373 ASSERT_EQ(observer_.credit_cards_[i], *credit_cards()[i]); |
| 367 } | 374 } |
| 368 } | 375 } |
| 369 | 376 |
| 370 TEST_F(AutoFillDialogControllerTest, AddNewProfile) { | 377 TEST_F(AutoFillDialogControllerTest, AddNewProfile) { |
| 371 AutoFillProfile profile(ASCIIToUTF16("One"), 1); | 378 AutoFillProfile profile(ASCIIToUTF16("One"), 1); |
| 372 profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Joe")); | 379 profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Joe")); |
| 373 profiles().push_back(&profile); | 380 profiles().push_back(&profile); |
| 374 LoadDialog(); | 381 LoadDialog(); |
| 375 [controller_ addNewAddress:nil]; | 382 [controller_ addNewAddress:nil]; |
| 383 AutoFillAddressSheetController* sheet = [controller_ addressSheetController]; |
| 384 ASSERT_TRUE(sheet != nil); |
| 385 [sheet save:nil]; |
| 376 [controller_ save:nil]; | 386 [controller_ save:nil]; |
| 377 | 387 |
| 378 // Should hit our observer. | 388 // Should hit our observer. |
| 379 ASSERT_TRUE(observer_.hit_); | 389 ASSERT_TRUE(observer_.hit_); |
| 380 | 390 |
| 381 // Sizes should match be different. New size should be 2. | 391 // Sizes should match be different. New size should be 2. |
| 382 ASSERT_NE(observer_.profiles_.size(), profiles().size()); | 392 ASSERT_NE(observer_.profiles_.size(), profiles().size()); |
| 383 ASSERT_EQ(observer_.profiles_.size(), 2UL); | 393 ASSERT_EQ(observer_.profiles_.size(), 2UL); |
| 384 | 394 |
| 385 // New address should match. | 395 // New address should match. |
| 386 AutoFillProfile new_profile(ASCIIToUTF16("New address"), 0); | 396 AutoFillProfile new_profile(ASCIIToUTF16("New address"), 0); |
| 387 ASSERT_EQ(observer_.profiles_[1], new_profile); | 397 ASSERT_EQ(observer_.profiles_[1], new_profile); |
| 388 } | 398 } |
| 389 | 399 |
| 390 TEST_F(AutoFillDialogControllerTest, AddNewCreditCard) { | 400 TEST_F(AutoFillDialogControllerTest, AddNewCreditCard) { |
| 391 CreditCard credit_card(ASCIIToUTF16("Visa"), 1); | 401 CreditCard credit_card(ASCIIToUTF16("Visa"), 1); |
| 392 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Joe")); | 402 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Joe")); |
| 393 credit_cards().push_back(&credit_card); | 403 credit_cards().push_back(&credit_card); |
| 394 LoadDialog(); | 404 LoadDialog(); |
| 395 [controller_ addNewCreditCard:nil]; | 405 [controller_ addNewCreditCard:nil]; |
| 406 AutoFillCreditCardSheetController* sheet = |
| 407 [controller_ creditCardSheetController]; |
| 408 ASSERT_TRUE(sheet != nil); |
| 409 [sheet save:nil]; |
| 396 [controller_ save:nil]; | 410 [controller_ save:nil]; |
| 397 | 411 |
| 398 // Should hit our observer. | 412 // Should hit our observer. |
| 399 ASSERT_TRUE(observer_.hit_); | 413 ASSERT_TRUE(observer_.hit_); |
| 400 | 414 |
| 401 // Sizes should match be different. New size should be 2. | 415 // Sizes should match be different. New size should be 2. |
| 402 ASSERT_NE(observer_.credit_cards_.size(), credit_cards().size()); | 416 ASSERT_NE(observer_.credit_cards_.size(), credit_cards().size()); |
| 403 ASSERT_EQ(observer_.credit_cards_.size(), 2UL); | 417 ASSERT_EQ(observer_.credit_cards_.size(), 2UL); |
| 404 | 418 |
| 405 // New address should match. | 419 // New address should match. |
| 406 CreditCard new_credit_card(ASCIIToUTF16("New credit card"), 0); | 420 CreditCard new_credit_card(ASCIIToUTF16("New credit card"), 0); |
| 407 ASSERT_EQ(observer_.credit_cards_[1], new_credit_card); | 421 ASSERT_EQ(observer_.credit_cards_[1], new_credit_card); |
| 408 } | 422 } |
| 409 | 423 |
| 410 TEST_F(AutoFillDialogControllerTest, DeleteProfile) { | 424 TEST_F(AutoFillDialogControllerTest, DeleteProfile) { |
| 411 AutoFillProfile profile(ASCIIToUTF16("One"), 1); | 425 AutoFillProfile profile(ASCIIToUTF16("One"), 1); |
| 412 profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Joe")); | 426 profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Joe")); |
| 413 profiles().push_back(&profile); | 427 profiles().push_back(&profile); |
| 414 LoadDialog(); | 428 LoadDialog(); |
| 415 EXPECT_EQ([[[controller_ addressFormViewControllers] lastObject] | 429 [controller_ selectAddressAtIndex:0]; |
| 416 retainCount], 1UL); | 430 [controller_ deleteSelection:nil]; |
| 417 [controller_ deleteAddress:[[controller_ addressFormViewControllers] | |
| 418 lastObject]]; | |
| 419 [controller_ save:nil]; | 431 [controller_ save:nil]; |
| 420 | 432 |
| 421 // Should hit our observer. | 433 // Should hit our observer. |
| 422 ASSERT_TRUE(observer_.hit_); | 434 ASSERT_TRUE(observer_.hit_); |
| 423 | 435 |
| 424 // Sizes should match be different. New size should be 0. | 436 // Sizes should match be different. New size should be 0. |
| 425 ASSERT_NE(observer_.profiles_.size(), profiles().size()); | 437 ASSERT_NE(observer_.profiles_.size(), profiles().size()); |
| 426 ASSERT_EQ(observer_.profiles_.size(), 0UL); | 438 ASSERT_EQ(observer_.profiles_.size(), 0UL); |
| 427 } | 439 } |
| 428 | 440 |
| 429 TEST_F(AutoFillDialogControllerTest, DeleteCreditCard) { | 441 TEST_F(AutoFillDialogControllerTest, DeleteCreditCard) { |
| 430 CreditCard credit_card(ASCIIToUTF16("Visa"), 1); | 442 CreditCard credit_card(ASCIIToUTF16("Visa"), 1); |
| 431 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Joe")); | 443 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Joe")); |
| 432 credit_cards().push_back(&credit_card); | 444 credit_cards().push_back(&credit_card); |
| 433 LoadDialog(); | 445 LoadDialog(); |
| 434 EXPECT_EQ([[[controller_ creditCardFormViewControllers] lastObject] | 446 [controller_ selectCreditCardAtIndex:0]; |
| 435 retainCount], 1UL); | 447 [controller_ deleteSelection:nil]; |
| 436 [controller_ deleteCreditCard:[[controller_ creditCardFormViewControllers] | |
| 437 lastObject]]; | |
| 438 [controller_ save:nil]; | 448 [controller_ save:nil]; |
| 439 | 449 |
| 440 // Should hit our observer. | 450 // Should hit our observer. |
| 441 ASSERT_TRUE(observer_.hit_); | 451 ASSERT_TRUE(observer_.hit_); |
| 442 | 452 |
| 443 // Sizes should match be different. New size should be 0. | 453 // Sizes should match be different. New size should be 0. |
| 444 ASSERT_NE(observer_.credit_cards_.size(), credit_cards().size()); | 454 ASSERT_NE(observer_.credit_cards_.size(), credit_cards().size()); |
| 445 ASSERT_EQ(observer_.credit_cards_.size(), 0UL); | 455 ASSERT_EQ(observer_.credit_cards_.size(), 0UL); |
| 446 } | 456 } |
| 447 | 457 |
| 448 TEST_F(AutoFillDialogControllerTest, TwoProfilesDeleteOne) { | 458 TEST_F(AutoFillDialogControllerTest, TwoProfilesDeleteOne) { |
| 449 AutoFillProfile profile(ASCIIToUTF16("One"), 1); | 459 AutoFillProfile profile(ASCIIToUTF16("One"), 1); |
| 450 profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Joe")); | 460 profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Joe")); |
| 451 profiles().push_back(&profile); | 461 profiles().push_back(&profile); |
| 452 AutoFillProfile profile2(ASCIIToUTF16("Two"), 2); | 462 AutoFillProfile profile2(ASCIIToUTF16("Two"), 2); |
| 453 profile2.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Bob")); | 463 profile2.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Bob")); |
| 454 profiles().push_back(&profile2); | 464 profiles().push_back(&profile2); |
| 455 LoadDialog(); | 465 LoadDialog(); |
| 456 [controller_ deleteAddress:[[controller_ addressFormViewControllers] | 466 [controller_ selectAddressAtIndex:1]; |
| 457 lastObject]]; | 467 [controller_ deleteSelection:nil]; |
| 458 [controller_ save:nil]; | 468 [controller_ save:nil]; |
| 459 | 469 |
| 460 // Should hit our observer. | 470 // Should hit our observer. |
| 461 ASSERT_TRUE(observer_.hit_); | 471 ASSERT_TRUE(observer_.hit_); |
| 462 | 472 |
| 463 // Sizes should match be different. New size should be 0. | 473 // Sizes should match be different. New size should be 0. |
| 464 ASSERT_NE(observer_.profiles_.size(), profiles().size()); | 474 ASSERT_NE(observer_.profiles_.size(), profiles().size()); |
| 465 ASSERT_EQ(observer_.profiles_.size(), 1UL); | 475 ASSERT_EQ(observer_.profiles_.size(), 1UL); |
| 466 | 476 |
| 467 // First address should match. | 477 // First address should match. |
| 468 profiles()[0]->set_unique_id(observer_.profiles_[0].unique_id()); | 478 profiles()[0]->set_unique_id(observer_.profiles_[0].unique_id()); |
| 469 ASSERT_EQ(observer_.profiles_[0], profile); | 479 ASSERT_EQ(observer_.profiles_[0], profile); |
| 470 } | 480 } |
| 471 | 481 |
| 472 TEST_F(AutoFillDialogControllerTest, TwoCreditCardsDeleteOne) { | 482 TEST_F(AutoFillDialogControllerTest, TwoCreditCardsDeleteOne) { |
| 473 CreditCard credit_card(ASCIIToUTF16("Visa"), 1); | 483 CreditCard credit_card(ASCIIToUTF16("Visa"), 1); |
| 474 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Joe")); | 484 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Joe")); |
| 475 credit_cards().push_back(&credit_card); | 485 credit_cards().push_back(&credit_card); |
| 476 CreditCard credit_card2(ASCIIToUTF16("Mastercard"), 2); | 486 CreditCard credit_card2(ASCIIToUTF16("Mastercard"), 2); |
| 477 credit_card2.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Bob")); | 487 credit_card2.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Bob")); |
| 478 credit_cards().push_back(&credit_card2); | 488 credit_cards().push_back(&credit_card2); |
| 479 LoadDialog(); | 489 LoadDialog(); |
| 480 [controller_ deleteCreditCard:[[controller_ creditCardFormViewControllers] | 490 [controller_ selectCreditCardAtIndex:1]; |
| 481 lastObject]]; | 491 [controller_ deleteSelection:nil]; |
| 482 [controller_ save:nil]; | 492 [controller_ save:nil]; |
| 483 | 493 |
| 484 // Should hit our observer. | 494 // Should hit our observer. |
| 485 ASSERT_TRUE(observer_.hit_); | 495 ASSERT_TRUE(observer_.hit_); |
| 486 | 496 |
| 487 // Sizes should match be different. New size should be 0. | 497 // Sizes should match be different. New size should be 0. |
| 488 ASSERT_NE(observer_.credit_cards_.size(), credit_cards().size()); | 498 ASSERT_NE(observer_.credit_cards_.size(), credit_cards().size()); |
| 489 ASSERT_EQ(observer_.credit_cards_.size(), 1UL); | 499 ASSERT_EQ(observer_.credit_cards_.size(), 1UL); |
| 490 | 500 |
| 491 // First credit card should match. | 501 // First credit card should match. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 // Sizes should match. | 594 // Sizes should match. |
| 585 ASSERT_EQ(1UL, observer_.profiles_.size()); | 595 ASSERT_EQ(1UL, observer_.profiles_.size()); |
| 586 ASSERT_EQ(1UL, observer_.credit_cards_.size()); | 596 ASSERT_EQ(1UL, observer_.credit_cards_.size()); |
| 587 | 597 |
| 588 // Contents should match. | 598 // Contents should match. |
| 589 ASSERT_EQ(observer_.profiles_[0], profile); | 599 ASSERT_EQ(observer_.profiles_[0], profile); |
| 590 ASSERT_EQ(observer_.credit_cards_[0], credit_card); | 600 ASSERT_EQ(observer_.credit_cards_[0], credit_card); |
| 591 } | 601 } |
| 592 | 602 |
| 593 } // namespace | 603 } // namespace |
| OLD | NEW |