OLD | NEW |
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 <stdarg.h> | 5 #include <stdarg.h> |
6 #include <stddef.h> | 6 #include <stddef.h> |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 } | 1170 } |
1171 | 1171 |
1172 TEST_F(NativeBackendGnomeTest, RemoveLoginsCreatedBetween) { | 1172 TEST_F(NativeBackendGnomeTest, RemoveLoginsCreatedBetween) { |
1173 CheckRemoveLoginsBetween(CREATED); | 1173 CheckRemoveLoginsBetween(CREATED); |
1174 } | 1174 } |
1175 | 1175 |
1176 TEST_F(NativeBackendGnomeTest, RemoveLoginsSyncedBetween) { | 1176 TEST_F(NativeBackendGnomeTest, RemoveLoginsSyncedBetween) { |
1177 CheckRemoveLoginsBetween(SYNCED); | 1177 CheckRemoveLoginsBetween(SYNCED); |
1178 } | 1178 } |
1179 | 1179 |
1180 TEST_F(NativeBackendGnomeTest, DisableAutoSignInForAllLogins) { | 1180 TEST_F(NativeBackendGnomeTest, DisableAutoSignInForOrigins) { |
1181 NativeBackendGnome backend(42); | 1181 NativeBackendGnome backend(42); |
1182 backend.Init(); | 1182 backend.Init(); |
1183 form_google_.skip_zero_click = false; | 1183 form_google_.skip_zero_click = false; |
1184 form_facebook_.skip_zero_click = false; | 1184 form_facebook_.skip_zero_click = false; |
1185 | 1185 |
1186 BrowserThread::PostTask( | 1186 BrowserThread::PostTask( |
1187 BrowserThread::DB, FROM_HERE, | 1187 BrowserThread::DB, FROM_HERE, |
1188 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), | 1188 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), |
1189 base::Unretained(&backend), form_google_)); | 1189 base::Unretained(&backend), form_google_)); |
1190 BrowserThread::PostTask( | 1190 BrowserThread::PostTask( |
1191 BrowserThread::DB, FROM_HERE, | 1191 BrowserThread::DB, FROM_HERE, |
1192 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), | 1192 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), |
1193 base::Unretained(&backend), form_facebook_)); | 1193 base::Unretained(&backend), form_facebook_)); |
1194 | 1194 |
1195 RunBothThreads(); | 1195 RunBothThreads(); |
1196 | 1196 |
1197 EXPECT_EQ(2u, mock_keyring_items.size()); | 1197 EXPECT_EQ(2u, mock_keyring_items.size()); |
1198 for (const auto& item : mock_keyring_items) | 1198 for (const auto& item : mock_keyring_items) |
1199 CheckUint32Attribute(&item, "should_skip_zero_click", 0); | 1199 CheckUint32Attribute(&item, "should_skip_zero_click", 0); |
1200 | 1200 |
1201 // Set the canonical forms to the updated value for the following comparison. | 1201 // Set the canonical forms to the updated value for the following comparison. |
1202 form_google_.skip_zero_click = true; | 1202 form_google_.skip_zero_click = true; |
1203 form_facebook_.skip_zero_click = true; | 1203 form_facebook_.skip_zero_click = true; |
1204 PasswordStoreChangeList expected_changes; | 1204 PasswordStoreChangeList expected_changes; |
1205 expected_changes.push_back( | 1205 expected_changes.push_back( |
1206 PasswordStoreChange(PasswordStoreChange::UPDATE, form_facebook_)); | 1206 PasswordStoreChange(PasswordStoreChange::UPDATE, form_facebook_)); |
1207 expected_changes.push_back( | |
1208 PasswordStoreChange(PasswordStoreChange::UPDATE, form_google_)); | |
1209 | 1207 |
1210 PasswordStoreChangeList changes; | 1208 PasswordStoreChangeList changes; |
1211 BrowserThread::PostTaskAndReplyWithResult( | 1209 BrowserThread::PostTaskAndReplyWithResult( |
1212 BrowserThread::DB, FROM_HERE, | 1210 BrowserThread::DB, FROM_HERE, |
1213 base::Bind(&NativeBackendGnome::DisableAutoSignInForAllLogins, | 1211 base::Bind(&NativeBackendGnome::DisableAutoSignInForOrigins, |
1214 base::Unretained(&backend), &changes), | 1212 base::Unretained(&backend), |
| 1213 base::Bind(&GURL::operator==, |
| 1214 base::Unretained(&form_facebook_.origin)), |
| 1215 &changes), |
1215 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes)); | 1216 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes)); |
1216 RunBothThreads(); | 1217 RunBothThreads(); |
1217 | 1218 |
1218 EXPECT_EQ(2u, mock_keyring_items.size()); | 1219 EXPECT_EQ(2u, mock_keyring_items.size()); |
1219 for (const auto& item : mock_keyring_items) | 1220 CheckStringAttribute( |
1220 CheckUint32Attribute(&item, "should_skip_zero_click", 1); | 1221 &mock_keyring_items[0], "origin_url", form_google_.origin.spec()); |
| 1222 CheckUint32Attribute(&mock_keyring_items[0], "should_skip_zero_click", 0); |
| 1223 CheckStringAttribute( |
| 1224 &mock_keyring_items[1], "origin_url", form_facebook_.origin.spec()); |
| 1225 CheckUint32Attribute(&mock_keyring_items[1], "should_skip_zero_click", 1); |
1221 } | 1226 } |
1222 | 1227 |
1223 TEST_F(NativeBackendGnomeTest, ReadDuplicateForms) { | 1228 TEST_F(NativeBackendGnomeTest, ReadDuplicateForms) { |
1224 NativeBackendGnome backend(42); | 1229 NativeBackendGnome backend(42); |
1225 backend.Init(); | 1230 backend.Init(); |
1226 | 1231 |
1227 // Add 2 slightly different password forms. | 1232 // Add 2 slightly different password forms. |
1228 const char unique_string[] = "unique_unique_string"; | 1233 const char unique_string[] = "unique_unique_string"; |
1229 const char unique_string_replacement[] = "uniKue_unique_string"; | 1234 const char unique_string_replacement[] = "uniKue_unique_string"; |
1230 form_google_.origin = | 1235 form_google_.origin = |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 base::Bind(&CheckTrue)); | 1297 base::Bind(&CheckTrue)); |
1293 | 1298 |
1294 RunBothThreads(); | 1299 RunBothThreads(); |
1295 | 1300 |
1296 EXPECT_EQ(2u, form_list.size()); | 1301 EXPECT_EQ(2u, form_list.size()); |
1297 EXPECT_THAT(form_list, UnorderedElementsAre(Pointee(form_google_), | 1302 EXPECT_THAT(form_list, UnorderedElementsAre(Pointee(form_google_), |
1298 Pointee(form_facebook_))); | 1303 Pointee(form_facebook_))); |
1299 } | 1304 } |
1300 | 1305 |
1301 // TODO(mdm): add more basic tests here at some point. | 1306 // TODO(mdm): add more basic tests here at some point. |
OLD | NEW |