Index: webkit/quota/quota_manager_unittest.cc |
diff --git a/webkit/quota/quota_manager_unittest.cc b/webkit/quota/quota_manager_unittest.cc |
index fd6e671487329d204f82db894ddcf1ae92aa36a2..3c519b418d78d1111bfa3c57c26382239aa29e5f 100644 |
--- a/webkit/quota/quota_manager_unittest.cc |
+++ b/webkit/quota/quota_manager_unittest.cc |
@@ -4,8 +4,6 @@ |
#include <vector> |
-#include "testing/gtest/include/gtest/gtest.h" |
- |
#include "base/file_util.h" |
#include "base/memory/scoped_callback_factory.h" |
#include "base/memory/scoped_ptr.h" |
@@ -13,6 +11,7 @@ |
#include "base/message_loop.h" |
#include "base/message_loop_proxy.h" |
#include "base/stl_util-inl.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaError.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaType.h" |
#include "webkit/quota/mock_storage_client.h" |
@@ -132,6 +131,15 @@ class QuotaManagerTest : public testing::Test { |
&QuotaManagerTest::DidGetUsageAndQuotaAdditional)); |
} |
+ void DeleteOriginData(QuotaClient* client, |
+ const GURL& origin, |
+ StorageType type) { |
+ quota_status_ = kQuotaStatusUnknown; |
+ client->DeleteOriginData(origin, type, |
+ callback_factory_.NewCallback( |
+ &QuotaManagerTest::DidDelete)); |
+ } |
+ |
void DidGetUsageAndQuota(QuotaStatusCode status, int64 usage, int64 quota) { |
quota_status_ = status; |
usage_ = usage; |
@@ -158,6 +166,10 @@ class QuotaManagerTest : public testing::Test { |
usage_ = usage; |
} |
+ void DidDelete(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( |
@@ -667,4 +679,43 @@ TEST_F(QuotaManagerTest, GetUsage_WithModification) { |
EXPECT_EQ(usage(), 4000 + 50000 + 900000000); |
} |
+TEST_F(QuotaManagerTest, GetUsage_WithDeleteOrigin) { |
+ static const MockOriginData kData[] = { |
+ { "http://foo.com/", kStorageTypeTemporary, 1 }, |
+ { "http://foo.com:1/", kStorageTypeTemporary, 20 }, |
+ { "http://foo.com/", kStorageTypePersistent, 300 }, |
+ { "http://bar.com/", kStorageTypeTemporary, 4000 }, |
+ }; |
+ MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData)); |
+ RegisterClient(client); |
+ |
+ 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(); |
+ |
+ DeleteOriginData(client, GURL("http://foo.com/"), kStorageTypeTemporary); |
+ MessageLoop::current()->RunAllPending(); |
+ EXPECT_EQ(kQuotaStatusOk, status()); |
+ |
+ GetGlobalUsage(kStorageTypeTemporary); |
+ MessageLoop::current()->RunAllPending(); |
+ EXPECT_EQ(predelete_global_tmp - 1, usage()); |
+ |
+ GetHostUsage("foo.com", kStorageTypeTemporary); |
+ MessageLoop::current()->RunAllPending(); |
+ EXPECT_EQ(predelete_host_tmp - 1, usage()); |
+ |
+ GetHostUsage("foo.com", kStorageTypePersistent); |
+ MessageLoop::current()->RunAllPending(); |
+ EXPECT_EQ(predelete_host_pers, usage()); |
+} |
+ |
} // namespace quota |