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

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

Issue 140743012: Start EmbeddedWorker during registration - take 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up log messages, tests Created 6 years, 11 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_context_unittest.cc
diff --git a/content/browser/service_worker/service_worker_context_unittest.cc b/content/browser/service_worker/service_worker_context_unittest.cc
index 56f52188664ca5c9a0eabf82b42d373fcf43332d..d92838b930aca25af235a59252127dc42006175b 100644
--- a/content/browser/service_worker/service_worker_context_unittest.cc
+++ b/content/browser/service_worker/service_worker_context_unittest.cc
@@ -8,6 +8,8 @@
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "content/browser/browser_thread_impl.h"
+#include "content/browser/service_worker/embedded_worker_registry.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_registration.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -50,13 +52,25 @@ class ServiceWorkerContextTest : public testing::Test {
virtual void SetUp() OVERRIDE {
context_.reset(new ServiceWorkerContextCore(base::FilePath(), NULL));
+ helper_.reset(new EmbeddedWorkerTestHelper(context_.get()));
+ scoped_ptr<EmbeddedWorkerInstance> worker =
+ context_->embedded_worker_registry()->CreateWorker();
+
+ render_process_id_ = 99;
+ int embedded_worker_id = worker->embedded_worker_id();
+ helper_->SimulateAddProcess(embedded_worker_id, render_process_id_);
kinuko 2014/02/04 03:37:53 (Oh I see... looks like the helper's still a bit i
kinuko 2014/02/04 11:41:31 Btw you can just remove line 56-61 and instead add
alecflett 2014/02/04 20:09:04 I ended up adding a helper to embedded_worker_test
}
- virtual void TearDown() OVERRIDE { context_.reset(); }
+ virtual void TearDown() OVERRIDE {
+ helper_.reset();
+ context_.reset();
+ }
protected:
TestBrowserThreadBundle browser_thread_bundle_;
scoped_ptr<ServiceWorkerContextCore> context_;
+ scoped_ptr<EmbeddedWorkerTestHelper> helper_;
+ int render_process_id_;
};
void RegistrationCallback(
@@ -72,13 +86,15 @@ TEST_F(ServiceWorkerContextTest, Register) {
context_->RegisterServiceWorker(
GURL("http://www.example.com/*"),
GURL("http://www.example.com/service_worker.js"),
+ render_process_id_,
MakeRegisteredCallback(&called, &registration_id));
ASSERT_FALSE(called);
base::RunLoop().RunUntilIdle();
- ASSERT_TRUE(called);
+ EXPECT_TRUE(called);
- ASSERT_NE(-1L, registration_id);
+ EXPECT_EQ(1UL, helper_->ipc_sink()->message_count());
+ EXPECT_NE(-1L, registration_id);
}
// Make sure registrations are cleaned up when they are unregistered.
@@ -90,6 +106,7 @@ TEST_F(ServiceWorkerContextTest, Unregister) {
context_->RegisterServiceWorker(
pattern,
GURL("http://www.example.com/service_worker.js"),
+ render_process_id_,
MakeRegisteredCallback(&called, &registration_id));
ASSERT_FALSE(called);
@@ -97,7 +114,8 @@ TEST_F(ServiceWorkerContextTest, Unregister) {
ASSERT_TRUE(called);
called = false;
- context_->UnregisterServiceWorker(pattern, MakeUnregisteredCallback(&called));
+ context_->UnregisterServiceWorker(
+ pattern, render_process_id_, MakeUnregisteredCallback(&called));
ASSERT_FALSE(called);
base::RunLoop().RunUntilIdle();
@@ -114,6 +132,7 @@ TEST_F(ServiceWorkerContextTest, RegisterNewScript) {
context_->RegisterServiceWorker(
pattern,
GURL("http://www.example.com/service_worker.js"),
+ render_process_id_,
MakeRegisteredCallback(&called, &old_registration_id));
ASSERT_FALSE(called);
@@ -125,6 +144,7 @@ TEST_F(ServiceWorkerContextTest, RegisterNewScript) {
context_->RegisterServiceWorker(
pattern,
GURL("http://www.example.com/service_worker_new.js"),
+ render_process_id_,
MakeRegisteredCallback(&called, &new_registration_id));
ASSERT_FALSE(called);
@@ -145,6 +165,7 @@ TEST_F(ServiceWorkerContextTest, RegisterDuplicateScript) {
context_->RegisterServiceWorker(
pattern,
script_url,
+ render_process_id_,
MakeRegisteredCallback(&called, &old_registration_id));
ASSERT_FALSE(called);
@@ -156,6 +177,7 @@ TEST_F(ServiceWorkerContextTest, RegisterDuplicateScript) {
context_->RegisterServiceWorker(
pattern,
script_url,
+ render_process_id_,
MakeRegisteredCallback(&called, &new_registration_id));
ASSERT_FALSE(called);

Powered by Google App Engine
This is Rietveld 408576698