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

Side by Side Diff: chrome/browser/autofill/autofill_profile_unittest.cc

Issue 8143007: Move a bunch of non-shared methods out of the FormGroup class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: De-nitting Created 9 years, 2 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
« no previous file with comments | « chrome/browser/autofill/autofill_profile.cc ('k') | chrome/browser/autofill/credit_card.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 b.reset(new AutofillProfile); 525 b.reset(new AutofillProfile);
526 autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", 526 autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson",
527 "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 527 "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
528 NULL); 528 NULL);
529 autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Adams", 529 autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Adams",
530 "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 530 "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
531 NULL); 531 NULL);
532 EXPECT_FALSE(a->IsSubsetOf(*b)); 532 EXPECT_FALSE(a->IsSubsetOf(*b));
533 } 533 }
534 534
535 TEST_F(AutofillProfileTest, IntersectionOfTypesHasEqualValues) {
536 scoped_ptr<AutofillProfile> a, b;
537
538 // Intersection of types contains the fields NAME_FIRST, NAME_LAST,
539 // EMAIL_ADDRESS. The values of these field types are equal between the two
540 // profiles.
541 a.reset(new AutofillProfile);
542 b.reset(new AutofillProfile);
543 autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson",
544 "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
545 "12134759123");
546 autofill_test::SetProfileInfo(b.get(), "Thomas", NULL, "Jefferson",
547 "declaration_guy@gmail.com", "United States Government", "Monticello",
548 NULL, "Charlottesville", "Virginia", "22902", NULL, NULL);
549 EXPECT_TRUE(a->IntersectionOfTypesHasEqualValues(*b));
550
551 // Intersection of types contains the fields NAME_FIRST, NAME_LAST,
552 // EMAIL_ADDRESS. The value of EMAIL_ADDRESS differs between the two profiles.
553 a.reset(new AutofillProfile);
554 b.reset(new AutofillProfile);
555 autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson",
556 "poser@yahoo.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
557 "12134759123");
558 autofill_test::SetProfileInfo(b.get(), "Thomas", NULL, "Jefferson",\
559 "declaration_guy@gmail.com", "United States Government", "Monticello",
560 NULL, "Charlottesville", "Virginia", "22902", NULL, NULL);
561 EXPECT_FALSE(a->IntersectionOfTypesHasEqualValues(*b));
562
563 // Intersection of types is empty.
564 a.reset(new AutofillProfile);
565 b.reset(new AutofillProfile);
566 autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson",
567 "poser@yahoo.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
568 "12134759123");
569 autofill_test::SetProfileInfo(b.get(), NULL, NULL, NULL, NULL,
570 "United States Government", "Monticello", NULL, "Charlottesville",
571 "Virginia", "22902", NULL, NULL);
572 EXPECT_FALSE(a->IntersectionOfTypesHasEqualValues(*b));
573 }
574
575 TEST_F(AutofillProfileTest, MergeWith) {
576 scoped_ptr<AutofillProfile> a, b;
577
578 // Merge |b| into |a|.
579 a.reset(new AutofillProfile);
580 b.reset(new AutofillProfile);
581 autofill_test::SetProfileInfo(a.get(), "Jimmy", NULL, NULL, NULL,
582 NULL, NULL, NULL, NULL, NULL, NULL, NULL, "12134759123");
583 autofill_test::SetProfileInfo(b.get(), "James", NULL, "Madison",
584 "constitutionalist@gmail.com", "United States Government", "Monticello",
585 NULL, "Charlottesville", "Virginia", "22902", NULL, NULL);
586 AutofillProfile expected_b(*b);
587 a->MergeWith(*b);
588
589 AutofillProfile expected_a;
590 autofill_test::SetProfileInfo(&expected_a, "Jimmy", NULL, "Madison",
591 "constitutionalist@gmail.com", "United States Government", "Monticello",
592 NULL, "Charlottesville", "Virginia", "22902", NULL, "12134759123");
593 EXPECT_EQ(0, expected_a.Compare(*a));
594 EXPECT_EQ(0, expected_b.Compare(*b));
595 }
596
597 TEST_F(AutofillProfileTest, AssignmentOperator){ 535 TEST_F(AutofillProfileTest, AssignmentOperator){
598 AutofillProfile a, b; 536 AutofillProfile a, b;
599 537
600 // Result of assignment should be logically equal to the original profile. 538 // Result of assignment should be logically equal to the original profile.
601 autofill_test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", 539 autofill_test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison",
602 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", 540 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5",
603 "Hollywood", "CA", "91601", "US", 541 "Hollywood", "CA", "91601", "US",
604 "12345678910"); 542 "12345678910");
605 b = a; 543 b = a;
606 EXPECT_TRUE(a == b); 544 EXPECT_TRUE(a == b);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 // Delete values. 712 // Delete values.
775 set_values.clear(); 713 set_values.clear();
776 p.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); 714 p.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values);
777 p.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values); 715 p.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values);
778 ASSERT_EQ(1UL, get_values.size()); 716 ASSERT_EQ(1UL, get_values.size());
779 EXPECT_EQ(string16(), get_values[0]); 717 EXPECT_EQ(string16(), get_values[0]);
780 718
781 // Expect regular |GetInfo| returns empty value. 719 // Expect regular |GetInfo| returns empty value.
782 EXPECT_EQ(string16(), p.GetInfo(PHONE_HOME_WHOLE_NUMBER)); 720 EXPECT_EQ(string16(), p.GetInfo(PHONE_HOME_WHOLE_NUMBER));
783 } 721 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_profile.cc ('k') | chrome/browser/autofill/credit_card.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698