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

Unified Diff: content/browser/cache_storage/cache_storage_cache_unittest.cc

Issue 1829663002: test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/cache_storage/cache_storage_cache.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/cache_storage/cache_storage_cache_unittest.cc
diff --git a/content/browser/cache_storage/cache_storage_cache_unittest.cc b/content/browser/cache_storage/cache_storage_cache_unittest.cc
index 505f9bd827887ed5da21340bed62fce76e6fff9d..a156595c91feae4b76e1fcbe2cf696a8587dc74f 100644
--- a/content/browser/cache_storage/cache_storage_cache_unittest.cc
+++ b/content/browser/cache_storage/cache_storage_cache_unittest.cc
@@ -388,6 +388,14 @@ class CacheStorageCacheTest : public testing::Test {
return callback_error_ == CACHE_STORAGE_OK;
}
+ bool QueryCache(const ServiceWorkerFetchRequest& request,
+ const CacheStorageCacheQueryParams& options) {
+ base::RunLoop loop;
+ cache_->QueryCache(CopyFetchRequest(request), options);
+ loop.Run();
+ return true;
+ }
+
bool MatchAll(const ServiceWorkerFetchRequest& request,
const CacheStorageCacheQueryParams& match_params,
scoped_ptr<CacheStorageCache::Responses>* responses,
@@ -829,6 +837,38 @@ TEST_P(CacheStorageCacheTestP, MatchAll_IgnoreSearch) {
EXPECT_EQ(2u, matched_set.size());
}
+TEST_P(CacheStorageCacheTestP, QueryCache) {
+ EXPECT_TRUE(Put(body_request_, body_response_));
+ EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_));
+ EXPECT_TRUE(Put(no_body_request_, no_body_response_));
+
+ CacheStorageCacheQueryParams match_params;
+ EXPECT_TRUE(QueryCache(body_request_, match_params));
+
+/* scoped_ptr<CacheStorageCache::Responses> responses;
+ scoped_ptr<CacheStorageCache::BlobDataHandles> body_handles;
+ CacheStorageCacheQueryParams match_params;
+ match_params.ignore_search = true;
+ EXPECT_TRUE(MatchAll(body_request_, match_params, &responses, &body_handles));
+
+ ASSERT_EQ(2u, responses->size());
+ ASSERT_EQ(2u, body_handles->size());
+
+ // Order of returned responses is not guaranteed.
+ std::set<std::string> matched_set;
+ for (const ServiceWorkerResponse& response : *responses) {
+ if (response.url.spec() == "http://example.com/body.html?query=test") {
+ EXPECT_TRUE(ResponseMetadataEqual(body_response_with_query_, response));
+ matched_set.insert(response.url.spec());
+ } else if (response.url.spec() == "http://example.com/body.html") {
+ EXPECT_TRUE(ResponseMetadataEqual(body_response_, response));
+ matched_set.insert(response.url.spec());
+ }
+ }
+ EXPECT_EQ(2u, matched_set.size());*/
+}
+
+
TEST_P(CacheStorageCacheTestP, Vary) {
body_request_.headers["vary_foo"] = "foo";
body_response_.headers["vary"] = "vary_foo";
« no previous file with comments | « content/browser/cache_storage/cache_storage_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698