diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-20 20:51:06 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-20 20:51:06 +0000 |
commit | 15f9cdedac1784a85dca7867858c905f0ed90d2b (patch) | |
tree | bb001e718240c0fd86aa43a55f4a76e978b72880 /webkit/appcache/appcache_host_unittest.cc | |
parent | b89f7e4d3f98fffe88bd07a57c735e28c37e692c (diff) | |
download | chromium_src-15f9cdedac1784a85dca7867858c905f0ed90d2b.zip chromium_src-15f9cdedac1784a85dca7867858c905f0ed90d2b.tar.gz chromium_src-15f9cdedac1784a85dca7867858c905f0ed90d2b.tar.bz2 |
Finally getting to the appcache parts instead of all of this webkitApi/ipc plumbing craziness.
BUG=39368
TEST=new unittests
Review URL: http://codereview.chromium.org/2121002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47844 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_host_unittest.cc')
-rw-r--r-- | webkit/appcache/appcache_host_unittest.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/webkit/appcache/appcache_host_unittest.cc b/webkit/appcache/appcache_host_unittest.cc index be287f7..85cc4b4 100644 --- a/webkit/appcache/appcache_host_unittest.cc +++ b/webkit/appcache/appcache_host_unittest.cc @@ -4,8 +4,10 @@ #include "base/callback.h" #include "base/scoped_ptr.h" +#include "net/url_request/url_request.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/appcache/appcache.h" +#include "webkit/appcache/appcache_backend_impl.h" #include "webkit/appcache/appcache_group.h" #include "webkit/appcache/appcache_host.h" #include "webkit/appcache/mock_appcache_service.h" @@ -301,5 +303,39 @@ TEST_F(AppCacheHostTest, SetSwappableCache) { EXPECT_FALSE(host.swappable_cache_.get()); // group2 had no newest cache } +TEST_F(AppCacheHostTest, ForDedicatedWorker) { + const int kMockProcessId = 1; + const int kParentHostId = 1; + const int kWorkerHostId = 2; + + AppCacheBackendImpl backend_impl; + backend_impl.Initialize(&service_, &mock_frontend_, kMockProcessId); + backend_impl.RegisterHost(kParentHostId); + backend_impl.RegisterHost(kWorkerHostId); + + AppCacheHost* parent_host = backend_impl.GetHost(kParentHostId); + EXPECT_FALSE(parent_host->is_for_dedicated_worker()); + + AppCacheHost* worker_host = backend_impl.GetHost(kWorkerHostId); + worker_host->SelectCacheForWorker(kParentHostId, kMockProcessId); + EXPECT_TRUE(worker_host->is_for_dedicated_worker()); + EXPECT_EQ(parent_host, worker_host->GetParentAppCacheHost()); + + // We should have received an OnCacheSelected msg for the worker_host. + // The host for workers always indicates 'no cache selected' regardless + // of its parent's state. This is OK because the worker cannot access + // the scriptable interface, the only function available is resource + // loading (see appcache_request_handler_unittests those tests). + EXPECT_EQ(kWorkerHostId, mock_frontend_.last_host_id_); + EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_); + EXPECT_EQ(UNCACHED, mock_frontend_.last_status_); + + // Simulate the parent being torn down. + backend_impl.UnregisterHost(kParentHostId); + parent_host = NULL; + EXPECT_EQ(NULL, backend_impl.GetHost(kParentHostId)); + EXPECT_EQ(NULL, worker_host->GetParentAppCacheHost()); +} + } // namespace appcache |