| 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..5986c85f5798bbe4055088463e60aca763fa77e2 100644
|
| --- a/webkit/quota/quota_manager_unittest.cc
|
| +++ b/webkit/quota/quota_manager_unittest.cc
|
| @@ -149,6 +149,16 @@ class QuotaManagerTest : public testing::Test {
|
| &QuotaManagerTest::DidGetQuota));
|
| }
|
|
|
| + void GetUsageAndQuotaForEviction() {
|
| + quota_status_ = kQuotaStatusUnknown;
|
| + usage_ = -1;
|
| + quota_ = -1;
|
| + available_space_ = -1;
|
| + quota_manager_->GetUsageAndQuotaForEviction(
|
| + callback_factory_.NewCallback(
|
| + &QuotaManagerTest::DidGetUsageAndQuotaForEviction));
|
| + }
|
| +
|
| void DidGetUsageAndQuota(QuotaStatusCode status, int64 usage, int64 quota) {
|
| quota_status_ = status;
|
| usage_ = usage;
|
| @@ -175,6 +185,14 @@ class QuotaManagerTest : public testing::Test {
|
| usage_ = usage;
|
| }
|
|
|
| + void DidGetUsageAndQuotaForEviction(QuotaStatusCode status,
|
| + int64 usage, int64 quota, int64 available_space) {
|
| + quota_status_ = status;
|
| + usage_ = usage;
|
| + quota_ = quota;
|
| + available_space_ = available_space;
|
| + }
|
| +
|
| void DidDelete(QuotaStatusCode status) {
|
| quota_status_ = status;
|
| }
|
| @@ -194,6 +212,7 @@ class QuotaManagerTest : public testing::Test {
|
| QuotaStatusCode status() const { return quota_status_; }
|
| int64 usage() const { return usage_; }
|
| int64 quota() const { return quota_; }
|
| + int64 available_space() const { return available_space_; }
|
| FilePath profile_path() const { return data_dir_.path(); }
|
|
|
| private:
|
| @@ -206,6 +225,7 @@ class QuotaManagerTest : public testing::Test {
|
| std::string host_;
|
| int64 usage_;
|
| int64 quota_;
|
| + int64 available_space_;
|
|
|
| int additional_callback_count_;
|
|
|
| @@ -736,4 +756,29 @@ TEST_F(QuotaManagerTest, GetAvailableSpaceTest) {
|
| int64 direct_called = base::SysInfo::AmountOfFreeDiskSpace(profile_path());
|
| EXPECT_EQ(direct_called, quota());
|
| }
|
| +
|
| +TEST_F(QuotaManagerTest, GetUsageAndQuotaForEviction) {
|
| + 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);
|
| +
|
| + SetTemporaryGlobalQuota(10000000);
|
| + MessageLoop::current()->RunAllPending();
|
| +
|
| + GetUsageAndQuotaForEviction();
|
| + MessageLoop::current()->RunAllPending();
|
| + EXPECT_EQ(kQuotaStatusOk, status());
|
| + EXPECT_EQ(4021, usage());
|
| + EXPECT_EQ(10000000, quota());
|
| +
|
| + // TODO(dmikurube): It might be flaky? (Also in GetAvailableSpaceTest.)
|
| + int64 direct_called = base::SysInfo::AmountOfFreeDiskSpace(profile_path());
|
| + EXPECT_EQ(direct_called, available_space());
|
| +}
|
| +
|
| } // namespace quota
|
|
|