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

Side by Side Diff: chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm

Issue 3041007: AutoFill Prefs dialog on Mac should list derived labels for profiles, not summaries. (Closed)
Patch Set: Fixing unit tests. Created 10 years, 5 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
OLDNEW
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_sheet_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_sheet_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"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 EXPECT_TRUE([[am phoneWholeNumber] isEqualToString:@"014155552258"]); 277 EXPECT_TRUE([[am phoneWholeNumber] isEqualToString:@"014155552258"]);
278 EXPECT_TRUE([[am faxWholeNumber] isEqualToString:@"024087172258"]); 278 EXPECT_TRUE([[am faxWholeNumber] isEqualToString:@"024087172258"]);
279 279
280 [sheet save:nil]; 280 [sheet save:nil];
281 [controller_ save:nil]; 281 [controller_ save:nil];
282 282
283 ASSERT_TRUE(observer_.hit_); 283 ASSERT_TRUE(observer_.hit_);
284 ASSERT_TRUE(observer_.profiles_.size() == 1); 284 ASSERT_TRUE(observer_.profiles_.size() == 1);
285 285
286 profiles()[0]->set_unique_id(observer_.profiles_[0].unique_id()); 286 profiles()[0]->set_unique_id(observer_.profiles_[0].unique_id());
287 // Do not compare labels. Label is a derived field.
288 observer_.profiles_[0].set_label(string16());
289 profiles()[0]->set_label(string16());
287 ASSERT_EQ(observer_.profiles_[0], *profiles()[0]); 290 ASSERT_EQ(observer_.profiles_[0], *profiles()[0]);
288 } 291 }
289 292
290 TEST_F(AutoFillDialogControllerTest, CreditCardDataMutation) { 293 TEST_F(AutoFillDialogControllerTest, CreditCardDataMutation) {
291 CreditCard credit_card(ASCIIToUTF16("myCC"), 345); 294 CreditCard credit_card(ASCIIToUTF16("myCC"), 345);
292 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("DCH")); 295 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("DCH"));
293 credit_card.SetInfo( 296 credit_card.SetInfo(
294 AutoFillType(CREDIT_CARD_NUMBER), ASCIIToUTF16("1234 5678 9101 1121")); 297 AutoFillType(CREDIT_CARD_NUMBER), ASCIIToUTF16("1234 5678 9101 1121"));
295 credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("01")); 298 credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("01"));
296 credit_card.SetInfo( 299 credit_card.SetInfo(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // Should hit our observer. 336 // Should hit our observer.
334 ASSERT_TRUE(observer_.hit_); 337 ASSERT_TRUE(observer_.hit_);
335 338
336 // Sizes should match. And should be 2. 339 // Sizes should match. And should be 2.
337 ASSERT_EQ(observer_.profiles_.size(), profiles().size()); 340 ASSERT_EQ(observer_.profiles_.size(), profiles().size());
338 ASSERT_EQ(observer_.profiles_.size(), 2UL); 341 ASSERT_EQ(observer_.profiles_.size(), 2UL);
339 342
340 // Contents should match. With the exception of the |unique_id|. 343 // Contents should match. With the exception of the |unique_id|.
341 for (size_t i = 0, count = profiles().size(); i < count; i++) { 344 for (size_t i = 0, count = profiles().size(); i < count; i++) {
342 profiles()[i]->set_unique_id(observer_.profiles_[i].unique_id()); 345 profiles()[i]->set_unique_id(observer_.profiles_[i].unique_id());
346
347 // Do not compare labels. Label is a derived field.
348 observer_.profiles_[i].set_label(string16());
349 profiles()[i]->set_label(string16());
343 ASSERT_EQ(observer_.profiles_[i], *profiles()[i]); 350 ASSERT_EQ(observer_.profiles_[i], *profiles()[i]);
344 } 351 }
345 } 352 }
346 353
347 TEST_F(AutoFillDialogControllerTest, TwoCreditCards) { 354 TEST_F(AutoFillDialogControllerTest, TwoCreditCards) {
348 CreditCard credit_card1(ASCIIToUTF16("Visa"), 1); 355 CreditCard credit_card1(ASCIIToUTF16("Visa"), 1);
349 credit_card1.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Joe")); 356 credit_card1.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Joe"));
350 credit_cards().push_back(&credit_card1); 357 credit_cards().push_back(&credit_card1);
351 CreditCard credit_card2(ASCIIToUTF16("Mastercard"), 2); 358 CreditCard credit_card2(ASCIIToUTF16("Mastercard"), 2);
352 credit_card2.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Bob")); 359 credit_card2.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Bob"));
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 470
464 // Should hit our observer. 471 // Should hit our observer.
465 ASSERT_TRUE(observer_.hit_); 472 ASSERT_TRUE(observer_.hit_);
466 473
467 // Sizes should match be different. New size should be 0. 474 // Sizes should match be different. New size should be 0.
468 ASSERT_NE(observer_.profiles_.size(), profiles().size()); 475 ASSERT_NE(observer_.profiles_.size(), profiles().size());
469 ASSERT_EQ(observer_.profiles_.size(), 1UL); 476 ASSERT_EQ(observer_.profiles_.size(), 1UL);
470 477
471 // First address should match. 478 // First address should match.
472 profiles()[0]->set_unique_id(observer_.profiles_[0].unique_id()); 479 profiles()[0]->set_unique_id(observer_.profiles_[0].unique_id());
480
481 // Do not compare labels. Label is a derived field.
482 observer_.profiles_[0].set_label(string16());
483 profile.set_label(string16());
473 ASSERT_EQ(observer_.profiles_[0], profile); 484 ASSERT_EQ(observer_.profiles_[0], profile);
474 } 485 }
475 486
476 TEST_F(AutoFillDialogControllerTest, TwoCreditCardsDeleteOne) { 487 TEST_F(AutoFillDialogControllerTest, TwoCreditCardsDeleteOne) {
477 CreditCard credit_card(ASCIIToUTF16("Visa"), 1); 488 CreditCard credit_card(ASCIIToUTF16("Visa"), 1);
478 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Joe")); 489 credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Joe"));
479 credit_cards().push_back(&credit_card); 490 credit_cards().push_back(&credit_card);
480 CreditCard credit_card2(ASCIIToUTF16("Mastercard"), 2); 491 CreditCard credit_card2(ASCIIToUTF16("Mastercard"), 2);
481 credit_card2.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Bob")); 492 credit_card2.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Bob"));
482 credit_cards().push_back(&credit_card2); 493 credit_cards().push_back(&credit_card2);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 // Should hit our observer. 562 // Should hit our observer.
552 ASSERT_TRUE(observer_.hit_); 563 ASSERT_TRUE(observer_.hit_);
553 564
554 // Sizes should match. 565 // Sizes should match.
555 ASSERT_EQ(observer_.profiles_.size(), profiles().size()); 566 ASSERT_EQ(observer_.profiles_.size(), profiles().size());
556 ASSERT_EQ(observer_.credit_cards_.size(), credit_cards().size()); 567 ASSERT_EQ(observer_.credit_cards_.size(), credit_cards().size());
557 568
558 // Contents should match. 569 // Contents should match.
559 size_t i = 0; 570 size_t i = 0;
560 size_t count = profiles().size(); 571 size_t count = profiles().size();
561 for (i = 0; i < count; i++) 572 for (i = 0; i < count; i++) {
573 // Do not compare labels. Label is a derived field.
574 observer_.profiles_[i].set_label(string16());
575 profiles()[i]->set_label(string16());
562 ASSERT_EQ(observer_.profiles_[i], *profiles()[i]); 576 ASSERT_EQ(observer_.profiles_[i], *profiles()[i]);
577 }
563 count = credit_cards().size(); 578 count = credit_cards().size();
564 for (i = 0; i < count; i++) { 579 for (i = 0; i < count; i++) {
565 ASSERT_EQ(observer_.credit_cards_[i], *credit_cards()[i]); 580 ASSERT_EQ(observer_.credit_cards_[i], *credit_cards()[i]);
566 } 581 }
567 } 582 }
568 583
569 TEST_F(AutoFillDialogControllerTest, ImportedParameters) { 584 TEST_F(AutoFillDialogControllerTest, ImportedParameters) {
570 AutoFillProfile profile(ASCIIToUTF16("Home"), 0); 585 AutoFillProfile profile(ASCIIToUTF16("Home"), 0);
571 imported_profile_ = &profile; 586 imported_profile_ = &profile;
572 CreditCard credit_card(ASCIIToUTF16("Mastercard"), 0); 587 CreditCard credit_card(ASCIIToUTF16("Mastercard"), 0);
(...skipping 10 matching lines...) Expand all
583 LoadDialog(); 598 LoadDialog();
584 [controller_ save:nil]; 599 [controller_ save:nil];
585 600
586 // Should hit our observer. 601 // Should hit our observer.
587 ASSERT_TRUE(observer_.hit_); 602 ASSERT_TRUE(observer_.hit_);
588 603
589 // Sizes should match. 604 // Sizes should match.
590 ASSERT_EQ(1UL, observer_.profiles_.size()); 605 ASSERT_EQ(1UL, observer_.profiles_.size());
591 ASSERT_EQ(1UL, observer_.credit_cards_.size()); 606 ASSERT_EQ(1UL, observer_.credit_cards_.size());
592 607
608 // Do not compare labels. Label is a derived field.
609 observer_.profiles_[0].set_label(string16());
610 profile.set_label(string16());
611
593 // Contents should match. 612 // Contents should match.
594 ASSERT_EQ(observer_.profiles_[0], profile); 613 ASSERT_EQ(observer_.profiles_[0], profile);
595 ASSERT_EQ(observer_.credit_cards_[0], credit_card); 614 ASSERT_EQ(observer_.credit_cards_[0], credit_card);
596 } 615 }
597 616
598 // AutoFill is enabled by default. 617 // AutoFill is enabled by default.
599 TEST_F(AutoFillDialogControllerTest, AutoFillEnabledTrue) { 618 TEST_F(AutoFillDialogControllerTest, AutoFillEnabledTrue) {
600 LoadDialog(); 619 LoadDialog();
601 [controller_ save:nil]; 620 [controller_ save:nil];
602 621
(...skipping 27 matching lines...) Expand all
630 649
631 // Should hit our observer. 650 // Should hit our observer.
632 ASSERT_TRUE(observer_.hit_); 651 ASSERT_TRUE(observer_.hit_);
633 652
634 // Auxiliary profiles setting should be unchanged. 653 // Auxiliary profiles setting should be unchanged.
635 ASSERT_TRUE(helper_.profile()->GetPrefs()->GetBoolean( 654 ASSERT_TRUE(helper_.profile()->GetPrefs()->GetBoolean(
636 prefs::kAutoFillEnabled)); 655 prefs::kAutoFillEnabled));
637 } 656 }
638 657
639 } // namespace 658 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_dialog_controller_mac.mm ('k') | chrome/browser/webdata/web_data_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698