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

Unified Diff: webkit/quota/quota_manager_unittest.cc

Issue 7039006: Implement GetUsageAndQuotaForEviction in QuotaManager. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Added a TODO. 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 697b0d6dab4739ca8df313fc67cf1e422a32fc96..ad32304eab8ba647a64dc881136c475d1b2ccf5b 100644
--- a/webkit/quota/quota_manager_unittest.cc
+++ b/webkit/quota/quota_manager_unittest.cc
@@ -151,10 +151,20 @@ class QuotaManagerTest : public testing::Test {
void GetAvailableSpace() {
quota_status_ = kQuotaStatusUnknown;
- quota_ = -1;
+ available_space_ = -1;
quota_manager_->GetAvailableSpace(
callback_factory_.NewCallback(
- &QuotaManagerTest::DidGetQuota));
+ &QuotaManagerTest::DidGetAvailableSpace));
+ }
+
+ 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) {
@@ -168,6 +178,11 @@ class QuotaManagerTest : public testing::Test {
quota_ = quota;
}
+ void DidGetAvailableSpace(QuotaStatusCode status, int64 available_space) {
+ quota_status_ = status;
+ available_space_ = available_space;
+ }
+
void DidGetHostQuota(QuotaStatusCode status,
const std::string& host, int64 quota) {
quota_status_ = status;
@@ -191,6 +206,14 @@ class QuotaManagerTest : public testing::Test {
quota_status_ = status;
}
+ void DidGetUsageAndQuotaForEviction(QuotaStatusCode status,
+ int64 usage, int64 quota, int64 available_space) {
+ quota_status_ = status;
+ usage_ = usage;
+ quota_ = quota;
+ available_space_ = available_space;
+ }
+
void set_additional_callback_count(int c) { additional_callback_count_ = c; }
int additional_callback_count() const { return additional_callback_count_; }
void DidGetUsageAndQuotaAdditional(
@@ -206,6 +229,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:
@@ -218,6 +242,7 @@ class QuotaManagerTest : public testing::Test {
std::string host_;
int64 usage_;
int64 quota_;
+ int64 available_space_;
int additional_callback_count_;
@@ -745,9 +770,7 @@ TEST_F(QuotaManagerTest, GetAvailableSpaceTest) {
GetAvailableSpace();
MessageLoop::current()->RunAllPending();
EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_LE(0, quota());
- int64 direct_called = base::SysInfo::AmountOfFreeDiskSpace(profile_path());
- EXPECT_EQ(direct_called, quota());
+ EXPECT_LE(0, available_space());
}
TEST_F(QuotaManagerTest, EvictOriginData) {
@@ -797,4 +820,26 @@ TEST_F(QuotaManagerTest, EvictOriginData) {
EXPECT_EQ(predelete_host_pers, usage());
}
+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());
+ EXPECT_LE(0, available_space());
+}
+
} // 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