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

Unified Diff: content/browser/service_worker/service_worker_cache_unittest.cc

Issue 672943002: [ServiceWorkerCache] Return the real size of the cache in GetOriginUsage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@quota_modified
Patch Set: Address comments from PS5 Created 6 years, 2 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/service_worker/service_worker_cache_storage_manager_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_cache_unittest.cc
diff --git a/content/browser/service_worker/service_worker_cache_unittest.cc b/content/browser/service_worker/service_worker_cache_unittest.cc
index 2ed040e3d1cdec62f30431cd3fbd7969c8d97780..0920ed980c8c34069e1b739dd12bc478f0ddf52b 100644
--- a/content/browser/service_worker/service_worker_cache_unittest.cc
+++ b/content/browser/service_worker/service_worker_cache_unittest.cc
@@ -300,6 +300,12 @@ class ServiceWorkerCacheTestP : public ServiceWorkerCacheTest,
bool MemoryOnly() override { return !GetParam(); }
};
+class ServiceWorkerCacheMemoryOnlyTest
+ : public ServiceWorkerCacheTest,
+ public testing::WithParamInterface<bool> {
+ bool MemoryOnly() override { return true; }
+};
+
TEST_P(ServiceWorkerCacheTestP, PutNoBody) {
EXPECT_TRUE(Put(no_body_request_, no_body_response_));
EXPECT_TRUE(callback_response_);
@@ -565,6 +571,28 @@ TEST_P(ServiceWorkerCacheTestP, QuotaManagerModified) {
EXPECT_EQ(0, sum_delta);
}
+TEST_F(ServiceWorkerCacheMemoryOnlyTest, MemoryBackedSize) {
+ EXPECT_EQ(0, cache_->MemoryBackedSize());
+ EXPECT_TRUE(Put(no_body_request_, no_body_response_));
+ EXPECT_LT(0, cache_->MemoryBackedSize());
+ int64 no_body_size = cache_->MemoryBackedSize();
+
+ EXPECT_TRUE(Delete(no_body_request_));
+ EXPECT_EQ(0, cache_->MemoryBackedSize());
+
+ EXPECT_TRUE(Put(body_request_, body_response_));
+ EXPECT_LT(no_body_size, cache_->MemoryBackedSize());
+
+ EXPECT_TRUE(Delete(body_request_));
+ EXPECT_EQ(0, cache_->MemoryBackedSize());
+}
+
+TEST_F(ServiceWorkerCacheTest, MemoryBackedSizePersistent) {
+ EXPECT_EQ(0, cache_->MemoryBackedSize());
+ EXPECT_TRUE(Put(no_body_request_, no_body_response_));
+ EXPECT_EQ(0, cache_->MemoryBackedSize());
+}
+
INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest,
ServiceWorkerCacheTestP,
::testing::Values(false, true));
« no previous file with comments | « content/browser/service_worker/service_worker_cache_storage_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698