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

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

Issue 5521005: AutoFillProfile: Don't clobber data on self-assignment (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar bettar 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') | chrome/browser/autofill/credit_card.cc » ('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) 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, AssignmentOperator){
499 AutoFillProfile a, b;
500
501 // Result of assignment should be logically equal to the original profile.
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 b = a;
507 EXPECT_TRUE(a == b);
508
509 // Assignment to self should not change the profile value.
510 a = a;
511 EXPECT_TRUE(a == b);
512 }
513
498 TEST(AutoFillProfileTest, Compare) { 514 TEST(AutoFillProfileTest, Compare) {
499 AutoFillProfile a, b; 515 AutoFillProfile a, b;
500 516
501 // Empty profiles are the same. 517 // Empty profiles are the same.
502 EXPECT_EQ(0, a.Compare(b)); 518 EXPECT_EQ(0, a.Compare(b));
503 519
504 // GUIDs don't count. 520 // GUIDs don't count.
505 a.set_guid(guid::GenerateGUID()); 521 a.set_guid(guid::GenerateGUID());
506 b.set_guid(guid::GenerateGUID()); 522 b.set_guid(guid::GenerateGUID());
507 EXPECT_EQ(0, a.Compare(b)); 523 EXPECT_EQ(0, a.Compare(b));
508 524
509 // Different values produce non-zero results. 525 // Different values produce non-zero results.
510 autofill_test::SetProfileInfo(&a, "label1", "Jimmy", NULL, NULL, NULL, 526 autofill_test::SetProfileInfo(&a, "label1", "Jimmy", NULL, NULL, NULL,
511 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); 527 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
512 autofill_test::SetProfileInfo(&b, "label1", "Ringo", NULL, NULL, NULL, 528 autofill_test::SetProfileInfo(&b, "label1", "Ringo", NULL, NULL, NULL,
513 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); 529 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
514 EXPECT_GT(0, a.Compare(b)); 530 EXPECT_GT(0, a.Compare(b));
515 EXPECT_LT(0, b.Compare(a)); 531 EXPECT_LT(0, b.Compare(a));
516 } 532 }
517 533
518 } // namespace 534 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_profile.cc ('k') | chrome/browser/autofill/credit_card.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698