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

Side by Side Diff: chrome/browser/password_manager/native_backend_kwallet_x_unittest.cc

Issue 2565173002: Remove ScopedVector from PasswordStoreX (Closed)
Patch Set: back_inserter, no =nullptr, drop autofill:: Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // legacy shared passwords in these tests, for testing the migration code. 130 // legacy shared passwords in these tests, for testing the migration code.
131 bool reject_local_folders_; 131 bool reject_local_folders_;
132 132
133 // No need to disallow copy and assign. This class is safe to copy and assign. 133 // No need to disallow copy and assign. This class is safe to copy and assign.
134 }; 134 };
135 135
136 // Runs |backend->GetAutofillableLogins(forms)| and expects that the return 136 // Runs |backend->GetAutofillableLogins(forms)| and expects that the return
137 // value is false. 137 // value is false.
138 void CheckGetAutofillableLoginsFails( 138 void CheckGetAutofillableLoginsFails(
139 PasswordStoreX::NativeBackend* backend, 139 PasswordStoreX::NativeBackend* backend,
140 ScopedVector<autofill::PasswordForm>* forms) { 140 std::vector<std::unique_ptr<PasswordForm>>* forms) {
141 EXPECT_FALSE(backend->GetAutofillableLogins(forms)); 141 EXPECT_FALSE(backend->GetAutofillableLogins(forms));
142 } 142 }
143 143
144 void CheckTrue(bool result) { 144 void CheckTrue(bool result) {
145 EXPECT_TRUE(result); 145 EXPECT_TRUE(result);
146 } 146 }
147 147
148 void WriteHTMLAttributes(const PasswordForm& form, base::Pickle* pickle) { 148 void WriteHTMLAttributes(const PasswordForm& form, base::Pickle* pickle) {
149 pickle->WriteInt(form.scheme); 149 pickle->WriteInt(form.scheme);
150 pickle->WriteString(form.origin.spec()); 150 pickle->WriteString(form.origin.spec());
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 std::vector<std::string> entries; 656 std::vector<std::string> entries;
657 EXPECT_TRUE(wallet_.entryList(folder, &entries)); 657 EXPECT_TRUE(wallet_.entryList(folder, &entries));
658 EXPECT_EQ(sorted_expected.size(), entries.size()); 658 EXPECT_EQ(sorted_expected.size(), entries.size());
659 std::sort(entries.begin(), entries.end()); 659 std::sort(entries.begin(), entries.end());
660 for (size_t i = 0; i < entries.size() && i < sorted_expected.size(); ++i) { 660 for (size_t i = 0; i < entries.size() && i < sorted_expected.size(); ++i) {
661 EXPECT_EQ(sorted_expected[i].first, entries[i]); 661 EXPECT_EQ(sorted_expected[i].first, entries[i]);
662 TestKWallet::Blob value; 662 TestKWallet::Blob value;
663 EXPECT_TRUE(wallet_.readEntry(folder, entries[i], &value)); 663 EXPECT_TRUE(wallet_.readEntry(folder, entries[i], &value));
664 base::Pickle pickle(reinterpret_cast<const char*>(value.data()), 664 base::Pickle pickle(reinterpret_cast<const char*>(value.data()),
665 value.size()); 665 value.size());
666 ScopedVector<autofill::PasswordForm> forms = 666 std::vector<std::unique_ptr<PasswordForm>> forms =
667 NativeBackendKWalletStub::DeserializeValue(entries[i], pickle); 667 NativeBackendKWalletStub::DeserializeValue(entries[i], pickle);
668 const std::vector<const PasswordForm*>& expect = sorted_expected[i].second; 668 const std::vector<const PasswordForm*>& expect = sorted_expected[i].second;
669 EXPECT_EQ(expect.size(), forms.size()); 669 EXPECT_EQ(expect.size(), forms.size());
670 for (size_t j = 0; j < forms.size() && j < expect.size(); ++j) 670 for (size_t j = 0; j < forms.size() && j < expect.size(); ++j)
671 CheckPasswordForm(*expect[j], *forms[j], true); 671 CheckPasswordForm(*expect[j], *forms[j], true);
672 } 672 }
673 } 673 }
674 674
675 TEST_P(NativeBackendKWalletTest, NotEnabled) { 675 TEST_P(NativeBackendKWalletTest, NotEnabled) {
676 NativeBackendKWalletStub kwallet(42, desktop_env_); 676 NativeBackendKWalletStub kwallet(42, desktop_env_);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 772
773 TEST_P(NativeBackendKWalletTest, BasicListLogins) { 773 TEST_P(NativeBackendKWalletTest, BasicListLogins) {
774 NativeBackendKWalletStub backend(42, desktop_env_); 774 NativeBackendKWalletStub backend(42, desktop_env_);
775 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); 775 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
776 776
777 BrowserThread::PostTask( 777 BrowserThread::PostTask(
778 BrowserThread::DB, FROM_HERE, 778 BrowserThread::DB, FROM_HERE,
779 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 779 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
780 base::Unretained(&backend), form_google_)); 780 base::Unretained(&backend), form_google_));
781 781
782 ScopedVector<autofill::PasswordForm> form_list; 782 std::vector<std::unique_ptr<PasswordForm>> form_list;
783 BrowserThread::PostTaskAndReplyWithResult( 783 BrowserThread::PostTaskAndReplyWithResult(
784 BrowserThread::DB, FROM_HERE, 784 BrowserThread::DB, FROM_HERE,
785 base::Bind(&NativeBackendKWalletStub::GetAutofillableLogins, 785 base::Bind(&NativeBackendKWalletStub::GetAutofillableLogins,
786 base::Unretained(&backend), &form_list), 786 base::Unretained(&backend), &form_list),
787 base::Bind(&CheckTrue)); 787 base::Bind(&CheckTrue));
788 788
789 RunDBThread(); 789 RunDBThread();
790 790
791 // Quick check that we got something back. 791 // Quick check that we got something back.
792 EXPECT_EQ(1u, form_list.size()); 792 EXPECT_EQ(1u, form_list.size());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 // Attempt to remove a login that doesn't exist. 892 // Attempt to remove a login that doesn't exist.
893 PasswordStoreChangeList changes; 893 PasswordStoreChangeList changes;
894 BrowserThread::PostTaskAndReplyWithResult( 894 BrowserThread::PostTaskAndReplyWithResult(
895 BrowserThread::DB, FROM_HERE, 895 BrowserThread::DB, FROM_HERE,
896 base::Bind(&NativeBackendKWalletStub::RemoveLogin, 896 base::Bind(&NativeBackendKWalletStub::RemoveLogin,
897 base::Unretained(&backend), form_isc_, &changes), 897 base::Unretained(&backend), form_isc_, &changes),
898 base::Bind(&CheckPasswordChangesWithResult, 898 base::Bind(&CheckPasswordChangesWithResult,
899 base::Owned(new PasswordStoreChangeList), &changes)); 899 base::Owned(new PasswordStoreChangeList), &changes));
900 900
901 // Make sure we can still get the first form back. 901 // Make sure we can still get the first form back.
902 ScopedVector<autofill::PasswordForm> form_list; 902 std::vector<std::unique_ptr<PasswordForm>> form_list;
903 BrowserThread::PostTaskAndReplyWithResult( 903 BrowserThread::PostTaskAndReplyWithResult(
904 BrowserThread::DB, FROM_HERE, 904 BrowserThread::DB, FROM_HERE,
905 base::Bind(&NativeBackendKWalletStub::GetAutofillableLogins, 905 base::Bind(&NativeBackendKWalletStub::GetAutofillableLogins,
906 base::Unretained(&backend), &form_list), 906 base::Unretained(&backend), &form_list),
907 base::Bind(&CheckTrue)); 907 base::Bind(&CheckTrue));
908 908
909 RunDBThread(); 909 RunDBThread();
910 910
911 // Quick check that we got something back. 911 // Quick check that we got something back.
912 EXPECT_EQ(1u, form_list.size()); 912 EXPECT_EQ(1u, form_list.size());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 password_manager::PasswordStore::FormDigest observed_android_form( 968 password_manager::PasswordStore::FormDigest observed_android_form(
969 saved_android_form); 969 saved_android_form);
970 BrowserThread::PostTaskAndReplyWithResult( 970 BrowserThread::PostTaskAndReplyWithResult(
971 BrowserThread::DB, FROM_HERE, 971 BrowserThread::DB, FROM_HERE,
972 base::Bind(&NativeBackendKWalletStub::AddLogin, 972 base::Bind(&NativeBackendKWalletStub::AddLogin,
973 base::Unretained(&backend), saved_android_form), 973 base::Unretained(&backend), saved_android_form),
974 base::Bind(&CheckPasswordChanges, 974 base::Bind(&CheckPasswordChanges,
975 PasswordStoreChangeList(1, PasswordStoreChange( 975 PasswordStoreChangeList(1, PasswordStoreChange(
976 PasswordStoreChange::ADD, saved_android_form)))); 976 PasswordStoreChange::ADD, saved_android_form))));
977 977
978 ScopedVector<autofill::PasswordForm> form_list; 978 std::vector<std::unique_ptr<PasswordForm>> form_list;
979 BrowserThread::PostTaskAndReplyWithResult( 979 BrowserThread::PostTaskAndReplyWithResult(
980 BrowserThread::DB, FROM_HERE, 980 BrowserThread::DB, FROM_HERE,
981 base::Bind(&NativeBackendKWalletStub::GetLogins, 981 base::Bind(&NativeBackendKWalletStub::GetLogins,
982 base::Unretained(&backend), observed_android_form, &form_list), 982 base::Unretained(&backend), observed_android_form, &form_list),
983 base::Bind(&CheckTrue)); 983 base::Bind(&CheckTrue));
984 984
985 RunDBThread(); 985 RunDBThread();
986 986
987 EXPECT_EQ(1u, form_list.size()); 987 EXPECT_EQ(1u, form_list.size());
988 988
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 ASSERT_TRUE(wallet_.readEntry("Chrome Form Data (42)", 1076 ASSERT_TRUE(wallet_.readEntry("Chrome Form Data (42)",
1077 form_google_.signon_realm, &value)); 1077 form_google_.signon_realm, &value));
1078 TestKWallet::Blob sample(reinterpret_cast<const uint8_t*>(unique_string)); 1078 TestKWallet::Blob sample(reinterpret_cast<const uint8_t*>(unique_string));
1079 size_t position = value.find(sample); 1079 size_t position = value.find(sample);
1080 ASSERT_NE(TestKWallet::Blob::npos, position); 1080 ASSERT_NE(TestKWallet::Blob::npos, position);
1081 value.replace(position, sample.length(), 1081 value.replace(position, sample.length(),
1082 reinterpret_cast<const uint8_t*>(unique_string_replacement)); 1082 reinterpret_cast<const uint8_t*>(unique_string_replacement));
1083 wallet_.writeEntry("Chrome Form Data (42)", form_google_.signon_realm, value); 1083 wallet_.writeEntry("Chrome Form Data (42)", form_google_.signon_realm, value);
1084 1084
1085 // Now test that GetAutofillableLogins returns only one form. 1085 // Now test that GetAutofillableLogins returns only one form.
1086 ScopedVector<autofill::PasswordForm> form_list; 1086 std::vector<std::unique_ptr<PasswordForm>> form_list;
1087 BrowserThread::PostTaskAndReplyWithResult( 1087 BrowserThread::PostTaskAndReplyWithResult(
1088 BrowserThread::DB, FROM_HERE, 1088 BrowserThread::DB, FROM_HERE,
1089 base::Bind(&NativeBackendKWalletStub::GetAutofillableLogins, 1089 base::Bind(&NativeBackendKWalletStub::GetAutofillableLogins,
1090 base::Unretained(&backend), &form_list), 1090 base::Unretained(&backend), &form_list),
1091 base::Bind(&CheckTrue)); 1091 base::Bind(&CheckTrue));
1092 RunDBThread(); 1092 RunDBThread();
1093 1093
1094 EXPECT_EQ(1u, form_list.size()); 1094 EXPECT_EQ(1u, form_list.size());
1095 EXPECT_EQ(form_google_, *form_list[0]); 1095 EXPECT_EQ(form_google_, *form_list[0]);
1096 1096
(...skipping 14 matching lines...) Expand all
1111 // Store some non-blacklisted logins to be potentially returned. 1111 // Store some non-blacklisted logins to be potentially returned.
1112 BrowserThread::PostTaskAndReplyWithResult( 1112 BrowserThread::PostTaskAndReplyWithResult(
1113 BrowserThread::DB, FROM_HERE, 1113 BrowserThread::DB, FROM_HERE,
1114 base::Bind(&NativeBackendKWalletStub::AddLogin, 1114 base::Bind(&NativeBackendKWalletStub::AddLogin,
1115 base::Unretained(&backend), form_google_), 1115 base::Unretained(&backend), form_google_),
1116 base::Bind(&CheckPasswordChanges, 1116 base::Bind(&CheckPasswordChanges,
1117 PasswordStoreChangeList(1, PasswordStoreChange( 1117 PasswordStoreChangeList(1, PasswordStoreChange(
1118 PasswordStoreChange::ADD, form_google_)))); 1118 PasswordStoreChange::ADD, form_google_))));
1119 1119
1120 // Verify that nothing is in fact returned, because KWallet fails to respond. 1120 // Verify that nothing is in fact returned, because KWallet fails to respond.
1121 ScopedVector<autofill::PasswordForm> form_list; 1121 std::vector<std::unique_ptr<PasswordForm>> form_list;
1122 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, 1122 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
1123 base::Bind(&CheckGetAutofillableLoginsFails, 1123 base::Bind(&CheckGetAutofillableLoginsFails,
1124 base::Unretained(&backend), &form_list)); 1124 base::Unretained(&backend), &form_list));
1125 RunDBThread(); 1125 RunDBThread();
1126 EXPECT_EQ(0u, form_list.size()); 1126 EXPECT_EQ(0u, form_list.size());
1127 } 1127 }
1128 1128
1129 TEST_P(NativeBackendKWalletTest, GetAllLogins) { 1129 TEST_P(NativeBackendKWalletTest, GetAllLogins) {
1130 NativeBackendKWalletStub backend(42, desktop_env_); 1130 NativeBackendKWalletStub backend(42, desktop_env_);
1131 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); 1131 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
1132 1132
1133 BrowserThread::PostTask( 1133 BrowserThread::PostTask(
1134 BrowserThread::DB, FROM_HERE, 1134 BrowserThread::DB, FROM_HERE,
1135 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 1135 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
1136 base::Unretained(&backend), form_google_)); 1136 base::Unretained(&backend), form_google_));
1137 BrowserThread::PostTask( 1137 BrowserThread::PostTask(
1138 BrowserThread::DB, FROM_HERE, 1138 BrowserThread::DB, FROM_HERE,
1139 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 1139 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
1140 base::Unretained(&backend), form_isc_)); 1140 base::Unretained(&backend), form_isc_));
1141 1141
1142 ScopedVector<autofill::PasswordForm> form_list; 1142 std::vector<std::unique_ptr<PasswordForm>> form_list;
1143 BrowserThread::PostTaskAndReplyWithResult( 1143 BrowserThread::PostTaskAndReplyWithResult(
1144 BrowserThread::DB, FROM_HERE, 1144 BrowserThread::DB, FROM_HERE,
1145 base::Bind(&NativeBackendKWalletStub::GetAllLogins, 1145 base::Bind(&NativeBackendKWalletStub::GetAllLogins,
1146 base::Unretained(&backend), &form_list), 1146 base::Unretained(&backend), &form_list),
1147 base::Bind(&CheckTrue)); 1147 base::Bind(&CheckTrue));
1148 1148
1149 RunDBThread(); 1149 RunDBThread();
1150 1150
1151 EXPECT_EQ(2u, form_list.size()); 1151 EXPECT_EQ(2u, form_list.size());
1152 EXPECT_THAT(form_list, 1152 EXPECT_THAT(form_list,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 1240
1241 void NativeBackendKWalletPickleTest::CheckVersion9Pickle() { 1241 void NativeBackendKWalletPickleTest::CheckVersion9Pickle() {
1242 // Pickle 9+ dropped an old flag in the middle of PasswordForm. This test 1242 // Pickle 9+ dropped an old flag in the middle of PasswordForm. This test
1243 // makes sure that the attributes after the dropped flag are deserialised 1243 // makes sure that the attributes after the dropped flag are deserialised
1244 // correctly. 1244 // correctly.
1245 base::Pickle pickle; 1245 base::Pickle pickle;
1246 PasswordForm default_values; 1246 PasswordForm default_values;
1247 PasswordForm form = form_google_; 1247 PasswordForm form = form_google_;
1248 1248
1249 CreateVersion1PlusPickle(form, &pickle, 9, 9); 1249 CreateVersion1PlusPickle(form, &pickle, 9, 9);
1250 ScopedVector<PasswordForm> form_list = 1250 std::vector<std::unique_ptr<PasswordForm>> form_list =
1251 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle); 1251 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle);
1252 EXPECT_EQ(1u, form_list.size()); 1252 EXPECT_EQ(1u, form_list.size());
1253 if (form_list.size() > 0) 1253 if (form_list.size() > 0)
1254 CheckPasswordForm(form, *form_list[0], true); 1254 CheckPasswordForm(form, *form_list[0], true);
1255 } 1255 }
1256 1256
1257 void NativeBackendKWalletPickleTest::CheckVersion8Pickle() { 1257 void NativeBackendKWalletPickleTest::CheckVersion8Pickle() {
1258 base::Pickle pickle; 1258 base::Pickle pickle;
1259 PasswordForm default_values; 1259 PasswordForm default_values;
1260 PasswordForm form = form_google_; 1260 PasswordForm form = form_google_;
1261 1261
1262 // Version 8 pickles deserialize with their own 'skip_zero_click' value. 1262 // Version 8 pickles deserialize with their own 'skip_zero_click' value.
1263 form.skip_zero_click = false; 1263 form.skip_zero_click = false;
1264 CreateVersion1PlusPickle(form, &pickle, 8, 8); 1264 CreateVersion1PlusPickle(form, &pickle, 8, 8);
1265 ScopedVector<PasswordForm> form_list = 1265 std::vector<std::unique_ptr<PasswordForm>> form_list =
1266 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle); 1266 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle);
1267 EXPECT_EQ(1u, form_list.size()); 1267 EXPECT_EQ(1u, form_list.size());
1268 if (form_list.size() > 0) 1268 if (form_list.size() > 0)
1269 CheckPasswordForm(form, *form_list[0], true); 1269 CheckPasswordForm(form, *form_list[0], true);
1270 } 1270 }
1271 1271
1272 void NativeBackendKWalletPickleTest::CheckVersion7Pickle() { 1272 void NativeBackendKWalletPickleTest::CheckVersion7Pickle() {
1273 base::Pickle pickle; 1273 base::Pickle pickle;
1274 PasswordForm default_values; 1274 PasswordForm default_values;
1275 PasswordForm form = form_google_; 1275 PasswordForm form = form_google_;
1276 1276
1277 // Version 7 pickles always deserialize with 'skip_zero_click' of 'true'. 1277 // Version 7 pickles always deserialize with 'skip_zero_click' of 'true'.
1278 form.skip_zero_click = false; 1278 form.skip_zero_click = false;
1279 CreateVersion1PlusPickle(form, &pickle, 7, 7); 1279 CreateVersion1PlusPickle(form, &pickle, 7, 7);
1280 ScopedVector<PasswordForm> form_list = 1280 std::vector<std::unique_ptr<PasswordForm>> form_list =
1281 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle); 1281 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle);
1282 EXPECT_EQ(1u, form_list.size()); 1282 EXPECT_EQ(1u, form_list.size());
1283 form.skip_zero_click = true; 1283 form.skip_zero_click = true;
1284 if (form_list.size() > 0) 1284 if (form_list.size() > 0)
1285 CheckPasswordForm(form, *form_list[0], true); 1285 CheckPasswordForm(form, *form_list[0], true);
1286 } 1286 }
1287 1287
1288 void NativeBackendKWalletPickleTest::CheckVersion6Pickle( 1288 void NativeBackendKWalletPickleTest::CheckVersion6Pickle(
1289 bool with_optional_field) { 1289 bool with_optional_field) {
1290 base::Pickle pickle; 1290 base::Pickle pickle;
1291 PasswordForm form = form_google_; 1291 PasswordForm form = form_google_;
1292 if (!with_optional_field) { 1292 if (!with_optional_field) {
1293 PasswordForm default_values; 1293 PasswordForm default_values;
1294 form.generation_upload_status = default_values.generation_upload_status; 1294 form.generation_upload_status = default_values.generation_upload_status;
1295 } 1295 }
1296 CreateVersion1PlusPickle(form, &pickle, 6, with_optional_field ? 7 : 5); 1296 CreateVersion1PlusPickle(form, &pickle, 6, with_optional_field ? 7 : 5);
1297 1297
1298 ScopedVector<PasswordForm> form_list = 1298 std::vector<std::unique_ptr<PasswordForm>> form_list =
1299 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle); 1299 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle);
1300 1300
1301 EXPECT_EQ(1u, form_list.size()); 1301 EXPECT_EQ(1u, form_list.size());
1302 if (form_list.size() > 0) 1302 if (form_list.size() > 0)
1303 CheckPasswordForm(form, *form_list[0], true); 1303 CheckPasswordForm(form, *form_list[0], true);
1304 } 1304 }
1305 1305
1306 void NativeBackendKWalletPickleTest::CheckVersion5Pickle() { 1306 void NativeBackendKWalletPickleTest::CheckVersion5Pickle() {
1307 base::Pickle pickle; 1307 base::Pickle pickle;
1308 PasswordForm default_values; 1308 PasswordForm default_values;
1309 PasswordForm form = form_google_; 1309 PasswordForm form = form_google_;
1310 // Remove the field which was not present in version #5. 1310 // Remove the field which was not present in version #5.
1311 form.generation_upload_status = default_values.generation_upload_status; 1311 form.generation_upload_status = default_values.generation_upload_status;
1312 CreateVersion1PlusPickle(form, &pickle, 6, 6); 1312 CreateVersion1PlusPickle(form, &pickle, 6, 6);
1313 1313
1314 ScopedVector<PasswordForm> form_list = 1314 std::vector<std::unique_ptr<PasswordForm>> form_list =
1315 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle); 1315 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle);
1316 1316
1317 EXPECT_EQ(1u, form_list.size()); 1317 EXPECT_EQ(1u, form_list.size());
1318 if (form_list.size() > 0) 1318 if (form_list.size() > 0)
1319 CheckPasswordForm(form, *form_list[0], true); 1319 CheckPasswordForm(form, *form_list[0], true);
1320 } 1320 }
1321 1321
1322 void NativeBackendKWalletPickleTest::CheckVersion3Pickle() { 1322 void NativeBackendKWalletPickleTest::CheckVersion3Pickle() {
1323 base::Pickle pickle; 1323 base::Pickle pickle;
1324 PasswordForm default_values; 1324 PasswordForm default_values;
1325 PasswordForm form = form_google_; 1325 PasswordForm form = form_google_;
1326 // Remove the fields which were not present in version #3. 1326 // Remove the fields which were not present in version #3.
1327 form.display_name = default_values.display_name; 1327 form.display_name = default_values.display_name;
1328 form.icon_url = default_values.icon_url; 1328 form.icon_url = default_values.icon_url;
1329 form.federation_origin = default_values.federation_origin; 1329 form.federation_origin = default_values.federation_origin;
1330 form.skip_zero_click = default_values.skip_zero_click; 1330 form.skip_zero_click = default_values.skip_zero_click;
1331 form.generation_upload_status = default_values.generation_upload_status; 1331 form.generation_upload_status = default_values.generation_upload_status;
1332 CreateVersion1PlusPickle(form, &pickle, 3, 3); 1332 CreateVersion1PlusPickle(form, &pickle, 3, 3);
1333 1333
1334 ScopedVector<PasswordForm> form_list = 1334 std::vector<std::unique_ptr<PasswordForm>> form_list =
1335 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle); 1335 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle);
1336 1336
1337 EXPECT_EQ(1u, form_list.size()); 1337 EXPECT_EQ(1u, form_list.size());
1338 if (form_list.size() > 0) 1338 if (form_list.size() > 0)
1339 CheckPasswordForm(form, *form_list[0], false); 1339 CheckPasswordForm(form, *form_list[0], false);
1340 } 1340 }
1341 1341
1342 void NativeBackendKWalletPickleTest::CheckVersion2Pickle() { 1342 void NativeBackendKWalletPickleTest::CheckVersion2Pickle() {
1343 base::Pickle pickle; 1343 base::Pickle pickle;
1344 PasswordForm form = old_form_google_; 1344 PasswordForm form = old_form_google_;
1345 form.times_used = form_google_.times_used; 1345 form.times_used = form_google_.times_used;
1346 form.type = form_google_.type; 1346 form.type = form_google_.type;
1347 form.form_data = form_google_.form_data; 1347 form.form_data = form_google_.form_data;
1348 CreateVersion1PlusPickle(form, &pickle, 2, 2); 1348 CreateVersion1PlusPickle(form, &pickle, 2, 2);
1349 1349
1350 ScopedVector<PasswordForm> form_list = 1350 std::vector<std::unique_ptr<PasswordForm>> form_list =
1351 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle); 1351 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle);
1352 1352
1353 EXPECT_EQ(1u, form_list.size()); 1353 EXPECT_EQ(1u, form_list.size());
1354 if (form_list.size() > 0) 1354 if (form_list.size() > 0)
1355 CheckPasswordForm(form, *form_list[0], false); 1355 CheckPasswordForm(form, *form_list[0], false);
1356 } 1356 }
1357 1357
1358 // Make sure that we can still read version 1 pickles. 1358 // Make sure that we can still read version 1 pickles.
1359 void NativeBackendKWalletPickleTest::CheckVersion1Pickle() { 1359 void NativeBackendKWalletPickleTest::CheckVersion1Pickle() {
1360 base::Pickle pickle; 1360 base::Pickle pickle;
1361 PasswordForm form = form_google_; 1361 PasswordForm form = form_google_;
1362 CreateVersion1PlusPickle(form, &pickle, 1, 1); 1362 CreateVersion1PlusPickle(form, &pickle, 1, 1);
1363 1363
1364 ScopedVector<autofill::PasswordForm> form_list = 1364 std::vector<std::unique_ptr<PasswordForm>> form_list =
1365 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle); 1365 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle);
1366 1366
1367 // This will match |old_form_google_| because not all the fields present in 1367 // This will match |old_form_google_| because not all the fields present in
1368 // |form_google_| will be deserialized. 1368 // |form_google_| will be deserialized.
1369 EXPECT_EQ(1u, form_list.size()); 1369 EXPECT_EQ(1u, form_list.size());
1370 if (form_list.size() > 0) 1370 if (form_list.size() > 0)
1371 CheckPasswordForm(old_form_google_, *form_list[0], false); 1371 CheckPasswordForm(old_form_google_, *form_list[0], false);
1372 } 1372 }
1373 1373
1374 void NativeBackendKWalletPickleTest::CheckVersion0Pickle( 1374 void NativeBackendKWalletPickleTest::CheckVersion0Pickle(
1375 bool size_32, PasswordForm::Scheme scheme) { 1375 bool size_32, PasswordForm::Scheme scheme) {
1376 base::Pickle pickle; 1376 base::Pickle pickle;
1377 PasswordForm form = old_form_google_; 1377 PasswordForm form = old_form_google_;
1378 form.scheme = scheme; 1378 form.scheme = scheme;
1379 CreateVersion0Pickle(size_32, form, &pickle); 1379 CreateVersion0Pickle(size_32, form, &pickle);
1380 ScopedVector<autofill::PasswordForm> form_list = 1380 std::vector<std::unique_ptr<PasswordForm>> form_list =
1381 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle); 1381 NativeBackendKWalletStub::DeserializeValue(form.signon_realm, pickle);
1382 EXPECT_EQ(1u, form_list.size()); 1382 EXPECT_EQ(1u, form_list.size());
1383 if (form_list.size() > 0) 1383 if (form_list.size() > 0)
1384 CheckPasswordForm(form, *form_list[0], false); 1384 CheckPasswordForm(form, *form_list[0], false);
1385 } 1385 }
1386 1386
1387 // We try both SCHEME_HTML and SCHEME_BASIC since the scheme is stored right 1387 // We try both SCHEME_HTML and SCHEME_BASIC since the scheme is stored right
1388 // after the size in the pickle, so it's what gets read as part of the count 1388 // after the size in the pickle, so it's what gets read as part of the count
1389 // when reading 32-bit pickles on 64-bit systems. SCHEME_HTML is 0 (so we'll 1389 // when reading 32-bit pickles on 64-bit systems. SCHEME_HTML is 0 (so we'll
1390 // detect errors later) while SCHEME_BASIC is 1 (so we'll detect it then). We 1390 // detect errors later) while SCHEME_BASIC is 1 (so we'll detect it then). We
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 CheckVersion7Pickle(); 1433 CheckVersion7Pickle();
1434 } 1434 }
1435 1435
1436 TEST_F(NativeBackendKWalletPickleTest, CheckVersion8Pickle) { 1436 TEST_F(NativeBackendKWalletPickleTest, CheckVersion8Pickle) {
1437 CheckVersion8Pickle(); 1437 CheckVersion8Pickle();
1438 } 1438 }
1439 1439
1440 TEST_F(NativeBackendKWalletPickleTest, CheckVersion9Pickle) { 1440 TEST_F(NativeBackendKWalletPickleTest, CheckVersion9Pickle) {
1441 CheckVersion9Pickle(); 1441 CheckVersion9Pickle();
1442 } 1442 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698