summaryrefslogtreecommitdiffstats
path: root/webkit/appcache
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-21 12:09:59 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-21 12:09:59 +0000
commit849d2167057a0bf54c95ca4f743e136555a13150 (patch)
tree70ad56e7af885ad312403d4f1642e57873d46c5b /webkit/appcache
parentead34cae2197353705a47f12572081446816c963 (diff)
downloadchromium_src-849d2167057a0bf54c95ca4f743e136555a13150.zip
chromium_src-849d2167057a0bf54c95ca4f743e136555a13150.tar.gz
chromium_src-849d2167057a0bf54c95ca4f743e136555a13150.tar.bz2
Merge MockQuotaManager in multiple places
- to share the single implementation in existing tests - to make it easier for writing new tests BUG=none TEST=existing tests Review URL: https://chromiumcodereview.appspot.com/10915202 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157964 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache')
-rw-r--r--webkit/appcache/appcache_storage_unittest.cc88
1 files changed, 28 insertions, 60 deletions
diff --git a/webkit/appcache/appcache_storage_unittest.cc b/webkit/appcache/appcache_storage_unittest.cc
index 8021e30..a5ad0b7 100644
--- a/webkit/appcache/appcache_storage_unittest.cc
+++ b/webkit/appcache/appcache_storage_unittest.cc
@@ -9,57 +9,19 @@
#include "webkit/appcache/appcache_response.h"
#include "webkit/appcache/appcache_storage.h"
#include "webkit/appcache/mock_appcache_service.h"
+#include "webkit/quota/mock_quota_manager.h"
namespace appcache {
+namespace {
+const quota::StorageType kTemp = quota::kStorageTypeTemporary;
+}
+
class AppCacheStorageTest : public testing::Test {
public:
class MockStorageDelegate : public AppCacheStorage::Delegate {
public:
};
-
- class MockQuotaManagerProxy : public quota::QuotaManagerProxy {
- public:
- MockQuotaManagerProxy()
- : QuotaManagerProxy(NULL, NULL),
- notify_storage_accessed_count_(0),
- notify_storage_modified_count_(0),
- last_delta_(0) {
- }
-
- virtual void NotifyStorageAccessed(quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type) OVERRIDE {
- EXPECT_EQ(quota::QuotaClient::kAppcache, client_id);
- EXPECT_EQ(quota::kStorageTypeTemporary, type);
- ++notify_storage_accessed_count_;
- last_origin_ = origin;
- }
-
- virtual void NotifyStorageModified(quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type,
- int64 delta) OVERRIDE {
- EXPECT_EQ(quota::QuotaClient::kAppcache, client_id);
- EXPECT_EQ(quota::kStorageTypeTemporary, type);
- ++notify_storage_modified_count_;
- last_origin_ = origin;
- last_delta_ = delta;
- }
-
- // Not needed for our tests.
- virtual void RegisterClient(quota::QuotaClient* client) OVERRIDE {}
- virtual void NotifyOriginInUse(const GURL& origin) OVERRIDE {}
- virtual void NotifyOriginNoLongerInUse(const GURL& origin) OVERRIDE {}
-
- int notify_storage_accessed_count_;
- int notify_storage_modified_count_;
- GURL last_origin_;
- int last_delta_;
-
- protected:
- virtual ~MockQuotaManagerProxy() {}
- };
};
TEST_F(AppCacheStorageTest, AddRemoveCache) {
@@ -155,41 +117,47 @@ TEST_F(AppCacheStorageTest, UsageMap) {
const GURL kOrigin2("http://origin2/");
MockAppCacheService service;
- scoped_refptr<MockQuotaManagerProxy> mock_proxy(new MockQuotaManagerProxy);
+ scoped_refptr<quota::MockQuotaManagerProxy> mock_proxy(
+ new quota::MockQuotaManagerProxy(NULL, NULL));
service.set_quota_manager_proxy(mock_proxy);
service.storage()->UpdateUsageMapAndNotify(kOrigin, 0);
- EXPECT_EQ(0, mock_proxy->notify_storage_modified_count_);
+ EXPECT_EQ(0, mock_proxy->notify_storage_modified_count());
service.storage()->UpdateUsageMapAndNotify(kOrigin, 10);
- EXPECT_EQ(1, mock_proxy->notify_storage_modified_count_);
- EXPECT_EQ(10, mock_proxy->last_delta_);
- EXPECT_EQ(kOrigin, mock_proxy->last_origin_);
+ EXPECT_EQ(1, mock_proxy->notify_storage_modified_count());
+ EXPECT_EQ(10, mock_proxy->last_notified_delta());
+ EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin());
+ EXPECT_EQ(kTemp, mock_proxy->last_notified_type());
service.storage()->UpdateUsageMapAndNotify(kOrigin, 100);
- EXPECT_EQ(2, mock_proxy->notify_storage_modified_count_);
- EXPECT_EQ(90, mock_proxy->last_delta_);
- EXPECT_EQ(kOrigin, mock_proxy->last_origin_);
+ EXPECT_EQ(2, mock_proxy->notify_storage_modified_count());
+ EXPECT_EQ(90, mock_proxy->last_notified_delta());
+ EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin());
+ EXPECT_EQ(kTemp, mock_proxy->last_notified_type());
service.storage()->UpdateUsageMapAndNotify(kOrigin, 0);
- EXPECT_EQ(3, mock_proxy->notify_storage_modified_count_);
- EXPECT_EQ(-100, mock_proxy->last_delta_);
- EXPECT_EQ(kOrigin, mock_proxy->last_origin_);
+ EXPECT_EQ(3, mock_proxy->notify_storage_modified_count());
+ EXPECT_EQ(-100, mock_proxy->last_notified_delta());
+ EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin());
+ EXPECT_EQ(kTemp, mock_proxy->last_notified_type());
service.storage()->NotifyStorageAccessed(kOrigin2);
- EXPECT_EQ(0, mock_proxy->notify_storage_accessed_count_);
+ EXPECT_EQ(0, mock_proxy->notify_storage_accessed_count());
service.storage()->usage_map_[kOrigin2] = 1;
service.storage()->NotifyStorageAccessed(kOrigin2);
- EXPECT_EQ(1, mock_proxy->notify_storage_accessed_count_);
- EXPECT_EQ(kOrigin2, mock_proxy->last_origin_);
+ EXPECT_EQ(1, mock_proxy->notify_storage_accessed_count());
+ EXPECT_EQ(kOrigin2, mock_proxy->last_notified_origin());
+ EXPECT_EQ(kTemp, mock_proxy->last_notified_type());
service.storage()->usage_map_.clear();
service.storage()->usage_map_[kOrigin] = 5000;
service.storage()->ClearUsageMapAndNotify();
- EXPECT_EQ(4, mock_proxy->notify_storage_modified_count_);
- EXPECT_EQ(-5000, mock_proxy->last_delta_);
- EXPECT_EQ(kOrigin, mock_proxy->last_origin_);
+ EXPECT_EQ(4, mock_proxy->notify_storage_modified_count());
+ EXPECT_EQ(-5000, mock_proxy->last_notified_delta());
+ EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin());
+ EXPECT_EQ(kTemp, mock_proxy->last_notified_type());
EXPECT_TRUE(service.storage()->usage_map_.empty());
}