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

Unified Diff: webkit/quota/quota_manager_unittest.cc

Issue 7029007: Implement EvictOriginData in QuotaManager. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed, updated the test, and reflected the comments. Created 9 years, 7 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
« webkit/quota/quota_manager.cc ('K') | « webkit/quota/quota_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/quota/quota_manager_unittest.cc
diff --git a/webkit/quota/quota_manager_unittest.cc b/webkit/quota/quota_manager_unittest.cc
index 7d09c3c947239fc34a16241e9fef3726d168d237..e4f3a5c292725b22ec6abd27d9fc92be6db4119a 100644
--- a/webkit/quota/quota_manager_unittest.cc
+++ b/webkit/quota/quota_manager_unittest.cc
@@ -141,6 +141,14 @@ class QuotaManagerTest : public testing::Test {
&QuotaManagerTest::DidDelete));
}
+ void EvictOriginData(const GURL& origin,
+ StorageType type) {
+ quota_status_ = kQuotaStatusUnknown;
+ quota_manager_->EvictOriginData(origin, type,
+ callback_factory_.NewCallback(
+ &QuotaManagerTest::DidEvict));
+ }
+
void GetAvailableSpace() {
quota_status_ = kQuotaStatusUnknown;
quota_ = -1;
@@ -179,6 +187,10 @@ class QuotaManagerTest : public testing::Test {
quota_status_ = status;
}
+ void DidEvict(QuotaStatusCode status) {
+ quota_status_ = status;
+ }
+
void set_additional_callback_count(int c) { additional_callback_count_ = c; }
int additional_callback_count() const { return additional_callback_count_; }
void DidGetUsageAndQuotaAdditional(
@@ -736,4 +748,52 @@ TEST_F(QuotaManagerTest, GetAvailableSpaceTest) {
int64 direct_called = base::SysInfo::AmountOfFreeDiskSpace(profile_path());
EXPECT_EQ(direct_called, quota());
}
+
+TEST_F(QuotaManagerTest, EvictOriginData) {
+ static const MockOriginData kData1[] = {
+ { "http://foo.com/", kStorageTypeTemporary, 1 },
+ { "http://foo.com:1/", kStorageTypeTemporary, 20 },
+ { "http://foo.com/", kStorageTypePersistent, 300 },
+ { "http://bar.com/", kStorageTypeTemporary, 4000 },
+ };
+ static const MockOriginData kData2[] = {
+ { "http://foo.com/", kStorageTypeTemporary, 50000 },
+ { "http://foo.com:1/", kStorageTypeTemporary, 6000 },
+ { "http://foo.com/", kStorageTypePersistent, 700 },
+ { "https://foo.com/", kStorageTypeTemporary, 80 },
+ { "http://bar.com/", kStorageTypeTemporary, 9 },
+ };
+ MockStorageClient* client1 = CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1));
+ MockStorageClient* client2 = CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2));
+ RegisterClient(client1);
+ RegisterClient(client2);
+
+ GetGlobalUsage(kStorageTypeTemporary);
+ MessageLoop::current()->RunAllPending();
+ int64 predelete_global_tmp = usage();
+
+ GetHostUsage("foo.com", kStorageTypeTemporary);
+ MessageLoop::current()->RunAllPending();
+ int64 predelete_host_tmp = usage();
+
+ GetHostUsage("foo.com", kStorageTypePersistent);
+ MessageLoop::current()->RunAllPending();
+ int64 predelete_host_pers = usage();
+
+ EvictOriginData(GURL("http://foo.com/"), kStorageTypeTemporary);
+ MessageLoop::current()->RunAllPending();
+
+ GetGlobalUsage(kStorageTypeTemporary);
+ MessageLoop::current()->RunAllPending();
+ EXPECT_EQ(predelete_global_tmp - (1 + 50000), usage());
+
+ GetHostUsage("foo.com", kStorageTypeTemporary);
+ MessageLoop::current()->RunAllPending();
+ EXPECT_EQ(predelete_host_tmp - (1 + 50000), usage());
+
+ GetHostUsage("foo.com", kStorageTypePersistent);
+ MessageLoop::current()->RunAllPending();
+ EXPECT_EQ(predelete_host_pers, usage());
+}
+
} // namespace quota
« webkit/quota/quota_manager.cc ('K') | « webkit/quota/quota_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698