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

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

Issue 1719103002: CacheStorage: Expand cache.keys() method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 4 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
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 f52e741aae6910c49224bf1996fe63956d35964f..60961052a85f4fe3b676fa8959e8a053b29b482d 100644
--- a/content/browser/cache_storage/cache_storage_cache_unittest.cc
+++ b/content/browser/cache_storage/cache_storage_cache_unittest.cc
@@ -504,12 +504,16 @@ class CacheStorageCacheTest : public testing::Test {
return error == CACHE_STORAGE_OK;
}
- bool Keys() {
+ bool Keys(
+ const ServiceWorkerFetchRequest& request = ServiceWorkerFetchRequest(),
+ const CacheStorageCacheQueryParams& match_params =
+ CacheStorageCacheQueryParams()) {
std::unique_ptr<base::RunLoop> loop(new base::RunLoop());
- cache_->Keys(base::Bind(&CacheStorageCacheTest::RequestsCallback,
- base::Unretained(this),
- base::Unretained(loop.get())));
+ cache_->Keys(
+ CopyFetchRequest(request), match_params,
+ base::Bind(&CacheStorageCacheTest::RequestsCallback,
+ base::Unretained(this), base::Unretained(loop.get())));
loop->Run();
return callback_error_ == CACHE_STORAGE_OK;
@@ -1038,6 +1042,39 @@ TEST_P(CacheStorageCacheTestP, TwoKeysThenOne) {
EXPECT_TRUE(VerifyKeys(expected_key));
}
+TEST_P(CacheStorageCacheTestP, KeysWithIgnoreSearchTrue) {
+ EXPECT_TRUE(Put(no_body_request_, no_body_response_));
+ EXPECT_TRUE(Put(body_request_, body_response_));
+ EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_));
+
+ CacheStorageCacheQueryParams match_params;
+ match_params.ignore_search = true;
+
+ EXPECT_TRUE(Keys(body_request_with_query_, match_params));
+ EXPECT_EQ(2u, callback_strings_.size());
+ std::vector<std::string> expected_keys = {
+ body_request_.url.spec(), body_request_with_query_.url.spec()};
+ EXPECT_TRUE(VerifyKeys(expected_keys));
+}
+
+TEST_P(CacheStorageCacheTestP, KeysWithIgnoreSearchFalse) {
+ EXPECT_TRUE(Put(no_body_request_, no_body_response_));
+ EXPECT_TRUE(Put(body_request_, body_response_));
+ EXPECT_TRUE(Put(body_request_with_query_, body_response_with_query_));
+
+ // Default value of ignore_search is false.
+ CacheStorageCacheQueryParams match_params;
+ match_params.ignore_search = false;
+ EXPECT_EQ(match_params.ignore_search,
+ CacheStorageCacheQueryParams().ignore_search);
+
+ EXPECT_TRUE(Keys(body_request_with_query_, match_params));
+ EXPECT_EQ(1u, callback_strings_.size());
+ std::vector<std::string> expected_keys = {
+ body_request_with_query_.url.spec()};
+ EXPECT_TRUE(VerifyKeys(expected_keys));
+}
+
TEST_P(CacheStorageCacheTestP, DeleteNoBody) {
EXPECT_TRUE(Put(no_body_request_, no_body_response_));
EXPECT_TRUE(Match(no_body_request_));
« no previous file with comments | « content/browser/cache_storage/cache_storage_cache.cc ('k') | content/browser/cache_storage/cache_storage_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698