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

Unified Diff: content/browser/service_worker/service_worker_provider_host_unittest.cc

Issue 443593002: ServiceWorker: Move worker candidate process knowledge to ServiceWorkerProcessManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: RPH observer DCHECK and browser tests build fix Created 6 years, 4 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
Index: content/browser/service_worker/service_worker_provider_host_unittest.cc
diff --git a/content/browser/service_worker/service_worker_provider_host_unittest.cc b/content/browser/service_worker/service_worker_provider_host_unittest.cc
index 440ad5877d62b41080f6d87a02fb4b197205265a..01f2eca74a0367257e51a9d1bd92ffba53de1790 100644
--- a/content/browser/service_worker/service_worker_provider_host_unittest.cc
+++ b/content/browser/service_worker/service_worker_provider_host_unittest.cc
@@ -4,6 +4,7 @@
#include "base/basictypes.h"
#include "base/memory/weak_ptr.h"
+#include "content/browser/service_worker/embedded_worker_test_helper.h"
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/browser/service_worker/service_worker_provider_host.h"
#include "content/browser/service_worker/service_worker_register_job.h"
@@ -23,15 +24,8 @@ class ServiceWorkerProviderHostTest : public testing::Test {
virtual ~ServiceWorkerProviderHostTest() {}
virtual void SetUp() OVERRIDE {
- context_.reset(
- new ServiceWorkerContextCore(base::FilePath(),
- base::MessageLoopProxy::current(),
- base::MessageLoopProxy::current(),
- base::MessageLoopProxy::current(),
- NULL,
- NULL,
- NULL));
-
+ helper_.reset(new EmbeddedWorkerTestHelper(kRenderProcessId));
+ context_ = helper_->context();
scope_ = GURL("http://www.example.com/");
script_url_ = GURL("http://www.example.com/service_worker.js");
registration_ = new ServiceWorkerRegistration(
@@ -56,7 +50,11 @@ class ServiceWorkerProviderHostTest : public testing::Test {
virtual void TearDown() OVERRIDE {
version_ = 0;
registration_ = 0;
- context_.reset();
+ helper_.reset();
+ }
+
+ bool HasProcessToRun() const {
+ return context_->process_manager()->ScopeHasProcessToRun(scope_);
}
void SetActiveVersion(
@@ -72,7 +70,8 @@ class ServiceWorkerProviderHostTest : public testing::Test {
}
content::TestBrowserThreadBundle thread_bundle_;
- scoped_ptr<ServiceWorkerContextCore> context_;
+ scoped_ptr<EmbeddedWorkerTestHelper> helper_;
+ ServiceWorkerContextCore* context_;
scoped_refptr<ServiceWorkerRegistration> registration_;
scoped_refptr<ServiceWorkerVersion> version_;
base::WeakPtr<ServiceWorkerProviderHost> provider_host1_;
@@ -85,77 +84,77 @@ class ServiceWorkerProviderHostTest : public testing::Test {
};
TEST_F(ServiceWorkerProviderHostTest, SetActiveVersion_ProcessStatus) {
- ASSERT_FALSE(version_->HasProcessToRun());
+ ASSERT_FALSE(HasProcessToRun());
// Associating version_ to a provider_host's active version will internally
// add the provider_host's process ref to the version.
SetActiveVersion(provider_host1_, version_);
- ASSERT_TRUE(version_->HasProcessToRun());
+ ASSERT_TRUE(HasProcessToRun());
// Re-associating the same version and provider_host should just work too.
SetActiveVersion(provider_host1_, version_);
- ASSERT_TRUE(version_->HasProcessToRun());
+ ASSERT_TRUE(HasProcessToRun());
// Resetting the provider_host's active version should remove process refs
// from the version.
SetActiveVersion(provider_host1_, NULL);
- ASSERT_FALSE(version_->HasProcessToRun());
+ ASSERT_FALSE(HasProcessToRun());
}
TEST_F(ServiceWorkerProviderHostTest,
SetActiveVersion_MultipleHostsForSameProcess) {
- ASSERT_FALSE(version_->HasProcessToRun());
+ ASSERT_FALSE(HasProcessToRun());
// Associating version_ to two providers as active version.
SetActiveVersion(provider_host1_, version_);
SetActiveVersion(provider_host2_, version_);
- ASSERT_TRUE(version_->HasProcessToRun());
+ ASSERT_TRUE(HasProcessToRun());
// Disassociating one provider_host shouldn't remove all process refs
// from the version yet.
SetActiveVersion(provider_host1_, NULL);
- ASSERT_TRUE(version_->HasProcessToRun());
+ ASSERT_TRUE(HasProcessToRun());
// Disassociating the other provider_host will remove all process refs.
SetActiveVersion(provider_host2_, NULL);
- ASSERT_FALSE(version_->HasProcessToRun());
+ ASSERT_FALSE(HasProcessToRun());
}
TEST_F(ServiceWorkerProviderHostTest, SetWaitingVersion_ProcessStatus) {
- ASSERT_FALSE(version_->HasProcessToRun());
+ ASSERT_FALSE(HasProcessToRun());
// Associating version_ to a provider_host's waiting version will internally
// add the provider_host's process ref to the version.
SetWaitingVersion(provider_host1_, version_);
- ASSERT_TRUE(version_->HasProcessToRun());
+ ASSERT_TRUE(HasProcessToRun());
// Re-associating the same version and provider_host should just work too.
SetWaitingVersion(provider_host1_, version_);
- ASSERT_TRUE(version_->HasProcessToRun());
+ ASSERT_TRUE(HasProcessToRun());
// Resetting the provider_host's waiting version should remove process refs
// from the version.
SetWaitingVersion(provider_host1_, NULL);
- ASSERT_FALSE(version_->HasProcessToRun());
+ ASSERT_FALSE(HasProcessToRun());
}
TEST_F(ServiceWorkerProviderHostTest,
SetWaitingVersion_MultipleHostsForSameProcess) {
- ASSERT_FALSE(version_->HasProcessToRun());
+ ASSERT_FALSE(HasProcessToRun());
// Associating version_ to two providers as active version.
SetWaitingVersion(provider_host1_, version_);
SetWaitingVersion(provider_host2_, version_);
- ASSERT_TRUE(version_->HasProcessToRun());
+ ASSERT_TRUE(HasProcessToRun());
// Disassociating one provider_host shouldn't remove all process refs
// from the version yet.
SetWaitingVersion(provider_host1_, NULL);
- ASSERT_TRUE(version_->HasProcessToRun());
+ ASSERT_TRUE(HasProcessToRun());
// Disassociating the other provider_host will remove all process refs.
SetWaitingVersion(provider_host2_, NULL);
- ASSERT_FALSE(version_->HasProcessToRun());
+ ASSERT_FALSE(HasProcessToRun());
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698