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 <set> | 5 #include <set> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 | 562 |
563 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, | 563 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, |
564 GetAllAutoFillProfiles(pdm1_))); | 564 GetAllAutoFillProfiles(pdm1_))); |
565 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, | 565 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, |
566 GetAllAutoFillProfiles(pdm2_))); | 566 GetAllAutoFillProfiles(pdm2_))); |
567 | 567 |
568 // Client2 adds a profile. | 568 // Client2 adds a profile. |
569 expected_profiles.push_back(new AutoFillProfile(string16(), 0)); | 569 expected_profiles.push_back(new AutoFillProfile(string16(), 0)); |
570 FillProfile(MARION, expected_profiles[1]); | 570 FillProfile(MARION, expected_profiles[1]); |
571 AddProfile(pdm2_, *expected_profiles[1]); | 571 AddProfile(pdm2_, *expected_profiles[1]); |
572 EXPECT_TRUE(client1()->AwaitMutualSyncCycleCompletion(client2())); | 572 EXPECT_TRUE(client2()->AwaitMutualSyncCycleCompletion(client1())); |
573 | 573 |
574 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, | 574 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, |
575 GetAllAutoFillProfiles(pdm1_))); | 575 GetAllAutoFillProfiles(pdm1_))); |
576 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, | 576 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, |
577 GetAllAutoFillProfiles(pdm2_))); | 577 GetAllAutoFillProfiles(pdm2_))); |
578 | 578 |
579 // Client1 adds a conflicting profile. | 579 // Client1 adds a conflicting profile. |
580 expected_profiles.push_back(new AutoFillProfile(string16(), 0)); | 580 expected_profiles.push_back(new AutoFillProfile(string16(), 0)); |
581 FillProfile(MARION, expected_profiles[2]); | 581 FillProfile(MARION, expected_profiles[2]); |
582 AddProfile(pdm1_, *expected_profiles[2]); | 582 AddProfile(pdm1_, *expected_profiles[2]); |
583 EXPECT_TRUE(client1()->AwaitMutualSyncCycleCompletion(client2())); | 583 EXPECT_TRUE(client1()->AwaitMutualSyncCycleCompletion(client2())); |
584 | 584 |
585 // The conflicting profile's label will be made unique. | 585 // The conflicting profile's label will be made unique. |
586 expected_profiles[2]->set_label(ASCIIToUTF16("Billing2")); | 586 expected_profiles[2]->set_label(ASCIIToUTF16("Billing2")); |
587 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, | 587 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, |
588 GetAllAutoFillProfiles(pdm1_))); | 588 GetAllAutoFillProfiles(pdm1_))); |
589 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, | 589 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, |
590 GetAllAutoFillProfiles(pdm2_))); | 590 GetAllAutoFillProfiles(pdm2_))); |
591 | 591 |
592 // Client2 removes a profile. | 592 // Client2 removes a profile. |
593 delete expected_profiles.front(); | 593 delete expected_profiles.front(); |
594 expected_profiles.erase(expected_profiles.begin()); | 594 expected_profiles.erase(expected_profiles.begin()); |
595 RemoveProfile(pdm2_, ASCIIToUTF16("Shipping")); | 595 RemoveProfile(pdm2_, ASCIIToUTF16("Shipping")); |
596 EXPECT_TRUE(client1()->AwaitMutualSyncCycleCompletion(client2())); | 596 EXPECT_TRUE(client2()->AwaitMutualSyncCycleCompletion(client1())); |
597 | 597 |
598 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, | 598 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, |
599 GetAllAutoFillProfiles(pdm1_))); | 599 GetAllAutoFillProfiles(pdm1_))); |
600 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, | 600 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, |
601 GetAllAutoFillProfiles(pdm2_))); | 601 GetAllAutoFillProfiles(pdm2_))); |
602 | 602 |
603 // Client1 updates a profile. | 603 // Client1 updates a profile. |
604 expected_profiles[0]->SetInfo(AutoFillType(NAME_FIRST), | 604 expected_profiles[0]->SetInfo(AutoFillType(NAME_FIRST), |
605 ASCIIToUTF16("Bart")); | 605 ASCIIToUTF16("Bart")); |
606 UpdateProfile(pdm1_, | 606 UpdateProfile(pdm1_, |
607 ASCIIToUTF16("Billing"), | 607 ASCIIToUTF16("Billing"), |
608 AutoFillType(NAME_FIRST), | 608 AutoFillType(NAME_FIRST), |
609 ASCIIToUTF16("Bart")); | 609 ASCIIToUTF16("Bart")); |
610 EXPECT_TRUE(client1()->AwaitMutualSyncCycleCompletion(client2())); | 610 EXPECT_TRUE(client1()->AwaitMutualSyncCycleCompletion(client2())); |
611 | 611 |
612 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, | 612 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, |
613 GetAllAutoFillProfiles(pdm1_))); | 613 GetAllAutoFillProfiles(pdm1_))); |
614 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, | 614 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, |
615 GetAllAutoFillProfiles(pdm2_))); | 615 GetAllAutoFillProfiles(pdm2_))); |
616 | 616 |
617 // Client2 removes everything. | 617 // Client2 removes everything. |
618 STLDeleteElements(&expected_profiles); | 618 STLDeleteElements(&expected_profiles); |
619 RemoveProfile(pdm2_, ASCIIToUTF16("Billing")); | 619 RemoveProfile(pdm2_, ASCIIToUTF16("Billing")); |
620 RemoveProfile(pdm2_, ASCIIToUTF16("Billing2")); | 620 RemoveProfile(pdm2_, ASCIIToUTF16("Billing2")); |
621 EXPECT_TRUE(client1()->AwaitMutualSyncCycleCompletion(client2())); | 621 EXPECT_TRUE(client2()->AwaitMutualSyncCycleCompletion(client1())); |
622 | 622 |
623 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, | 623 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, |
624 GetAllAutoFillProfiles(pdm1_))); | 624 GetAllAutoFillProfiles(pdm1_))); |
625 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, | 625 EXPECT_TRUE(CompareAutoFillProfiles(expected_profiles, |
626 GetAllAutoFillProfiles(pdm2_))); | 626 GetAllAutoFillProfiles(pdm2_))); |
627 | 627 |
628 Cleanup(); | 628 Cleanup(); |
629 } | 629 } |
OLD | NEW |