OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "content/browser/service_worker/embedded_worker_instance.h" | 8 #include "content/browser/service_worker/embedded_worker_instance.h" |
9 #include "content/browser/service_worker/embedded_worker_registry.h" | 9 #include "content/browser/service_worker/embedded_worker_registry.h" |
10 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 10 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 | 67 |
68 // Start should succeed. | 68 // Start should succeed. |
69 ServiceWorkerStatusCode status; | 69 ServiceWorkerStatusCode status; |
70 base::RunLoop run_loop; | 70 base::RunLoop run_loop; |
71 worker->Start( | 71 worker->Start( |
72 service_worker_version_id, | 72 service_worker_version_id, |
73 pattern, | 73 pattern, |
74 url, | 74 url, |
75 false, | 75 false, |
76 base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure())); | 76 base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure())); |
77 EXPECT_EQ(EmbeddedWorkerInstance::STARTING, worker->status()); | |
77 run_loop.Run(); | 78 run_loop.Run(); |
78 EXPECT_EQ(SERVICE_WORKER_OK, status); | 79 EXPECT_EQ(SERVICE_WORKER_OK, status); |
79 EXPECT_EQ(EmbeddedWorkerInstance::STARTING, worker->status()); | |
80 base::RunLoop().RunUntilIdle(); | |
81 | 80 |
82 // Worker started message should be notified (by EmbeddedWorkerTestHelper). | 81 // The 'WorkerStarted' message should be notified. |
falken
2014/11/06 04:36:30
Ah, this is confusing grammar. You notify a listen
nhiroki
2014/11/06 04:47:12
Oh... sorry for my injudicious changes :( Fixed.
| |
83 EXPECT_EQ(EmbeddedWorkerInstance::RUNNING, worker->status()); | 82 EXPECT_EQ(EmbeddedWorkerInstance::RUNNING, worker->status()); |
84 EXPECT_EQ(kRenderProcessId, worker->process_id()); | 83 EXPECT_EQ(kRenderProcessId, worker->process_id()); |
85 | 84 |
86 // Stop the worker. | 85 // Stop the worker. |
87 EXPECT_EQ(SERVICE_WORKER_OK, worker->Stop()); | 86 EXPECT_EQ(SERVICE_WORKER_OK, worker->Stop()); |
88 EXPECT_EQ(EmbeddedWorkerInstance::STOPPING, worker->status()); | 87 EXPECT_EQ(EmbeddedWorkerInstance::STOPPING, worker->status()); |
89 base::RunLoop().RunUntilIdle(); | 88 base::RunLoop().RunUntilIdle(); |
90 | 89 |
91 // Worker stopped message should be notified (by EmbeddedWorkerTestHelper). | 90 // The 'WorkerStopped' message should be notified. |
92 EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status()); | 91 EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status()); |
93 | 92 |
94 // Verify that we've sent two messages to start and terminate the worker. | 93 // Verify that we've sent two messages to start and terminate the worker. |
95 ASSERT_TRUE(ipc_sink()->GetUniqueMessageMatching( | 94 ASSERT_TRUE(ipc_sink()->GetUniqueMessageMatching( |
96 EmbeddedWorkerMsg_StartWorker::ID)); | 95 EmbeddedWorkerMsg_StartWorker::ID)); |
97 ASSERT_TRUE(ipc_sink()->GetUniqueMessageMatching( | 96 ASSERT_TRUE(ipc_sink()->GetUniqueMessageMatching( |
98 EmbeddedWorkerMsg_StopWorker::ID)); | 97 EmbeddedWorkerMsg_StopWorker::ID)); |
99 } | 98 } |
100 | 99 |
101 TEST_F(EmbeddedWorkerInstanceTest, InstanceDestroyedBeforeStartFinishes) { | 100 TEST_F(EmbeddedWorkerInstanceTest, InstanceDestroyedBeforeStartFinishes) { |
(...skipping 20 matching lines...) Expand all Loading... | |
122 worker.reset(); | 121 worker.reset(); |
123 run_loop.Run(); | 122 run_loop.Run(); |
124 EXPECT_EQ(SERVICE_WORKER_ERROR_ABORT, status); | 123 EXPECT_EQ(SERVICE_WORKER_ERROR_ABORT, status); |
125 | 124 |
126 // Verify that we didn't send the message to start the worker. | 125 // Verify that we didn't send the message to start the worker. |
127 ASSERT_FALSE( | 126 ASSERT_FALSE( |
128 ipc_sink()->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID)); | 127 ipc_sink()->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID)); |
129 } | 128 } |
130 | 129 |
131 } // namespace content | 130 } // namespace content |
OLD | NEW |