summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_host_unittest.cc
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-16 18:39:39 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-16 18:39:39 +0000
commit9830d77aa9cc9efd03d64226b15cfd94c39e66f8 (patch)
tree939166dbdc360b3c7d596cc2cef95803df82ac59 /webkit/appcache/appcache_host_unittest.cc
parent59e414ef3fbd4551cc17a7cece753946357b8f63 (diff)
downloadchromium_src-9830d77aa9cc9efd03d64226b15cfd94c39e66f8.zip
chromium_src-9830d77aa9cc9efd03d64226b15cfd94c39e66f8.tar.gz
chromium_src-9830d77aa9cc9efd03d64226b15cfd94c39e66f8.tar.bz2
Enough appcache + quota integration to call NotifyOriginInUse/NotifyOriginNoLongerInUse when frames are loaded/unloaded.
BUG=61676 TEST=appcache_host_unittest.cc Review URL: http://codereview.chromium.org/6999008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85507 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_host_unittest.cc')
-rw-r--r--webkit/appcache/appcache_host_unittest.cc75
1 files changed, 60 insertions, 15 deletions
diff --git a/webkit/appcache/appcache_host_unittest.cc b/webkit/appcache/appcache_host_unittest.cc
index d648e07..762ed9c 100644
--- a/webkit/appcache/appcache_host_unittest.cc
+++ b/webkit/appcache/appcache_host_unittest.cc
@@ -11,6 +11,7 @@
#include "webkit/appcache/appcache_group.h"
#include "webkit/appcache/appcache_host.h"
#include "webkit/appcache/mock_appcache_service.h"
+#include "webkit/quota/quota_manager.h"
namespace appcache {
@@ -76,6 +77,40 @@ class AppCacheHostTest : public testing::Test {
appcache::EventID last_event_id_;
};
+ class MockQuotaManagerProxy : public quota::QuotaManagerProxy {
+ public:
+ MockQuotaManagerProxy() : QuotaManagerProxy(NULL, NULL) {}
+
+ // Not needed for our tests.
+ virtual void RegisterClient(quota::QuotaClient* client) {}
+ virtual void NotifyStorageAccessed(quota::QuotaClient::ID client_id,
+ const GURL& origin,
+ quota::StorageType type) {}
+ virtual void NotifyStorageModified(quota::QuotaClient::ID client_id,
+ const GURL& origin,
+ quota::StorageType type,
+ int64 delta) {}
+
+ virtual void NotifyOriginInUse(const GURL& origin) {
+ inuse_[origin] += 1;
+ }
+
+ virtual void NotifyOriginNoLongerInUse(const GURL& origin) {
+ inuse_[origin] -= 1;
+ }
+
+ int GetInUseCount(const GURL& origin) {
+ return inuse_[origin];
+ }
+
+ void reset() {
+ inuse_.clear();
+ }
+
+ // Map from origin to count of inuse notifications.
+ std::map<GURL, int> inuse_;
+ };
+
void GetStatusCallback(Status status, void* param) {
last_status_result_ = status;
last_callback_param_ = param;
@@ -137,26 +172,36 @@ TEST_F(AppCacheHostTest, Basic) {
}
TEST_F(AppCacheHostTest, SelectNoCache) {
+ scoped_refptr<MockQuotaManagerProxy> mock_quota_proxy(
+ new MockQuotaManagerProxy);
+ service_.set_quota_manager_proxy(mock_quota_proxy);
+
// Reset our mock frontend
mock_frontend_.last_cache_id_ = -333;
mock_frontend_.last_host_id_ = -333;
mock_frontend_.last_status_ = OBSOLETE;
- AppCacheHost host(1, &mock_frontend_, &service_);
- host.SelectCache(GURL("http://whatever/"), kNoCacheId, GURL());
-
- // We should have received an OnCacheSelected msg
- EXPECT_EQ(1, mock_frontend_.last_host_id_);
- EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_);
- EXPECT_EQ(UNCACHED, mock_frontend_.last_status_);
-
- // Otherwise, see that it respond as if there is no cache selected.
- EXPECT_EQ(1, host.host_id());
- EXPECT_EQ(&service_, host.service());
- EXPECT_EQ(&mock_frontend_, host.frontend());
- EXPECT_EQ(NULL, host.associated_cache());
- EXPECT_FALSE(host.is_selection_pending());
- EXPECT_TRUE(host.preferred_manifest_url().is_empty());
+ const GURL kDocAndOriginUrl(GURL("http://whatever/").GetOrigin());
+ {
+ AppCacheHost host(1, &mock_frontend_, &service_);
+ host.SelectCache(kDocAndOriginUrl, kNoCacheId, GURL());
+ EXPECT_EQ(1, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl));
+
+ // We should have received an OnCacheSelected msg
+ EXPECT_EQ(1, mock_frontend_.last_host_id_);
+ EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_);
+ EXPECT_EQ(UNCACHED, mock_frontend_.last_status_);
+
+ // Otherwise, see that it respond as if there is no cache selected.
+ EXPECT_EQ(1, host.host_id());
+ EXPECT_EQ(&service_, host.service());
+ EXPECT_EQ(&mock_frontend_, host.frontend());
+ EXPECT_EQ(NULL, host.associated_cache());
+ EXPECT_FALSE(host.is_selection_pending());
+ EXPECT_TRUE(host.preferred_manifest_url().is_empty());
+ }
+ EXPECT_EQ(0, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl));
+ service_.set_quota_manager_proxy(NULL);
}
TEST_F(AppCacheHostTest, ForeignEntry) {