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

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

Issue 5608004: AutoFillProfile: don't replicate logic in Clone() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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') | no next file » | 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) 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/scoped_ptr.h" 6 #include "base/scoped_ptr.h"
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/autofill/autofill_common_test.h" 10 #include "chrome/browser/autofill/autofill_common_test.h"
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 488
489 AutoFillProfile expected_a; 489 AutoFillProfile expected_a;
490 autofill_test::SetProfileInfo(&expected_a, "label1", "Jimmy", NULL, "Madison", 490 autofill_test::SetProfileInfo(&expected_a, "label1", "Jimmy", NULL, "Madison",
491 "constitutionalist@gmail.com", "United States Government", "Monticello", 491 "constitutionalist@gmail.com", "United States Government", "Monticello",
492 NULL, "Charlottesville", "Virginia", "22902", NULL, "12134759123", 492 NULL, "Charlottesville", "Virginia", "22902", NULL, "12134759123",
493 "19384284720"); 493 "19384284720");
494 EXPECT_EQ(0, expected_a.Compare(*a)); 494 EXPECT_EQ(0, expected_a.Compare(*a));
495 EXPECT_EQ(0, expected_b.Compare(*b)); 495 EXPECT_EQ(0, expected_b.Compare(*b));
496 } 496 }
497 497
498 TEST(AutoFillProfileTest, Clone) {
499 AutoFillProfile a;
500
501 // Clone should be logically equal to the original.
502 autofill_test::SetProfileInfo(&a, "Billing", "Marion", "Mitchell", "Morrison",
503 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5",
504 "Hollywood", "CA", "91601", "US", "12345678910",
505 "01987654321");
506 scoped_ptr<AutoFillProfile> b(static_cast<AutoFillProfile*>(a.Clone()));
507 EXPECT_TRUE(a == *b);
508 }
509
498 TEST(AutoFillProfileTest, Compare) { 510 TEST(AutoFillProfileTest, Compare) {
499 AutoFillProfile a, b; 511 AutoFillProfile a, b;
500 512
501 // Empty profiles are the same. 513 // Empty profiles are the same.
502 EXPECT_EQ(0, a.Compare(b)); 514 EXPECT_EQ(0, a.Compare(b));
503 515
504 // GUIDs don't count. 516 // GUIDs don't count.
505 a.set_guid(guid::GenerateGUID()); 517 a.set_guid(guid::GenerateGUID());
506 b.set_guid(guid::GenerateGUID()); 518 b.set_guid(guid::GenerateGUID());
507 EXPECT_EQ(0, a.Compare(b)); 519 EXPECT_EQ(0, a.Compare(b));
508 520
509 // Different values produce non-zero results. 521 // Different values produce non-zero results.
510 autofill_test::SetProfileInfo(&a, "label1", "Jimmy", NULL, NULL, NULL, 522 autofill_test::SetProfileInfo(&a, "label1", "Jimmy", NULL, NULL, NULL,
511 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); 523 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
512 autofill_test::SetProfileInfo(&b, "label1", "Ringo", NULL, NULL, NULL, 524 autofill_test::SetProfileInfo(&b, "label1", "Ringo", NULL, NULL, NULL,
513 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); 525 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
514 EXPECT_GT(0, a.Compare(b)); 526 EXPECT_GT(0, a.Compare(b));
515 EXPECT_LT(0, b.Compare(a)); 527 EXPECT_LT(0, b.Compare(a));
516 } 528 }
517 529
518 } // namespace 530 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_profile.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698