| OLD | NEW |
| 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 "content/browser/cache_storage/cache_storage_cache.h" | 5 #include "content/browser/cache_storage/cache_storage_cache.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 | 639 |
| 640 void SizeCallback(base::RunLoop* run_loop, | 640 void SizeCallback(base::RunLoop* run_loop, |
| 641 bool* callback_called, | 641 bool* callback_called, |
| 642 int64_t size) { | 642 int64_t size) { |
| 643 *callback_called = true; | 643 *callback_called = true; |
| 644 callback_size_ = size; | 644 callback_size_ = size; |
| 645 if (run_loop) | 645 if (run_loop) |
| 646 run_loop->Quit(); | 646 run_loop->Quit(); |
| 647 } | 647 } |
| 648 | 648 |
| 649 bool VerifyKeys(const std::vector<std::string>& expected_keys) { | |
| 650 if (expected_keys.size() != callback_strings_.size()) | |
| 651 return false; | |
| 652 | |
| 653 std::set<std::string> found_set; | |
| 654 for (int i = 0, max = callback_strings_.size(); i < max; ++i) | |
| 655 found_set.insert(callback_strings_[i]); | |
| 656 | |
| 657 for (int i = 0, max = expected_keys.size(); i < max; ++i) { | |
| 658 if (found_set.find(expected_keys[i]) == found_set.end()) | |
| 659 return false; | |
| 660 } | |
| 661 return true; | |
| 662 } | |
| 663 | |
| 664 bool TestResponseType(blink::WebServiceWorkerResponseType response_type) { | 649 bool TestResponseType(blink::WebServiceWorkerResponseType response_type) { |
| 665 body_response_.response_type = response_type; | 650 body_response_.response_type = response_type; |
| 666 EXPECT_TRUE(Put(body_request_, body_response_)); | 651 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 667 EXPECT_TRUE(Match(body_request_)); | 652 EXPECT_TRUE(Match(body_request_)); |
| 668 EXPECT_TRUE(Delete(body_request_)); | 653 EXPECT_TRUE(Delete(body_request_)); |
| 669 return response_type == callback_response_->response_type; | 654 return response_type == callback_response_->response_type; |
| 670 } | 655 } |
| 671 | 656 |
| 672 void VerifyAllOpsFail() { | 657 void VerifyAllOpsFail() { |
| 673 EXPECT_FALSE(Put(no_body_request_, no_body_response_)); | 658 EXPECT_FALSE(Put(no_body_request_, no_body_response_)); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 TEST_P(CacheStorageCacheTestP, MatchAll_NoBody) { | 917 TEST_P(CacheStorageCacheTestP, MatchAll_NoBody) { |
| 933 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); | 918 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 934 | 919 |
| 935 std::unique_ptr<CacheStorageCache::Responses> responses; | 920 std::unique_ptr<CacheStorageCache::Responses> responses; |
| 936 std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; | 921 std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; |
| 937 EXPECT_TRUE(MatchAll(&responses, &body_handles)); | 922 EXPECT_TRUE(MatchAll(&responses, &body_handles)); |
| 938 | 923 |
| 939 ASSERT_EQ(1u, responses->size()); | 924 ASSERT_EQ(1u, responses->size()); |
| 940 EXPECT_TRUE( | 925 EXPECT_TRUE( |
| 941 ResponseMetadataEqual(SetCacheName(no_body_response_), responses->at(0))); | 926 ResponseMetadataEqual(SetCacheName(no_body_response_), responses->at(0))); |
| 942 EXPECT_TRUE(body_handles->empty()); | 927 EXPECT_FALSE(body_handles->at(0)); |
| 943 } | 928 } |
| 944 | 929 |
| 945 TEST_P(CacheStorageCacheTestP, MatchAll_Body) { | 930 TEST_P(CacheStorageCacheTestP, MatchAll_Body) { |
| 946 EXPECT_TRUE(Put(body_request_, body_response_)); | 931 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 947 | 932 |
| 948 std::unique_ptr<CacheStorageCache::Responses> responses; | 933 std::unique_ptr<CacheStorageCache::Responses> responses; |
| 949 std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; | 934 std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; |
| 950 EXPECT_TRUE(MatchAll(&responses, &body_handles)); | 935 EXPECT_TRUE(MatchAll(&responses, &body_handles)); |
| 951 | 936 |
| 952 ASSERT_EQ(1u, responses->size()); | 937 ASSERT_EQ(1u, responses->size()); |
| 953 ASSERT_EQ(1u, body_handles->size()); | 938 ASSERT_EQ(1u, body_handles->size()); |
| 954 EXPECT_TRUE( | 939 EXPECT_TRUE( |
| 955 ResponseMetadataEqual(SetCacheName(body_response_), responses->at(0))); | 940 ResponseMetadataEqual(SetCacheName(body_response_), responses->at(0))); |
| 956 EXPECT_TRUE(ResponseBodiesEqual(expected_blob_data_, body_handles->at(0))); | 941 EXPECT_TRUE(ResponseBodiesEqual(expected_blob_data_, *body_handles->at(0))); |
| 957 } | 942 } |
| 958 | 943 |
| 959 TEST_P(CacheStorageCacheTestP, MatchAll_TwoResponsesThenOne) { | 944 TEST_P(CacheStorageCacheTestP, MatchAll_TwoResponsesThenOne) { |
| 960 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); | 945 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 961 EXPECT_TRUE(Put(body_request_, body_response_)); | 946 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 962 | 947 |
| 963 std::unique_ptr<CacheStorageCache::Responses> responses; | 948 std::unique_ptr<CacheStorageCache::Responses> responses; |
| 964 std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; | 949 std::unique_ptr<CacheStorageCache::BlobDataHandles> body_handles; |
| 965 EXPECT_TRUE(MatchAll(&responses, &body_handles)); | 950 EXPECT_TRUE(MatchAll(&responses, &body_handles)); |
| 966 ASSERT_EQ(2u, responses->size()); | 951 ASSERT_TRUE(body_handles->at(1)); |
| 967 ASSERT_EQ(1u, body_handles->size()); | |
| 968 | 952 |
| 969 // Order of returned responses is not guaranteed. | 953 EXPECT_TRUE( |
| 970 std::set<std::string> matched_set; | 954 ResponseMetadataEqual(SetCacheName(no_body_response_), responses->at(0))); |
| 971 for (const ServiceWorkerResponse& response : *responses) { | 955 EXPECT_FALSE(body_handles->at(0)); |
| 972 if (response.url.spec() == "http://example.com/no_body.html") { | 956 EXPECT_TRUE( |
| 973 EXPECT_TRUE( | 957 ResponseMetadataEqual(SetCacheName(body_response_), responses->at(1))); |
| 974 ResponseMetadataEqual(SetCacheName(no_body_response_), response)); | 958 EXPECT_TRUE(ResponseBodiesEqual(expected_blob_data_, *body_handles->at(1))); |
| 975 matched_set.insert(response.url.spec()); | |
| 976 } else if (response.url.spec() == "http://example.com/body.html") { | |
| 977 EXPECT_TRUE( | |
| 978 ResponseMetadataEqual(SetCacheName(body_response_), response)); | |
| 979 EXPECT_TRUE( | |
| 980 ResponseBodiesEqual(expected_blob_data_, body_handles->at(0))); | |
| 981 matched_set.insert(response.url.spec()); | |
| 982 } | |
| 983 } | |
| 984 EXPECT_EQ(2u, matched_set.size()); | |
| 985 | 959 |
| 986 responses->clear(); | 960 responses->clear(); |
| 987 body_handles->clear(); | 961 body_handles->clear(); |
| 988 | 962 |
| 989 EXPECT_TRUE(Delete(body_request_)); | 963 EXPECT_TRUE(Delete(body_request_)); |
| 990 EXPECT_TRUE(MatchAll(&responses, &body_handles)); | 964 EXPECT_TRUE(MatchAll(&responses, &body_handles)); |
| 991 | 965 |
| 992 ASSERT_EQ(1u, responses->size()); | 966 ASSERT_EQ(1u, responses->size()); |
| 993 EXPECT_TRUE( | 967 EXPECT_TRUE( |
| 994 ResponseMetadataEqual(SetCacheName(no_body_response_), responses->at(0))); | 968 ResponseMetadataEqual(SetCacheName(no_body_response_), responses->at(0))); |
| 995 EXPECT_TRUE(body_handles->empty()); | 969 ASSERT_EQ(1u, body_handles->size()); |
| 970 EXPECT_FALSE(body_handles->at(0)); |
| 996 } | 971 } |
| 997 | 972 |
| 998 TEST_P(CacheStorageCacheTestP, Match_IgnoreSearch) { | 973 TEST_P(CacheStorageCacheTestP, Match_IgnoreSearch) { |
| 999 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); | 974 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); |
| 1000 | 975 |
| 1001 EXPECT_FALSE(Match(body_request_)); | 976 EXPECT_FALSE(Match(body_request_)); |
| 1002 CacheStorageCacheQueryParams match_params; | 977 CacheStorageCacheQueryParams match_params; |
| 1003 match_params.ignore_search = true; | 978 match_params.ignore_search = true; |
| 1004 EXPECT_TRUE(Match(body_request_, match_params)); | 979 EXPECT_TRUE(Match(body_request_, match_params)); |
| 1005 } | 980 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 EXPECT_TRUE(responses->empty()); | 1161 EXPECT_TRUE(responses->empty()); |
| 1187 EXPECT_TRUE(body_handles->empty()); | 1162 EXPECT_TRUE(body_handles->empty()); |
| 1188 | 1163 |
| 1189 match_params.ignore_method = true; | 1164 match_params.ignore_method = true; |
| 1190 EXPECT_TRUE( | 1165 EXPECT_TRUE( |
| 1191 MatchAll(body_head_request_, match_params, &responses, &body_handles)); | 1166 MatchAll(body_head_request_, match_params, &responses, &body_handles)); |
| 1192 ASSERT_EQ(1u, responses->size()); | 1167 ASSERT_EQ(1u, responses->size()); |
| 1193 ASSERT_EQ(1u, body_handles->size()); | 1168 ASSERT_EQ(1u, body_handles->size()); |
| 1194 EXPECT_TRUE( | 1169 EXPECT_TRUE( |
| 1195 ResponseMetadataEqual(SetCacheName(body_response_), responses->at(0))); | 1170 ResponseMetadataEqual(SetCacheName(body_response_), responses->at(0))); |
| 1196 EXPECT_TRUE(ResponseBodiesEqual(expected_blob_data_, body_handles->at(0))); | 1171 EXPECT_TRUE(ResponseBodiesEqual(expected_blob_data_, *body_handles->at(0))); |
| 1197 } | 1172 } |
| 1198 | 1173 |
| 1199 TEST_P(CacheStorageCacheTestP, Vary) { | 1174 TEST_P(CacheStorageCacheTestP, Vary) { |
| 1200 body_request_.headers["vary_foo"] = "foo"; | 1175 body_request_.headers["vary_foo"] = "foo"; |
| 1201 body_response_.headers["vary"] = "vary_foo"; | 1176 body_response_.headers["vary"] = "vary_foo"; |
| 1202 EXPECT_TRUE(Put(body_request_, body_response_)); | 1177 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 1203 EXPECT_TRUE(Match(body_request_)); | 1178 EXPECT_TRUE(Match(body_request_)); |
| 1204 | 1179 |
| 1205 body_request_.headers["vary_foo"] = "bar"; | 1180 body_request_.headers["vary_foo"] = "bar"; |
| 1206 EXPECT_FALSE(Match(body_request_)); | 1181 EXPECT_FALSE(Match(body_request_)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 | 1233 |
| 1259 TEST_P(CacheStorageCacheTestP, EmptyKeys) { | 1234 TEST_P(CacheStorageCacheTestP, EmptyKeys) { |
| 1260 EXPECT_TRUE(Keys()); | 1235 EXPECT_TRUE(Keys()); |
| 1261 EXPECT_EQ(0u, callback_strings_.size()); | 1236 EXPECT_EQ(0u, callback_strings_.size()); |
| 1262 } | 1237 } |
| 1263 | 1238 |
| 1264 TEST_P(CacheStorageCacheTestP, TwoKeys) { | 1239 TEST_P(CacheStorageCacheTestP, TwoKeys) { |
| 1265 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); | 1240 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 1266 EXPECT_TRUE(Put(body_request_, body_response_)); | 1241 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 1267 EXPECT_TRUE(Keys()); | 1242 EXPECT_TRUE(Keys()); |
| 1268 EXPECT_EQ(2u, callback_strings_.size()); | 1243 std::vector<std::string> expected_keys{no_body_request_.url.spec(), |
| 1269 std::vector<std::string> expected_keys; | 1244 body_request_.url.spec()}; |
| 1270 expected_keys.push_back(no_body_request_.url.spec()); | 1245 EXPECT_EQ(expected_keys, callback_strings_); |
| 1271 expected_keys.push_back(body_request_.url.spec()); | |
| 1272 EXPECT_TRUE(VerifyKeys(expected_keys)); | |
| 1273 } | 1246 } |
| 1274 | 1247 |
| 1275 TEST_P(CacheStorageCacheTestP, TwoKeysThenOne) { | 1248 TEST_P(CacheStorageCacheTestP, TwoKeysThenOne) { |
| 1276 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); | 1249 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 1277 EXPECT_TRUE(Put(body_request_, body_response_)); | 1250 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 1278 EXPECT_TRUE(Keys()); | 1251 EXPECT_TRUE(Keys()); |
| 1279 EXPECT_EQ(2u, callback_strings_.size()); | 1252 std::vector<std::string> expected_keys{no_body_request_.url.spec(), |
| 1280 std::vector<std::string> expected_keys; | 1253 body_request_.url.spec()}; |
| 1281 expected_keys.push_back(no_body_request_.url.spec()); | 1254 EXPECT_EQ(expected_keys, callback_strings_); |
| 1282 expected_keys.push_back(body_request_.url.spec()); | |
| 1283 EXPECT_TRUE(VerifyKeys(expected_keys)); | |
| 1284 | 1255 |
| 1285 EXPECT_TRUE(Delete(body_request_)); | 1256 EXPECT_TRUE(Delete(body_request_)); |
| 1286 EXPECT_TRUE(Keys()); | 1257 EXPECT_TRUE(Keys()); |
| 1287 EXPECT_EQ(1u, callback_strings_.size()); | 1258 std::vector<std::string> expected_keys2{no_body_request_.url.spec()}; |
| 1288 std::vector<std::string> expected_key; | 1259 EXPECT_EQ(expected_keys2, callback_strings_); |
| 1289 expected_key.push_back(no_body_request_.url.spec()); | |
| 1290 EXPECT_TRUE(VerifyKeys(expected_key)); | |
| 1291 } | 1260 } |
| 1292 | 1261 |
| 1293 TEST_P(CacheStorageCacheTestP, KeysWithIgnoreSearchTrue) { | 1262 TEST_P(CacheStorageCacheTestP, KeysWithIgnoreSearchTrue) { |
| 1294 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); | 1263 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 1295 EXPECT_TRUE(Put(body_request_, body_response_)); | 1264 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 1296 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); | 1265 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); |
| 1297 | 1266 |
| 1298 CacheStorageCacheQueryParams match_params; | 1267 CacheStorageCacheQueryParams match_params; |
| 1299 match_params.ignore_search = true; | 1268 match_params.ignore_search = true; |
| 1300 | 1269 |
| 1301 EXPECT_TRUE(Keys(body_request_with_query_, match_params)); | 1270 EXPECT_TRUE(Keys(body_request_with_query_, match_params)); |
| 1302 EXPECT_EQ(2u, callback_strings_.size()); | |
| 1303 std::vector<std::string> expected_keys = { | 1271 std::vector<std::string> expected_keys = { |
| 1304 body_request_.url.spec(), body_request_with_query_.url.spec()}; | 1272 body_request_.url.spec(), body_request_with_query_.url.spec()}; |
| 1305 EXPECT_TRUE(VerifyKeys(expected_keys)); | 1273 EXPECT_EQ(expected_keys, callback_strings_); |
| 1306 } | 1274 } |
| 1307 | 1275 |
| 1308 TEST_P(CacheStorageCacheTestP, KeysWithIgnoreSearchFalse) { | 1276 TEST_P(CacheStorageCacheTestP, KeysWithIgnoreSearchFalse) { |
| 1309 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); | 1277 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 1310 EXPECT_TRUE(Put(body_request_, body_response_)); | 1278 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 1311 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); | 1279 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); |
| 1312 | 1280 |
| 1313 // Default value of ignore_search is false. | 1281 // Default value of ignore_search is false. |
| 1314 CacheStorageCacheQueryParams match_params; | 1282 CacheStorageCacheQueryParams match_params; |
| 1315 match_params.ignore_search = false; | 1283 match_params.ignore_search = false; |
| 1316 EXPECT_EQ(match_params.ignore_search, | 1284 EXPECT_EQ(match_params.ignore_search, |
| 1317 CacheStorageCacheQueryParams().ignore_search); | 1285 CacheStorageCacheQueryParams().ignore_search); |
| 1318 | 1286 |
| 1319 EXPECT_TRUE(Keys(body_request_with_query_, match_params)); | 1287 EXPECT_TRUE(Keys(body_request_with_query_, match_params)); |
| 1320 EXPECT_EQ(1u, callback_strings_.size()); | |
| 1321 std::vector<std::string> expected_keys = { | 1288 std::vector<std::string> expected_keys = { |
| 1322 body_request_with_query_.url.spec()}; | 1289 body_request_with_query_.url.spec()}; |
| 1323 EXPECT_TRUE(VerifyKeys(expected_keys)); | 1290 EXPECT_EQ(expected_keys, callback_strings_); |
| 1324 } | 1291 } |
| 1325 | 1292 |
| 1326 TEST_P(CacheStorageCacheTestP, DeleteNoBody) { | 1293 TEST_P(CacheStorageCacheTestP, DeleteNoBody) { |
| 1327 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); | 1294 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 1328 EXPECT_TRUE(Match(no_body_request_)); | 1295 EXPECT_TRUE(Match(no_body_request_)); |
| 1329 EXPECT_TRUE(Delete(no_body_request_)); | 1296 EXPECT_TRUE(Delete(no_body_request_)); |
| 1330 EXPECT_FALSE(Match(no_body_request_)); | 1297 EXPECT_FALSE(Match(no_body_request_)); |
| 1331 EXPECT_FALSE(Delete(no_body_request_)); | 1298 EXPECT_FALSE(Delete(no_body_request_)); |
| 1332 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); | 1299 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 1333 EXPECT_TRUE(Match(no_body_request_)); | 1300 EXPECT_TRUE(Match(no_body_request_)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1344 EXPECT_TRUE(Match(body_request_)); | 1311 EXPECT_TRUE(Match(body_request_)); |
| 1345 EXPECT_TRUE(Delete(body_request_)); | 1312 EXPECT_TRUE(Delete(body_request_)); |
| 1346 } | 1313 } |
| 1347 | 1314 |
| 1348 TEST_P(CacheStorageCacheTestP, DeleteWithIgnoreSearchTrue) { | 1315 TEST_P(CacheStorageCacheTestP, DeleteWithIgnoreSearchTrue) { |
| 1349 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); | 1316 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 1350 EXPECT_TRUE(Put(body_request_, body_response_)); | 1317 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 1351 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); | 1318 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); |
| 1352 | 1319 |
| 1353 EXPECT_TRUE(Keys()); | 1320 EXPECT_TRUE(Keys()); |
| 1354 EXPECT_EQ(3u, callback_strings_.size()); | 1321 std::vector<std::string> expected_keys{no_body_request_.url.spec(), |
| 1355 std::vector<std::string> expected_keys; | 1322 body_request_.url.spec(), |
| 1356 expected_keys.push_back(no_body_request_.url.spec()); | 1323 body_request_with_query_.url.spec()}; |
| 1357 expected_keys.push_back(body_request_.url.spec()); | 1324 EXPECT_EQ(expected_keys, callback_strings_); |
| 1358 expected_keys.push_back(body_request_with_query_.url.spec()); | |
| 1359 EXPECT_TRUE(VerifyKeys(expected_keys)); | |
| 1360 | 1325 |
| 1361 // The following delete operation will remove both of body_request_ and | 1326 // The following delete operation will remove both of body_request_ and |
| 1362 // body_request_with_query_ from cache storage. | 1327 // body_request_with_query_ from cache storage. |
| 1363 CacheStorageCacheQueryParams match_params; | 1328 CacheStorageCacheQueryParams match_params; |
| 1364 match_params.ignore_search = true; | 1329 match_params.ignore_search = true; |
| 1365 EXPECT_TRUE(Delete(body_request_with_query_, match_params)); | 1330 EXPECT_TRUE(Delete(body_request_with_query_, match_params)); |
| 1366 | 1331 |
| 1367 EXPECT_TRUE(Keys()); | 1332 EXPECT_TRUE(Keys()); |
| 1368 EXPECT_EQ(1u, callback_strings_.size()); | |
| 1369 expected_keys.clear(); | 1333 expected_keys.clear(); |
| 1370 expected_keys.push_back(no_body_request_.url.spec()); | 1334 std::vector<std::string> expected_keys2{no_body_request_.url.spec()}; |
| 1371 EXPECT_TRUE(VerifyKeys(expected_keys)); | 1335 EXPECT_EQ(expected_keys2, callback_strings_); |
| 1372 } | 1336 } |
| 1373 | 1337 |
| 1374 TEST_P(CacheStorageCacheTestP, DeleteWithIgnoreSearchFalse) { | 1338 TEST_P(CacheStorageCacheTestP, DeleteWithIgnoreSearchFalse) { |
| 1375 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); | 1339 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 1376 EXPECT_TRUE(Put(body_request_, body_response_)); | 1340 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 1377 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); | 1341 EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_)); |
| 1378 | 1342 |
| 1379 EXPECT_TRUE(Keys()); | 1343 EXPECT_TRUE(Keys()); |
| 1380 EXPECT_EQ(3u, callback_strings_.size()); | 1344 std::vector<std::string> expected_keys{no_body_request_.url.spec(), |
| 1381 std::vector<std::string> expected_keys; | 1345 body_request_.url.spec(), |
| 1382 expected_keys.push_back(no_body_request_.url.spec()); | 1346 body_request_with_query_.url.spec()}; |
| 1383 expected_keys.push_back(body_request_.url.spec()); | 1347 EXPECT_EQ(expected_keys, callback_strings_); |
| 1384 expected_keys.push_back(body_request_with_query_.url.spec()); | |
| 1385 EXPECT_TRUE(VerifyKeys(expected_keys)); | |
| 1386 | 1348 |
| 1387 // Default value of ignore_search is false. | 1349 // Default value of ignore_search is false. |
| 1388 CacheStorageCacheQueryParams match_params; | 1350 CacheStorageCacheQueryParams match_params; |
| 1389 match_params.ignore_search = false; | 1351 match_params.ignore_search = false; |
| 1390 EXPECT_EQ(match_params.ignore_search, | 1352 EXPECT_EQ(match_params.ignore_search, |
| 1391 CacheStorageCacheQueryParams().ignore_search); | 1353 CacheStorageCacheQueryParams().ignore_search); |
| 1392 | 1354 |
| 1393 EXPECT_TRUE(Delete(body_request_with_query_, match_params)); | 1355 EXPECT_TRUE(Delete(body_request_with_query_, match_params)); |
| 1394 | 1356 |
| 1395 EXPECT_TRUE(Keys()); | 1357 EXPECT_TRUE(Keys()); |
| 1396 EXPECT_EQ(2u, callback_strings_.size()); | 1358 std::vector<std::string> expected_keys2{no_body_request_.url.spec(), |
| 1397 expected_keys.clear(); | 1359 body_request_.url.spec()}; |
| 1398 expected_keys.push_back(no_body_request_.url.spec()); | 1360 EXPECT_EQ(expected_keys2, callback_strings_); |
| 1399 expected_keys.push_back(body_request_.url.spec()); | |
| 1400 EXPECT_TRUE(VerifyKeys(expected_keys)); | |
| 1401 } | 1361 } |
| 1402 | 1362 |
| 1403 TEST_P(CacheStorageCacheTestP, QuickStressNoBody) { | 1363 TEST_P(CacheStorageCacheTestP, QuickStressNoBody) { |
| 1404 for (int i = 0; i < 100; ++i) { | 1364 for (int i = 0; i < 100; ++i) { |
| 1405 EXPECT_FALSE(Match(no_body_request_)); | 1365 EXPECT_FALSE(Match(no_body_request_)); |
| 1406 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); | 1366 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 1407 EXPECT_TRUE(Match(no_body_request_)); | 1367 EXPECT_TRUE(Match(no_body_request_)); |
| 1408 EXPECT_TRUE(Delete(no_body_request_)); | 1368 EXPECT_TRUE(Delete(no_body_request_)); |
| 1409 } | 1369 } |
| 1410 } | 1370 } |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 EXPECT_EQ(1, sequence_out); | 1620 EXPECT_EQ(1, sequence_out); |
| 1661 close_loop2->Run(); | 1621 close_loop2->Run(); |
| 1662 EXPECT_EQ(2, sequence_out); | 1622 EXPECT_EQ(2, sequence_out); |
| 1663 } | 1623 } |
| 1664 | 1624 |
| 1665 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, | 1625 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, |
| 1666 CacheStorageCacheTestP, | 1626 CacheStorageCacheTestP, |
| 1667 ::testing::Values(false, true)); | 1627 ::testing::Values(false, true)); |
| 1668 | 1628 |
| 1669 } // namespace content | 1629 } // namespace content |
| OLD | NEW |