| Index: webkit/quota/quota_manager_unittest.cc
|
| diff --git a/webkit/quota/quota_manager_unittest.cc b/webkit/quota/quota_manager_unittest.cc
|
| index 171f6b40c0aae2bacb82533c11d2016546cf724d..d8f3ebe7487f547f7520f6ffe2218a3d7a01f920 100644
|
| --- a/webkit/quota/quota_manager_unittest.cc
|
| +++ b/webkit/quota/quota_manager_unittest.cc
|
| @@ -33,6 +33,27 @@ const StorageType kPerm = kStorageTypePersistent;
|
|
|
| const int kAllClients = QuotaClient::kAllClientsMask;
|
|
|
| +//
|
| +class TestQuotaManager : public QuotaManager {
|
| + public:
|
| + TestQuotaManager(bool is_incognito,
|
| + const FilePath& profile_path,
|
| + base::SingleThreadTaskRunner* io_thread,
|
| + base::SequencedTaskRunner* db_thread,
|
| + SpecialStoragePolicy* special_storage_policy)
|
| + : QuotaManager(is_incognito, profile_path, io_thread, db_thread,
|
| + special_storage_policy) {
|
| + }
|
| +
|
| + // QuotaManager implementation.
|
| + virtual int64 GetAvailableDiskSpace() const {
|
| + return 13377331;
|
| + }
|
| +
|
| + private:
|
| + ~TestQuotaManager() { printf("~TestQuotaManager\n"); };
|
| +};
|
| +
|
| class QuotaManagerTest : public testing::Test {
|
| protected:
|
| typedef QuotaManager::QuotaTableEntry QuotaTableEntry;
|
| @@ -42,13 +63,22 @@ class QuotaManagerTest : public testing::Test {
|
| public:
|
| QuotaManagerTest()
|
| : weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
|
| + quota_status_(kQuotaStatusUnknown),
|
| + type_(kStorageTypeUnknown),
|
| + usage_(0),
|
| + unlimited_usage_(0),
|
| + quota_(0),
|
| + available_space_(0),
|
| + modified_origins_type_(kStorageTypeUnknown),
|
| + status_callback_count_(0),
|
| + additional_callback_count_(0),
|
| mock_time_counter_(0) {
|
| }
|
|
|
| void SetUp() {
|
| ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
|
| mock_special_storage_policy_ = new MockSpecialStoragePolicy;
|
| - quota_manager_ = new QuotaManager(
|
| + quota_manager_ = new TestQuotaManager(
|
| false /* is_incognito */,
|
| data_dir_.path(),
|
| MessageLoopProxy::current(),
|
| @@ -282,6 +312,7 @@ class QuotaManagerTest : public testing::Test {
|
| }
|
|
|
| void DidGetUsageAndQuota(QuotaStatusCode status, int64 usage, int64 quota) {
|
| + printf("DidGetUsageAndQuota\n");
|
| quota_status_ = status;
|
| usage_ = usage;
|
| quota_ = quota;
|
| @@ -365,8 +396,9 @@ class QuotaManagerTest : public testing::Test {
|
| ++additional_callback_count_;
|
| }
|
|
|
| - QuotaManager* quota_manager() const { return quota_manager_.get(); }
|
| - void set_quota_manager(QuotaManager* quota_manager) {
|
| + TestQuotaManager* quota_manager() const { return /*quota_manager_.get();*/NULL; }
|
| + void set_quota_manager(TestQuotaManager* quota_manager) {
|
| + printf("set_quota_manager: %p\n", quota_manager);
|
| quota_manager_ = quota_manager;
|
| }
|
|
|
| @@ -403,7 +435,7 @@ class QuotaManagerTest : public testing::Test {
|
| ScopedTempDir data_dir_;
|
| base::WeakPtrFactory<QuotaManagerTest> weak_factory_;
|
|
|
| - scoped_refptr<QuotaManager> quota_manager_;
|
| + scoped_refptr<TestQuotaManager> quota_manager_;
|
| scoped_refptr<MockSpecialStoragePolicy> mock_special_storage_policy_;
|
|
|
| QuotaStatusCode quota_status_;
|
| @@ -621,17 +653,24 @@ TEST_F(QuotaManagerTest, GetUsage_MultipleClients) {
|
| EXPECT_EQ(kQuotaStatusOk, status());
|
| EXPECT_EQ(50, usage());
|
|
|
| + GetAvailableSpace();
|
| + MessageLoop::current()->RunAllPending();
|
| + EXPECT_EQ(kQuotaStatusOk, status());
|
| + EXPECT_LE(0, available_space());
|
| +
|
| GetUsageAndQuota(GURL("http://unlimited/"), kTemp);
|
| MessageLoop::current()->RunAllPending();
|
| EXPECT_EQ(kQuotaStatusOk, status());
|
| EXPECT_EQ(1, usage());
|
| - EXPECT_EQ(kint64max, quota());
|
| + EXPECT_EQ(available_space(), quota());
|
|
|
| + printf("before\n");
|
| GetUsageAndQuota(GURL("http://unlimited/"), kPerm);
|
| MessageLoop::current()->RunAllPending();
|
| + printf("after\n");
|
| EXPECT_EQ(kQuotaStatusOk, status());
|
| EXPECT_EQ(1, usage());
|
| - EXPECT_EQ(kint64max, quota());
|
| + EXPECT_EQ(available_space(), quota());
|
|
|
| GetGlobalUsage(kTemp);
|
| MessageLoop::current()->RunAllPending();
|
| @@ -792,7 +831,7 @@ TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_Unlimited) {
|
| QuotaClient::kFileSystem);
|
| RegisterClient(client);
|
|
|
| - // Test when not overbugdet.
|
| + // Test when not over budget.
|
| SetTemporaryGlobalQuota(1000);
|
| MessageLoop::current()->RunAllPending();
|
|
|
| @@ -816,13 +855,18 @@ TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_Unlimited) {
|
| EXPECT_EQ(50, usage());
|
| EXPECT_EQ(kPerHostQuotaFor1000, quota());
|
|
|
| + GetAvailableSpace();
|
| + MessageLoop::current()->RunAllPending();
|
| + EXPECT_EQ(kQuotaStatusOk, status());
|
| + EXPECT_LE(0, available_space());
|
| +
|
| GetUsageAndQuota(GURL("http://unlimited/"), kTemp);
|
| MessageLoop::current()->RunAllPending();
|
| EXPECT_EQ(kQuotaStatusOk, status());
|
| EXPECT_EQ(4000, usage());
|
| - EXPECT_EQ(kint64max, quota());
|
| + EXPECT_EQ(available_space(), quota());
|
|
|
| - // Test when overbugdet.
|
| + // Test when over budget.
|
| SetTemporaryGlobalQuota(100);
|
| MessageLoop::current()->RunAllPending();
|
|
|
| @@ -841,11 +885,16 @@ TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_Unlimited) {
|
| EXPECT_EQ(50, usage());
|
| EXPECT_EQ(kPerHostQuotaFor100, quota());
|
|
|
| + GetAvailableSpace();
|
| + MessageLoop::current()->RunAllPending();
|
| + EXPECT_EQ(kQuotaStatusOk, status());
|
| + EXPECT_LE(0, available_space());
|
| +
|
| GetUsageAndQuota(GURL("http://unlimited/"), kTemp);
|
| MessageLoop::current()->RunAllPending();
|
| EXPECT_EQ(kQuotaStatusOk, status());
|
| EXPECT_EQ(4000, usage());
|
| - EXPECT_EQ(kint64max, quota());
|
| + EXPECT_EQ(available_space(), quota());
|
|
|
| // Revoke the unlimited rights and make sure the change is noticed.
|
| mock_special_storage_policy()->Reset();
|
|
|