| 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
|
|
|