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

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

Issue 2039743003: Introduce ServiceWorker.ActivatedWorkerPreparationForMainFrame.Time UMA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move GetWorkerPreparationSuffix Created 4 years, 6 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/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 62e1ce66f6d39853c877a146c3621756a4afff6c..5c8b19ec874508107872581995f2da028e388c6d 100644
--- a/content/browser/service_worker/embedded_worker_instance_unittest.cc
+++ b/content/browser/service_worker/embedded_worker_instance_unittest.cc
@@ -64,9 +64,9 @@ class EmbeddedWorkerInstanceTest : public testing::Test,
EmbeddedWorkerInstance::Status status;
};
- void RecordEvent(
- EventType type,
- EmbeddedWorkerInstance::Status status = EmbeddedWorkerInstance::STOPPED) {
+ void RecordEvent(EventType type,
+ EmbeddedWorkerInstance::Status status =
+ EmbeddedWorkerInstance::Status::STOPPED) {
EventLog log = {type, status};
events_.push_back(log);
}
@@ -164,7 +164,7 @@ class FailToSendIPCHelper : public EmbeddedWorkerTestHelper {
TEST_F(EmbeddedWorkerInstanceTest, StartAndStop) {
std::unique_ptr<EmbeddedWorkerInstance> worker =
embedded_worker_registry()->CreateWorker();
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPED, worker->status());
const int64_t service_worker_version_id = 55L;
const GURL pattern("http://example.com/");
@@ -181,23 +181,23 @@ TEST_F(EmbeddedWorkerInstanceTest, StartAndStop) {
CreateStartParams(service_worker_version_id, pattern, url);
worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status,
run_loop.QuitClosure()));
- EXPECT_EQ(EmbeddedWorkerInstance::STARTING, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STARTING, worker->status());
run_loop.Run();
EXPECT_EQ(SERVICE_WORKER_OK, status);
// The 'WorkerStarted' message should have been sent by
// EmbeddedWorkerTestHelper.
- EXPECT_EQ(EmbeddedWorkerInstance::RUNNING, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::RUNNING, worker->status());
EXPECT_EQ(helper_->mock_render_process_id(), worker->process_id());
// Stop the worker.
EXPECT_EQ(SERVICE_WORKER_OK, worker->Stop());
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPING, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPING, worker->status());
base::RunLoop().RunUntilIdle();
// The 'WorkerStopped' message should have been sent by
// EmbeddedWorkerTestHelper.
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPED, worker->status());
// Verify that we've sent two messages to start and terminate the worker.
ASSERT_TRUE(
@@ -211,7 +211,7 @@ TEST_F(EmbeddedWorkerInstanceTest, StartAndStop) {
TEST_F(EmbeddedWorkerInstanceTest, ForceNewProcess) {
std::unique_ptr<EmbeddedWorkerInstance> worker =
embedded_worker_registry()->CreateWorker();
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPED, worker->status());
const int64_t service_worker_version_id = 55L;
const GURL pattern("http://example.com/");
@@ -238,7 +238,7 @@ TEST_F(EmbeddedWorkerInstanceTest, ForceNewProcess) {
run_loop.QuitClosure()));
run_loop.Run();
EXPECT_EQ(SERVICE_WORKER_OK, status);
- EXPECT_EQ(EmbeddedWorkerInstance::RUNNING, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::RUNNING, worker->status());
// The worker should be using the default render process.
EXPECT_EQ(helper_->mock_render_process_id(), worker->process_id());
@@ -260,11 +260,11 @@ TEST_F(EmbeddedWorkerInstanceTest, ForceNewProcess) {
CreateStartParams(service_worker_version_id, pattern, url));
worker->Start(std::move(params), base::Bind(&SaveStatusAndCall, &status,
run_loop.QuitClosure()));
- EXPECT_EQ(EmbeddedWorkerInstance::STARTING, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STARTING, worker->status());
run_loop.Run();
EXPECT_EQ(SERVICE_WORKER_OK, status);
- EXPECT_EQ(EmbeddedWorkerInstance::RUNNING, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::RUNNING, worker->status());
// The worker should be using the new render process.
EXPECT_EQ(helper_->new_render_process_id(), worker->process_id());
EXPECT_EQ(SERVICE_WORKER_OK, worker->Stop());
@@ -275,7 +275,7 @@ TEST_F(EmbeddedWorkerInstanceTest, ForceNewProcess) {
TEST_F(EmbeddedWorkerInstanceTest, StopWhenDevToolsAttached) {
std::unique_ptr<EmbeddedWorkerInstance> worker =
embedded_worker_registry()->CreateWorker();
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPED, worker->status());
const int64_t service_worker_version_id = 55L;
const GURL pattern("http://example.com/");
@@ -288,33 +288,33 @@ TEST_F(EmbeddedWorkerInstanceTest, StopWhenDevToolsAttached) {
// Start the worker and then call StopIfIdle().
EXPECT_EQ(SERVICE_WORKER_OK,
StartWorker(worker.get(), service_worker_version_id, pattern, url));
- EXPECT_EQ(EmbeddedWorkerInstance::RUNNING, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::RUNNING, worker->status());
EXPECT_EQ(helper_->mock_render_process_id(), worker->process_id());
worker->StopIfIdle();
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPING, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPING, worker->status());
base::RunLoop().RunUntilIdle();
// The worker must be stopped now.
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPED, worker->status());
// Set devtools_attached to true, and do the same.
worker->set_devtools_attached(true);
EXPECT_EQ(SERVICE_WORKER_OK,
StartWorker(worker.get(), service_worker_version_id, pattern, url));
- EXPECT_EQ(EmbeddedWorkerInstance::RUNNING, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::RUNNING, worker->status());
EXPECT_EQ(helper_->mock_render_process_id(), worker->process_id());
worker->StopIfIdle();
base::RunLoop().RunUntilIdle();
// The worker must not be stopped this time.
- EXPECT_EQ(EmbeddedWorkerInstance::RUNNING, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::RUNNING, worker->status());
// Calling Stop() actually stops the worker regardless of whether devtools
// is attached or not.
EXPECT_EQ(SERVICE_WORKER_OK, worker->Stop());
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPED, worker->status());
}
// Test that the removal of a worker from the registry doesn't remove
@@ -392,7 +392,7 @@ TEST_F(EmbeddedWorkerInstanceTest, DetachDuringProcessAllocation) {
worker->Detach();
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPED, worker->status());
EXPECT_EQ(ChildProcessHost::kInvalidUniqueID, worker->process_id());
// The start callback should not be aborted by detach (see a comment on the
@@ -402,7 +402,7 @@ TEST_F(EmbeddedWorkerInstanceTest, DetachDuringProcessAllocation) {
// "PROCESS_ALLOCATED" event should not be recorded.
ASSERT_EQ(1u, events_.size());
EXPECT_EQ(DETACHED, events_[0].type);
- EXPECT_EQ(EmbeddedWorkerInstance::STARTING, events_[0].status);
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STARTING, events_[0].status);
}
TEST_F(EmbeddedWorkerInstanceTest, DetachAfterSendingStartWorkerMessage) {
@@ -431,7 +431,7 @@ TEST_F(EmbeddedWorkerInstanceTest, DetachAfterSendingStartWorkerMessage) {
worker->Detach();
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPED, worker->status());
EXPECT_EQ(ChildProcessHost::kInvalidUniqueID, worker->process_id());
// The start callback should not be aborted by detach (see a comment on the
@@ -441,7 +441,7 @@ TEST_F(EmbeddedWorkerInstanceTest, DetachAfterSendingStartWorkerMessage) {
// "STARTED" event should not be recorded.
ASSERT_EQ(1u, events_.size());
EXPECT_EQ(DETACHED, events_[0].type);
- EXPECT_EQ(EmbeddedWorkerInstance::STARTING, events_[0].status);
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STARTING, events_[0].status);
}
TEST_F(EmbeddedWorkerInstanceTest, StopDuringProcessAllocation) {
@@ -463,7 +463,7 @@ TEST_F(EmbeddedWorkerInstanceTest, StopDuringProcessAllocation) {
worker->Stop();
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPED, worker->status());
EXPECT_EQ(ChildProcessHost::kInvalidUniqueID, worker->process_id());
// The start callback should not be aborted by stop (see a comment on the dtor
@@ -473,7 +473,7 @@ TEST_F(EmbeddedWorkerInstanceTest, StopDuringProcessAllocation) {
// "PROCESS_ALLOCATED" event should not be recorded.
ASSERT_EQ(1u, events_.size());
EXPECT_EQ(DETACHED, events_[0].type);
- EXPECT_EQ(EmbeddedWorkerInstance::STARTING, events_[0].status);
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STARTING, events_[0].status);
events_.clear();
// Restart the worker.
@@ -520,7 +520,7 @@ TEST_F(EmbeddedWorkerInstanceTest, StopDuringPausedAfterDownload) {
base::RunLoop().RunUntilIdle();
// The resume after download message should not have been sent.
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPED, worker->status());
EXPECT_FALSE(ipc_sink()->GetFirstMessageMatching(
EmbeddedWorkerMsg_ResumeAfterDownload::ID));
}
@@ -551,7 +551,7 @@ TEST_F(EmbeddedWorkerInstanceTest, StopAfterSendingStartWorkerMessage) {
worker->Stop();
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPED, worker->status());
EXPECT_EQ(ChildProcessHost::kInvalidUniqueID, worker->process_id());
// The start callback should not be aborted by stop (see a comment on the dtor
@@ -561,7 +561,7 @@ TEST_F(EmbeddedWorkerInstanceTest, StopAfterSendingStartWorkerMessage) {
// "STARTED" event should not be recorded.
ASSERT_EQ(1u, events_.size());
EXPECT_EQ(STOPPED, events_[0].type);
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPING, events_[0].status);
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPING, events_[0].status);
events_.clear();
// Restart the worker.
@@ -608,13 +608,13 @@ TEST_F(EmbeddedWorkerInstanceTest, Detach) {
// Detach.
int process_id = worker->process_id();
worker->Detach();
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPED, worker->status());
// Send the registry a message from the detached worker. Nothing should
// happen.
embedded_worker_registry()->OnWorkerStarted(process_id,
worker->embedded_worker_id());
- EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STOPPED, worker->status());
}
// Test for when sending the start IPC failed.
@@ -645,7 +645,7 @@ TEST_F(EmbeddedWorkerInstanceTest, FailToSendStartIPC) {
ASSERT_EQ(2u, events_.size());
EXPECT_EQ(PROCESS_ALLOCATED, events_[0].type);
EXPECT_EQ(STOPPED, events_[1].type);
- EXPECT_EQ(EmbeddedWorkerInstance::STARTING, events_[1].status);
+ EXPECT_EQ(EmbeddedWorkerInstance::Status::STARTING, events_[1].status);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698