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

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: Created 4 years, 10 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 505f9bd827887ed5da21340bed62fce76e6fff9d..0729674990e5f7b788c3c8d6534b6968246c9f73 100644
--- a/content/browser/cache_storage/cache_storage_cache_unittest.cc
+++ b/content/browser/cache_storage/cache_storage_cache_unittest.cc
@@ -421,12 +421,16 @@ class CacheStorageCacheTest : public testing::Test {
return error == CACHE_STORAGE_OK;
}
- bool Keys() {
+ bool Keys(
+ const ServiceWorkerFetchRequest& request = ServiceWorkerFetchRequest(),
+ const CacheStorageCacheQueryParams& match_params =
+ CacheStorageCacheQueryParams()) {
scoped_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;
@@ -923,6 +927,40 @@ 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;
+ expected_keys.push_back(body_request_.url.spec());
+ expected_keys.push_back(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;
+ expected_keys.push_back(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_));

Powered by Google App Engine
This is Rietveld 408576698