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

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

Issue 2627543002: ServiceWorker: Returns true for IsMojoForServiceWorkerEnabled (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_registry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/embedded_worker_instance_unittest.cc
diff --git a/content/browser/service_worker/embedded_worker_instance_unittest.cc b/content/browser/service_worker/embedded_worker_instance_unittest.cc
index 723f6f1e94818f12ff3b81f9fa2a3bee366b281c..1f89e03f088d5353dce175522dc493b68651c8e7 100644
--- a/content/browser/service_worker/embedded_worker_instance_unittest.cc
+++ b/content/browser/service_worker/embedded_worker_instance_unittest.cc
@@ -146,9 +146,6 @@ class EmbeddedWorkerInstanceTest : public testing::Test,
DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstanceTest);
};
-class EmbeddedWorkerInstanceTestP
- : public MojoServiceWorkerTestP<EmbeddedWorkerInstanceTest> {};
-
// A helper to simulate the start worker sequence is stalled in a worker
// process.
class StalledInStartWorkerHelper : public EmbeddedWorkerTestHelper {
@@ -178,18 +175,7 @@ class StalledInStartWorkerHelper : public EmbeddedWorkerTestHelper {
bool force_stall_in_start_ = true;
};
-class FailToSendIPCHelper : public EmbeddedWorkerTestHelper {
- public:
- FailToSendIPCHelper() : EmbeddedWorkerTestHelper(base::FilePath()) {}
- ~FailToSendIPCHelper() override {}
-
- bool Send(IPC::Message* message) override {
- delete message;
- return false;
- }
-};
-
-TEST_P(EmbeddedWorkerInstanceTestP, StartAndStop) {
+TEST_F(EmbeddedWorkerInstanceTest, StartAndStop) {
std::unique_ptr<EmbeddedWorkerInstance> worker =
embedded_worker_registry()->CreateWorker();
EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, worker->status());
@@ -229,15 +215,6 @@ TEST_P(EmbeddedWorkerInstanceTestP, StartAndStop) {
// EmbeddedWorkerTestHelper.
EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, worker->status());
- if (!is_mojo_enabled()) {
- // Verify that we've sent two messages via chromium IPC to start and
- // terminate the worker.
- ASSERT_TRUE(ipc_sink()->GetUniqueMessageMatching(
- EmbeddedWorkerMsg_StartWorker::ID));
- ASSERT_TRUE(
- ipc_sink()->GetUniqueMessageMatching(EmbeddedWorkerMsg_StopWorker::ID));
- }
-
// Check if the IPCs are fired in expected order.
ASSERT_EQ(4u, events_.size());
EXPECT_EQ(PROCESS_ALLOCATED, events_[0].type);
@@ -248,7 +225,7 @@ TEST_P(EmbeddedWorkerInstanceTestP, StartAndStop) {
// Test that a worker that failed twice will use a new render process
// on the next attempt.
-TEST_P(EmbeddedWorkerInstanceTestP, ForceNewProcess) {
+TEST_F(EmbeddedWorkerInstanceTest, ForceNewProcess) {
std::unique_ptr<EmbeddedWorkerInstance> worker =
embedded_worker_registry()->CreateWorker();
EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, worker->status());
@@ -314,7 +291,7 @@ TEST_P(EmbeddedWorkerInstanceTestP, ForceNewProcess) {
}
}
-TEST_P(EmbeddedWorkerInstanceTestP, StopWhenDevToolsAttached) {
+TEST_F(EmbeddedWorkerInstanceTest, StopWhenDevToolsAttached) {
std::unique_ptr<EmbeddedWorkerInstance> worker =
embedded_worker_registry()->CreateWorker();
EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, worker->status());
@@ -361,7 +338,7 @@ TEST_P(EmbeddedWorkerInstanceTestP, StopWhenDevToolsAttached) {
// Test that the removal of a worker from the registry doesn't remove
// other workers in the same process.
-TEST_P(EmbeddedWorkerInstanceTestP, RemoveWorkerInSharedProcess) {
+TEST_F(EmbeddedWorkerInstanceTest, RemoveWorkerInSharedProcess) {
std::unique_ptr<EmbeddedWorkerInstance> worker1 =
embedded_worker_registry()->CreateWorker();
std::unique_ptr<EmbeddedWorkerInstance> worker2 =
@@ -418,7 +395,7 @@ TEST_P(EmbeddedWorkerInstanceTestP, RemoveWorkerInSharedProcess) {
worker2->Stop();
}
-TEST_P(EmbeddedWorkerInstanceTestP, DetachDuringProcessAllocation) {
+TEST_F(EmbeddedWorkerInstanceTest, DetachDuringProcessAllocation) {
const int64_t version_id = 55L;
const GURL scope("http://example.com/");
const GURL url("http://example.com/worker.js");
@@ -450,7 +427,7 @@ TEST_P(EmbeddedWorkerInstanceTestP, DetachDuringProcessAllocation) {
EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[0].status);
}
-TEST_P(EmbeddedWorkerInstanceTestP, DetachAfterSendingStartWorkerMessage) {
+TEST_F(EmbeddedWorkerInstanceTest, DetachAfterSendingStartWorkerMessage) {
const int64_t version_id = 55L;
const GURL scope("http://example.com/");
const GURL url("http://example.com/worker.js");
@@ -490,7 +467,7 @@ TEST_P(EmbeddedWorkerInstanceTestP, DetachAfterSendingStartWorkerMessage) {
EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[0].status);
}
-TEST_P(EmbeddedWorkerInstanceTestP, StopDuringProcessAllocation) {
+TEST_F(EmbeddedWorkerInstanceTest, StopDuringProcessAllocation) {
const int64_t version_id = 55L;
const GURL scope("http://example.com/");
const GURL url("http://example.com/worker.js");
@@ -542,7 +519,7 @@ TEST_P(EmbeddedWorkerInstanceTestP, StopDuringProcessAllocation) {
worker->Stop();
}
-TEST_P(EmbeddedWorkerInstanceTestP, StopDuringPausedAfterDownload) {
+TEST_F(EmbeddedWorkerInstanceTest, StopDuringPausedAfterDownload) {
const int64_t version_id = 55L;
const GURL scope("http://example.com/");
const GURL url("http://example.com/worker.js");
@@ -574,7 +551,7 @@ TEST_P(EmbeddedWorkerInstanceTestP, StopDuringPausedAfterDownload) {
EmbeddedWorkerMsg_ResumeAfterDownload::ID));
}
-TEST_P(EmbeddedWorkerInstanceTestP, StopAfterSendingStartWorkerMessage) {
+TEST_F(EmbeddedWorkerInstanceTest, StopAfterSendingStartWorkerMessage) {
const int64_t version_id = 55L;
const GURL scope("http://example.com/");
const GURL url("http://example.com/worker.js");
@@ -637,7 +614,7 @@ TEST_P(EmbeddedWorkerInstanceTestP, StopAfterSendingStartWorkerMessage) {
worker->Stop();
}
-TEST_P(EmbeddedWorkerInstanceTestP, Detach) {
+TEST_F(EmbeddedWorkerInstanceTest, Detach) {
const int64_t version_id = 55L;
const GURL pattern("http://example.com/");
const GURL url("http://example.com/worker.js");
@@ -670,56 +647,33 @@ TEST_P(EmbeddedWorkerInstanceTestP, Detach) {
}
// Test for when sending the start IPC failed.
-TEST_P(EmbeddedWorkerInstanceTestP, FailToSendStartIPC) {
+TEST_F(EmbeddedWorkerInstanceTest, FailToSendStartIPC) {
const int64_t version_id = 55L;
const GURL pattern("http://example.com/");
const GURL url("http://example.com/worker.js");
- if (is_mojo_enabled()) {
- // Let StartWorker fail; mojo IPC fails to connect to a remote interface.
- helper_->RegisterMockInstanceClient(nullptr);
- } else {
- helper_.reset(new FailToSendIPCHelper());
- }
+ // Let StartWorker fail; mojo IPC fails to connect to a remote interface.
+ helper_->RegisterMockInstanceClient(nullptr);
std::unique_ptr<EmbeddedWorkerInstance> worker =
embedded_worker_registry()->CreateWorker();
helper_->SimulateAddProcessToPattern(pattern,
helper_->mock_render_process_id());
- ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
worker->AddListener(this);
// Attempt to start the worker.
std::unique_ptr<EmbeddedWorkerStartParams> params =
CreateStartParams(version_id, pattern, url);
- if (is_mojo_enabled()) {
- worker->Start(std::move(params), CreateEventDispatcher(),
- base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
- base::RunLoop().RunUntilIdle();
- } else {
- base::RunLoop run_loop;
- worker->Start(
- std::move(params), CreateEventDispatcher(),
- base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure()));
- run_loop.Run();
- }
+ worker->Start(std::move(params), CreateEventDispatcher(),
+ base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
+ base::RunLoop().RunUntilIdle();
- if (is_mojo_enabled()) {
- // Worker should handle the failure of binding as detach.
- ASSERT_EQ(3u, events_.size());
- EXPECT_EQ(PROCESS_ALLOCATED, events_[0].type);
- EXPECT_EQ(START_WORKER_MESSAGE_SENT, events_[1].type);
- EXPECT_EQ(DETACHED, events_[2].type);
- EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status);
- } else {
- // The callback should have run, and we should have got an OnStopped
- // message.
- EXPECT_EQ(SERVICE_WORKER_ERROR_IPC_FAILED, status);
- ASSERT_EQ(2u, events_.size());
- EXPECT_EQ(PROCESS_ALLOCATED, events_[0].type);
- EXPECT_EQ(STOPPED, events_[1].type);
- EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[1].status);
- }
+ // Worker should handle the failure of binding as detach.
+ ASSERT_EQ(3u, events_.size());
+ EXPECT_EQ(PROCESS_ALLOCATED, events_[0].type);
+ EXPECT_EQ(START_WORKER_MESSAGE_SENT, events_[1].type);
+ EXPECT_EQ(DETACHED, events_[2].type);
+ EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status);
}
class FailEmbeddedWorkerInstanceClientImpl
@@ -737,10 +691,7 @@ class FailEmbeddedWorkerInstanceClientImpl
}
};
-TEST_P(EmbeddedWorkerInstanceTestP, RemoveRemoteInterface) {
- if (!is_mojo_enabled())
- return;
-
+TEST_F(EmbeddedWorkerInstanceTest, RemoveRemoteInterface) {
const int64_t version_id = 55L;
const GURL pattern("http://example.com/");
const GURL url("http://example.com/worker.js");
@@ -772,8 +723,4 @@ TEST_P(EmbeddedWorkerInstanceTestP, RemoveRemoteInterface) {
EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status);
}
-INSTANTIATE_TEST_CASE_P(EmbeddedWorkerInstanceTest,
- EmbeddedWorkerInstanceTestP,
- ::testing::Values(false, true));
-
} // namespace content
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698