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

Side by Side Diff: chrome/browser/prefs/tracked/tracked_preferences_migration_unittest.cc

Issue 599463002: Use base::StringPairs where appropriate from src/chrome/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing nit Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/prefs/tracked/tracked_preferences_migration.h" 5 #include "chrome/browser/prefs/tracked/tracked_preferences_migration.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 // There is no pending cleanup task for the modern hash stores. 524 // There is no pending cleanup task for the modern hash stores.
525 EXPECT_FALSE( 525 EXPECT_FALSE(
526 WasOnSuccessfulWriteCallbackRegistered(MOCK_UNPROTECTED_PREF_STORE)); 526 WasOnSuccessfulWriteCallbackRegistered(MOCK_UNPROTECTED_PREF_STORE));
527 EXPECT_FALSE( 527 EXPECT_FALSE(
528 WasOnSuccessfulWriteCallbackRegistered(MOCK_PROTECTED_PREF_STORE)); 528 WasOnSuccessfulWriteCallbackRegistered(MOCK_PROTECTED_PREF_STORE));
529 529
530 // Both stores were modified as hashes were moved from Local State. 530 // Both stores were modified as hashes were moved from Local State.
531 EXPECT_TRUE(StoreModifiedByMigration(MOCK_UNPROTECTED_PREF_STORE)); 531 EXPECT_TRUE(StoreModifiedByMigration(MOCK_UNPROTECTED_PREF_STORE));
532 EXPECT_TRUE(StoreModifiedByMigration(MOCK_PROTECTED_PREF_STORE)); 532 EXPECT_TRUE(StoreModifiedByMigration(MOCK_PROTECTED_PREF_STORE));
533 533
534 std::vector<std::pair<std::string, std::string> > expected_unprotected_values; 534 base::StringPairs expected_unprotected_values;
535 expected_unprotected_values.push_back( 535 expected_unprotected_values.push_back(
536 std::make_pair(kUnprotectedPref, kUnprotectedPrefValue)); 536 std::make_pair(kUnprotectedPref, kUnprotectedPrefValue));
537 VerifyValuesStored(MOCK_UNPROTECTED_PREF_STORE, expected_unprotected_values); 537 VerifyValuesStored(MOCK_UNPROTECTED_PREF_STORE, expected_unprotected_values);
538 538
539 std::vector<std::pair<std::string, std::string> > expected_protected_values; 539 base::StringPairs expected_protected_values;
540 expected_protected_values.push_back( 540 expected_protected_values.push_back(
541 std::make_pair(kProtectedPref, kProtectedPrefValue)); 541 std::make_pair(kProtectedPref, kProtectedPrefValue));
542 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values); 542 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values);
543 543
544 EXPECT_TRUE(ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kUnprotectedPref)); 544 EXPECT_TRUE(ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kUnprotectedPref));
545 EXPECT_FALSE(ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kProtectedPref)); 545 EXPECT_FALSE(ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kProtectedPref));
546 546
547 EXPECT_TRUE(ContainsHash(MOCK_PROTECTED_PREF_STORE, kProtectedPref)); 547 EXPECT_TRUE(ContainsHash(MOCK_PROTECTED_PREF_STORE, kProtectedPref));
548 EXPECT_FALSE(ContainsHash(MOCK_PROTECTED_PREF_STORE, kUnprotectedPref)); 548 EXPECT_FALSE(ContainsHash(MOCK_PROTECTED_PREF_STORE, kUnprotectedPref));
549 549
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 EXPECT_TRUE(ContainsLegacyHash(kProtectedPref)); 605 EXPECT_TRUE(ContainsLegacyHash(kProtectedPref));
606 EXPECT_TRUE(ContainsLegacyHash(kPreviouslyProtectedPref)); 606 EXPECT_TRUE(ContainsLegacyHash(kPreviouslyProtectedPref));
607 607
608 // Perform a first-pass migration. 608 // Perform a first-pass migration.
609 HandPrefsToMigrator(MOCK_UNPROTECTED_PREF_STORE); 609 HandPrefsToMigrator(MOCK_UNPROTECTED_PREF_STORE);
610 HandPrefsToMigrator(MOCK_PROTECTED_PREF_STORE); 610 HandPrefsToMigrator(MOCK_PROTECTED_PREF_STORE);
611 EXPECT_TRUE(MigrationCompleted()); 611 EXPECT_TRUE(MigrationCompleted());
612 612
613 // All values should have been moved to their preferred locations, including 613 // All values should have been moved to their preferred locations, including
614 // MACs. 614 // MACs.
615 std::vector<std::pair<std::string, std::string> > expected_unprotected_values; 615 base::StringPairs expected_unprotected_values;
616 expected_unprotected_values.push_back( 616 expected_unprotected_values.push_back(
617 std::make_pair(kUnprotectedPref, kUnprotectedPrefValue)); 617 std::make_pair(kUnprotectedPref, kUnprotectedPrefValue));
618 expected_unprotected_values.push_back( 618 expected_unprotected_values.push_back(
619 std::make_pair(kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue)); 619 std::make_pair(kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue));
620 std::vector<std::pair<std::string, std::string> > expected_protected_values; 620 base::StringPairs expected_protected_values;
621 expected_protected_values.push_back( 621 expected_protected_values.push_back(
622 std::make_pair(kProtectedPref, kProtectedPrefValue)); 622 std::make_pair(kProtectedPref, kProtectedPrefValue));
623 expected_protected_values.push_back(std::make_pair( 623 expected_protected_values.push_back(std::make_pair(
624 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue)); 624 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue));
625 625
626 VerifyValuesStored(MOCK_UNPROTECTED_PREF_STORE, expected_unprotected_values); 626 VerifyValuesStored(MOCK_UNPROTECTED_PREF_STORE, expected_unprotected_values);
627 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values); 627 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values);
628 628
629 EXPECT_TRUE(ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kUnprotectedPref)); 629 EXPECT_TRUE(ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kUnprotectedPref));
630 EXPECT_TRUE( 630 EXPECT_TRUE(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 EXPECT_TRUE( 731 EXPECT_TRUE(
732 WasOnSuccessfulWriteCallbackRegistered(MOCK_UNPROTECTED_PREF_STORE)); 732 WasOnSuccessfulWriteCallbackRegistered(MOCK_UNPROTECTED_PREF_STORE));
733 EXPECT_TRUE( 733 EXPECT_TRUE(
734 WasOnSuccessfulWriteCallbackRegistered(MOCK_PROTECTED_PREF_STORE)); 734 WasOnSuccessfulWriteCallbackRegistered(MOCK_PROTECTED_PREF_STORE));
735 EXPECT_TRUE(StoreModifiedByMigration(MOCK_UNPROTECTED_PREF_STORE)); 735 EXPECT_TRUE(StoreModifiedByMigration(MOCK_UNPROTECTED_PREF_STORE));
736 EXPECT_TRUE(StoreModifiedByMigration(MOCK_PROTECTED_PREF_STORE)); 736 EXPECT_TRUE(StoreModifiedByMigration(MOCK_PROTECTED_PREF_STORE));
737 737
738 // Values should have been migrated to their store, but migrated values should 738 // Values should have been migrated to their store, but migrated values should
739 // still remain in the source store until cleanup tasks are later invoked. 739 // still remain in the source store until cleanup tasks are later invoked.
740 { 740 {
741 std::vector<std::pair<std::string, std::string> > 741 base::StringPairs expected_unprotected_values;
742 expected_unprotected_values;
743 expected_unprotected_values.push_back(std::make_pair( 742 expected_unprotected_values.push_back(std::make_pair(
744 kUnprotectedPref, kUnprotectedPrefValue)); 743 kUnprotectedPref, kUnprotectedPrefValue));
745 expected_unprotected_values.push_back(std::make_pair( 744 expected_unprotected_values.push_back(std::make_pair(
746 kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue)); 745 kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue));
747 expected_unprotected_values.push_back(std::make_pair( 746 expected_unprotected_values.push_back(std::make_pair(
748 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue)); 747 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue));
749 VerifyValuesStored(MOCK_UNPROTECTED_PREF_STORE, 748 VerifyValuesStored(MOCK_UNPROTECTED_PREF_STORE,
750 expected_unprotected_values); 749 expected_unprotected_values);
751 750
752 std::vector<std::pair<std::string, std::string> > expected_protected_values; 751 base::StringPairs expected_protected_values;
753 expected_protected_values.push_back(std::make_pair( 752 expected_protected_values.push_back(std::make_pair(
754 kProtectedPref, kProtectedPrefValue)); 753 kProtectedPref, kProtectedPrefValue));
755 expected_protected_values.push_back(std::make_pair( 754 expected_protected_values.push_back(std::make_pair(
756 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue)); 755 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue));
757 expected_unprotected_values.push_back(std::make_pair( 756 expected_unprotected_values.push_back(std::make_pair(
758 kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue)); 757 kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue));
759 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values); 758 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values);
760 759
761 EXPECT_TRUE(ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kUnprotectedPref)); 760 EXPECT_TRUE(ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kUnprotectedPref));
762 EXPECT_TRUE( 761 EXPECT_TRUE(
763 ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kPreviouslyUnprotectedPref)); 762 ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kPreviouslyUnprotectedPref));
764 EXPECT_FALSE(ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kProtectedPref)); 763 EXPECT_FALSE(ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kProtectedPref));
765 EXPECT_TRUE( 764 EXPECT_TRUE(
766 ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kPreviouslyProtectedPref)); 765 ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kPreviouslyProtectedPref));
767 766
768 EXPECT_FALSE(ContainsHash(MOCK_PROTECTED_PREF_STORE, kUnprotectedPref)); 767 EXPECT_FALSE(ContainsHash(MOCK_PROTECTED_PREF_STORE, kUnprotectedPref));
769 EXPECT_TRUE( 768 EXPECT_TRUE(
770 ContainsHash(MOCK_PROTECTED_PREF_STORE, kPreviouslyUnprotectedPref)); 769 ContainsHash(MOCK_PROTECTED_PREF_STORE, kPreviouslyUnprotectedPref));
771 EXPECT_TRUE(ContainsHash(MOCK_PROTECTED_PREF_STORE, kProtectedPref)); 770 EXPECT_TRUE(ContainsHash(MOCK_PROTECTED_PREF_STORE, kProtectedPref));
772 EXPECT_TRUE( 771 EXPECT_TRUE(
773 ContainsHash(MOCK_PROTECTED_PREF_STORE, kPreviouslyProtectedPref)); 772 ContainsHash(MOCK_PROTECTED_PREF_STORE, kPreviouslyProtectedPref));
774 } 773 }
775 774
776 // A successful write of the protected pref store should result in a clean up 775 // A successful write of the protected pref store should result in a clean up
777 // of the unprotected store. 776 // of the unprotected store.
778 SimulateSuccessfulWrite(MOCK_PROTECTED_PREF_STORE); 777 SimulateSuccessfulWrite(MOCK_PROTECTED_PREF_STORE);
779 778
780 { 779 {
781 std::vector<std::pair<std::string, std::string> > 780 base::StringPairs expected_unprotected_values;
782 expected_unprotected_values;
783 expected_unprotected_values.push_back(std::make_pair( 781 expected_unprotected_values.push_back(std::make_pair(
784 kUnprotectedPref, kUnprotectedPrefValue)); 782 kUnprotectedPref, kUnprotectedPrefValue));
785 expected_unprotected_values.push_back(std::make_pair( 783 expected_unprotected_values.push_back(std::make_pair(
786 kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue)); 784 kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue));
787 VerifyValuesStored(MOCK_UNPROTECTED_PREF_STORE, 785 VerifyValuesStored(MOCK_UNPROTECTED_PREF_STORE,
788 expected_unprotected_values); 786 expected_unprotected_values);
789 787
790 std::vector<std::pair<std::string, std::string> > expected_protected_values; 788 base::StringPairs expected_protected_values;
791 expected_protected_values.push_back(std::make_pair( 789 expected_protected_values.push_back(std::make_pair(
792 kProtectedPref, kProtectedPrefValue)); 790 kProtectedPref, kProtectedPrefValue));
793 expected_protected_values.push_back(std::make_pair( 791 expected_protected_values.push_back(std::make_pair(
794 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue)); 792 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue));
795 expected_unprotected_values.push_back(std::make_pair( 793 expected_unprotected_values.push_back(std::make_pair(
796 kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue)); 794 kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue));
797 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values); 795 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values);
798 } 796 }
799 797
800 SimulateSuccessfulWrite(MOCK_UNPROTECTED_PREF_STORE); 798 SimulateSuccessfulWrite(MOCK_UNPROTECTED_PREF_STORE);
801 799
802 { 800 {
803 std::vector<std::pair<std::string, std::string> > 801 base::StringPairs expected_unprotected_values;
804 expected_unprotected_values;
805 expected_unprotected_values.push_back(std::make_pair( 802 expected_unprotected_values.push_back(std::make_pair(
806 kUnprotectedPref, kUnprotectedPrefValue)); 803 kUnprotectedPref, kUnprotectedPrefValue));
807 expected_unprotected_values.push_back(std::make_pair( 804 expected_unprotected_values.push_back(std::make_pair(
808 kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue)); 805 kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue));
809 VerifyValuesStored(MOCK_UNPROTECTED_PREF_STORE, 806 VerifyValuesStored(MOCK_UNPROTECTED_PREF_STORE,
810 expected_unprotected_values); 807 expected_unprotected_values);
811 808
812 std::vector<std::pair<std::string, std::string> > expected_protected_values; 809 base::StringPairs expected_protected_values;
813 expected_protected_values.push_back(std::make_pair( 810 expected_protected_values.push_back(std::make_pair(
814 kProtectedPref, kProtectedPrefValue)); 811 kProtectedPref, kProtectedPrefValue));
815 expected_protected_values.push_back(std::make_pair( 812 expected_protected_values.push_back(std::make_pair(
816 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue)); 813 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue));
817 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values); 814 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values);
818 } 815 }
819 816
820 // Hashes are not cleaned up yet. 817 // Hashes are not cleaned up yet.
821 EXPECT_TRUE(ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kUnprotectedPref)); 818 EXPECT_TRUE(ContainsHash(MOCK_UNPROTECTED_PREF_STORE, kUnprotectedPref));
822 EXPECT_TRUE( 819 EXPECT_TRUE(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 EXPECT_FALSE( 883 EXPECT_FALSE(
887 WasOnSuccessfulWriteCallbackRegistered(MOCK_UNPROTECTED_PREF_STORE)); 884 WasOnSuccessfulWriteCallbackRegistered(MOCK_UNPROTECTED_PREF_STORE));
888 EXPECT_FALSE( 885 EXPECT_FALSE(
889 WasOnSuccessfulWriteCallbackRegistered(MOCK_PROTECTED_PREF_STORE)); 886 WasOnSuccessfulWriteCallbackRegistered(MOCK_PROTECTED_PREF_STORE));
890 EXPECT_FALSE(StoreModifiedByMigration(MOCK_UNPROTECTED_PREF_STORE)); 887 EXPECT_FALSE(StoreModifiedByMigration(MOCK_UNPROTECTED_PREF_STORE));
891 EXPECT_FALSE(StoreModifiedByMigration(MOCK_PROTECTED_PREF_STORE)); 888 EXPECT_FALSE(StoreModifiedByMigration(MOCK_PROTECTED_PREF_STORE));
892 889
893 // Cleanup should happen synchronously if the values were already present in 890 // Cleanup should happen synchronously if the values were already present in
894 // their destination stores. 891 // their destination stores.
895 { 892 {
896 std::vector<std::pair<std::string, std::string> > 893 base::StringPairs expected_unprotected_values;
897 expected_unprotected_values;
898 expected_unprotected_values.push_back(std::make_pair( 894 expected_unprotected_values.push_back(std::make_pair(
899 kUnprotectedPref, kUnprotectedPrefValue)); 895 kUnprotectedPref, kUnprotectedPrefValue));
900 expected_unprotected_values.push_back(std::make_pair( 896 expected_unprotected_values.push_back(std::make_pair(
901 kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue)); 897 kPreviouslyProtectedPref, kPreviouslyProtectedPrefValue));
902 VerifyValuesStored(MOCK_UNPROTECTED_PREF_STORE, 898 VerifyValuesStored(MOCK_UNPROTECTED_PREF_STORE,
903 expected_unprotected_values); 899 expected_unprotected_values);
904 900
905 std::vector<std::pair<std::string, std::string> > expected_protected_values; 901 base::StringPairs expected_protected_values;
906 expected_protected_values.push_back(std::make_pair( 902 expected_protected_values.push_back(std::make_pair(
907 kProtectedPref, kProtectedPrefValue)); 903 kProtectedPref, kProtectedPrefValue));
908 expected_protected_values.push_back(std::make_pair( 904 expected_protected_values.push_back(std::make_pair(
909 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue)); 905 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue));
910 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values); 906 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values);
911 } 907 }
912 } 908 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698