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

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: Renamed On... to Did... 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
« no previous file with comments | « 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..697b0d6dab4739ca8df313fc67cf1e422a32fc96 100644
--- a/webkit/quota/quota_manager_unittest.cc
+++ b/webkit/quota/quota_manager_unittest.cc
@@ -132,13 +132,21 @@ class QuotaManagerTest : public testing::Test {
&QuotaManagerTest::DidGetUsageAndQuotaAdditional));
}
- void DeleteOriginData(QuotaClient* client,
+ void DeleteClientOriginData(QuotaClient* client,
const GURL& origin,
StorageType type) {
quota_status_ = kQuotaStatusUnknown;
client->DeleteOriginData(origin, type,
callback_factory_.NewCallback(
- &QuotaManagerTest::DidDelete));
+ &QuotaManagerTest::DidDeleteClientOriginData));
+ }
+
+ void EvictOriginData(const GURL& origin,
+ StorageType type) {
+ quota_status_ = kQuotaStatusUnknown;
+ quota_manager_->EvictOriginData(origin, type,
+ callback_factory_.NewCallback(
+ &QuotaManagerTest::DidEvictOriginData));
}
void GetAvailableSpace() {
@@ -175,7 +183,11 @@ class QuotaManagerTest : public testing::Test {
usage_ = usage;
}
- void DidDelete(QuotaStatusCode status) {
+ void DidDeleteClientOriginData(QuotaStatusCode status) {
+ quota_status_ = status;
+ }
+
+ void DidEvictOriginData(QuotaStatusCode status) {
quota_status_ = status;
}
@@ -711,7 +723,8 @@ TEST_F(QuotaManagerTest, GetUsage_WithDeleteOrigin) {
MessageLoop::current()->RunAllPending();
int64 predelete_host_pers = usage();
- DeleteOriginData(client, GURL("http://foo.com/"), kStorageTypeTemporary);
+ DeleteClientOriginData(client, GURL("http://foo.com/"),
+ kStorageTypeTemporary);
MessageLoop::current()->RunAllPending();
EXPECT_EQ(kQuotaStatusOk, status());
@@ -736,4 +749,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
« no previous file with comments | « webkit/quota/quota_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698