Index: webkit/fileapi/sandbox_quota_client_unittest.cc |
diff --git a/webkit/fileapi/sandbox_quota_client_unittest.cc b/webkit/fileapi/sandbox_quota_client_unittest.cc |
index c77e42340f363330e3dd7b8060266a6ff3c3d580..276214893c41d2f67a3993a4e37b606d4d3f0ebe 100644 |
--- a/webkit/fileapi/sandbox_quota_client_unittest.cc |
+++ b/webkit/fileapi/sandbox_quota_client_unittest.cc |
@@ -43,7 +43,8 @@ class SandboxQuotaClientTest : public testing::Test { |
public: |
SandboxQuotaClientTest() |
: callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
- additional_callback_count_(0) { |
+ additional_callback_count_(0), |
+ quota_status_(quota::kQuotaStatusUnknown) { |
} |
void SetUp() { |
@@ -176,7 +177,18 @@ class SandboxQuotaClientTest : public testing::Test { |
} |
} |
+ void DeleteOriginData(SandboxQuotaClient* quota_client, |
+ const char* origin, |
+ quota::StorageType type) { |
+ quota_status_ = quota::kQuotaStatusUnknown; |
+ quota_client->DeleteOriginData( |
+ GURL(origin), type, |
+ callback_factory_.NewCallback( |
+ &SandboxQuotaClientTest::OnDeleteOrigin)); |
+ } |
+ |
int64 usage() const { return usage_; } |
+ quota::QuotaStatusCode status(){ return quota_status_; } |
michaeln
2011/05/13 07:28:02
maybe delete_status_ and delete_status()
tzik (google)
2011/05/13 14:22:24
Done.
|
int additional_callback_count() const { return additional_callback_count_; } |
void set_additional_callback_count(int count) { |
additional_callback_count_ = count; |
@@ -195,12 +207,17 @@ class SandboxQuotaClientTest : public testing::Test { |
++additional_callback_count_; |
} |
+ void OnDeleteOrigin(quota::QuotaStatusCode status) { |
+ quota_status_ = status; |
+ } |
+ |
ScopedTempDir data_dir_; |
scoped_refptr<FileSystemContext> file_system_context_; |
base::ScopedCallbackFactory<SandboxQuotaClientTest> callback_factory_; |
int64 usage_; |
int additional_callback_count_; |
std::set<GURL> origins_; |
+ quota::QuotaStatusCode quota_status_; |
DISALLOW_COPY_AND_ASSIGN(SandboxQuotaClientTest); |
}; |
@@ -429,3 +446,54 @@ TEST_F(SandboxQuotaClientTest, IncognitoTest) { |
origins = GetOriginsForHost(quota_client.get(), kTemporary, "www.dummy.org"); |
EXPECT_EQ(0U, origins.size()); |
} |
+ |
+TEST_F(SandboxQuotaClientTest, DeleteOriginTest) { |
+ scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(false)); |
+ const TestFile kFiles[] = { |
+ {true, NULL, 0, "http://foo.com/", kTemporary}, |
+ {false, "a", 1, "http://foo.com/", kTemporary}, |
+ {true, NULL, 0, "https://foo.com/", kTemporary}, |
+ {false, "b", 2, "https://foo.com/", kTemporary}, |
+ {true, NULL, 0, "http://foo.com/", kPersistent}, |
+ {false, "c", 4, "http://foo.com/", kPersistent}, |
+ {true, NULL, 0, "http://bar.com/", kTemporary}, |
+ {false, "d", 8, "http://bar.com/", kTemporary}, |
+ {true, NULL, 0, "http://bar.com/", kPersistent}, |
+ {false, "e", 16, "http://bar.com/", kPersistent}, |
+ {true, NULL, 0, "https://bar.com/", kPersistent}, |
+ {false, "f", 32, "https://bar.com/", kPersistent}, |
+ {true, NULL, 0, "https://bar.com/", kTemporary}, |
+ {false, "g", 64, "https://bar.com/", kTemporary}, |
+ }; |
+ CreateFiles(kFiles,ARRAYSIZE_UNSAFE(kFiles)); |
michaeln
2011/05/13 07:28:02
missing space before,ARRAY (why does lint not run?
tzik (google)
2011/05/13 14:22:24
Done.
Thanks, I'll try it.
|
+ |
+ DeleteOriginData(quota_client.get(), "http://foo.com/", kTemporary); |
+ MessageLoop::current()->RunAllPending(); |
+ EXPECT_EQ(quota::kQuotaStatusOk, status()); |
+ |
+ DeleteOriginData(quota_client.get(), "http://bar.com/", kPersistent); |
+ MessageLoop::current()->RunAllPending(); |
+ EXPECT_EQ(quota::kQuotaStatusOk, status()); |
+ |
+ DeleteOriginData(quota_client.get(), "http://buz.com/", kTemporary); |
+ MessageLoop::current()->RunAllPending(); |
+ EXPECT_EQ(quota::kQuotaStatusOk, status()); |
+ |
+ EXPECT_EQ(0, GetOriginUsage( |
+ quota_client.get(), "http://foo.com/", kTemporary)); |
+ EXPECT_EQ(0, GetOriginUsage( |
+ quota_client.get(), "http://bar.com/", kPersistent)); |
+ EXPECT_EQ(0, GetOriginUsage( |
+ quota_client.get(), "http://buz.com/", kTemporary)); |
+ |
+ EXPECT_EQ(2 + kUsageFileSize, |
+ GetOriginUsage(quota_client.get(), "https://foo.com/", kTemporary)); |
+ EXPECT_EQ(4 + kUsageFileSize, |
+ GetOriginUsage(quota_client.get(), "http://foo.com/", kPersistent)); |
kinuko
2011/05/13 07:26:00
style-nit: over 80 chars
michaeln
2011/05/13 07:28:02
line length
tzik (google)
2011/05/13 14:22:24
Done.
|
+ EXPECT_EQ(8 + kUsageFileSize, |
+ GetOriginUsage(quota_client.get(), "http://bar.com/", kTemporary)); |
+ EXPECT_EQ(32 + kUsageFileSize, |
+ GetOriginUsage(quota_client.get(), "https://bar.com/", kPersistent)); |
kinuko
2011/05/13 07:26:00
ditto
michaeln
2011/05/13 07:28:02
line length
tzik (google)
2011/05/13 14:22:24
Done.
|
+ EXPECT_EQ(64 + kUsageFileSize, |
+ GetOriginUsage(quota_client.get(), "https://bar.com/", kTemporary)); |
+} |