summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/backend_unittest.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-14 18:48:15 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-14 18:48:15 +0000
commite31aab1840df828c907d32b41cc61b024e12e132 (patch)
treeb3e457e98d478a8d6b37bfaedc516f933ff41225 /net/disk_cache/backend_unittest.cc
parentdf9fd0d0bfef305243b90b193a6211ae64193fd5 (diff)
downloadchromium_src-e31aab1840df828c907d32b41cc61b024e12e132.zip
chromium_src-e31aab1840df828c907d32b41cc61b024e12e132.tar.gz
chromium_src-e31aab1840df828c907d32b41cc61b024e12e132.tar.bz2
Disk cache: Enable the code that sets the max size automatically.
(still limiting the ceiling). Review URL: http://codereview.chromium.org/68007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/backend_unittest.cc')
-rw-r--r--net/disk_cache/backend_unittest.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc
index a13762f..b18a5af 100644
--- a/net/disk_cache/backend_unittest.cc
+++ b/net/disk_cache/backend_unittest.cc
@@ -1040,3 +1040,33 @@ TEST_F(DiskCacheTest, MultipleInstances) {
entry->Close();
}
}
+
+// Test the four regions of the curve that determines the max cache size.
+TEST_F(DiskCacheTest, AutomaticMaxSize) {
+ const int kDefaultSize = 80 * 1024 * 1024;
+ int64 large_size = kDefaultSize;
+
+ EXPECT_EQ(kDefaultSize, disk_cache::PreferedCacheSize(large_size));
+ EXPECT_EQ((kDefaultSize / 2) * 8 / 10,
+ disk_cache::PreferedCacheSize(large_size / 2));
+
+ EXPECT_EQ(kDefaultSize, disk_cache::PreferedCacheSize(large_size * 2));
+ EXPECT_EQ(kDefaultSize, disk_cache::PreferedCacheSize(large_size * 4));
+ EXPECT_EQ(kDefaultSize, disk_cache::PreferedCacheSize(large_size * 10));
+
+ EXPECT_EQ(kDefaultSize * 2, disk_cache::PreferedCacheSize(large_size * 20));
+ EXPECT_EQ(kDefaultSize * 5 / 2,
+ disk_cache::PreferedCacheSize(large_size * 50 / 2));
+
+ EXPECT_EQ(kDefaultSize * 5 / 2,
+ disk_cache::PreferedCacheSize(large_size * 51 / 2));
+ EXPECT_EQ(kDefaultSize * 5 / 2,
+ disk_cache::PreferedCacheSize(large_size * 100 / 2));
+ EXPECT_EQ(kDefaultSize * 5 / 2,
+ disk_cache::PreferedCacheSize(large_size * 500 / 2));
+
+ EXPECT_EQ(kDefaultSize * 6 / 2,
+ disk_cache::PreferedCacheSize(large_size * 600 / 2));
+ EXPECT_EQ(kDefaultSize * 7 / 2,
+ disk_cache::PreferedCacheSize(large_size * 700 / 2));
+}