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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 callback.Run(); | 55 callback.Run(); |
56 } | 56 } |
57 | 57 |
58 TEST_F(EmbeddedWorkerInstanceTest, StartAndStop) { | 58 TEST_F(EmbeddedWorkerInstanceTest, StartAndStop) { |
59 scoped_ptr<EmbeddedWorkerInstance> worker = | 59 scoped_ptr<EmbeddedWorkerInstance> worker = |
60 embedded_worker_registry()->CreateWorker(); | 60 embedded_worker_registry()->CreateWorker(); |
61 EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status()); | 61 EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status()); |
62 | 62 |
63 const int embedded_worker_id = worker->embedded_worker_id(); | 63 const int embedded_worker_id = worker->embedded_worker_id(); |
64 const int64 service_worker_version_id = 55L; | 64 const int64 service_worker_version_id = 55L; |
65 const GURL scope("http://example.com/*"); | 65 const GURL scope("http://example.com/"); |
66 const GURL url("http://example.com/worker.js"); | 66 const GURL url("http://example.com/worker.js"); |
67 | 67 |
68 // Simulate adding one process to the worker. | 68 // Simulate adding one process to the worker. |
69 helper_->SimulateAddProcessToWorker(embedded_worker_id, kRenderProcessId); | 69 helper_->SimulateAddProcessToWorker(embedded_worker_id, kRenderProcessId); |
70 | 70 |
71 // Start should succeed. | 71 // Start should succeed. |
72 ServiceWorkerStatusCode status; | 72 ServiceWorkerStatusCode status; |
73 base::RunLoop run_loop; | 73 base::RunLoop run_loop; |
74 worker->Start( | 74 worker->Start( |
75 service_worker_version_id, | 75 service_worker_version_id, |
(...skipping 25 matching lines...) Expand all Loading... |
101 ASSERT_TRUE(ipc_sink()->GetUniqueMessageMatching( | 101 ASSERT_TRUE(ipc_sink()->GetUniqueMessageMatching( |
102 EmbeddedWorkerMsg_StopWorker::ID)); | 102 EmbeddedWorkerMsg_StopWorker::ID)); |
103 } | 103 } |
104 | 104 |
105 TEST_F(EmbeddedWorkerInstanceTest, InstanceDestroyedBeforeStartFinishes) { | 105 TEST_F(EmbeddedWorkerInstanceTest, InstanceDestroyedBeforeStartFinishes) { |
106 scoped_ptr<EmbeddedWorkerInstance> worker = | 106 scoped_ptr<EmbeddedWorkerInstance> worker = |
107 embedded_worker_registry()->CreateWorker(); | 107 embedded_worker_registry()->CreateWorker(); |
108 EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status()); | 108 EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status()); |
109 | 109 |
110 const int64 service_worker_version_id = 55L; | 110 const int64 service_worker_version_id = 55L; |
111 const GURL scope("http://example.com/*"); | 111 const GURL scope("http://example.com/"); |
112 const GURL url("http://example.com/worker.js"); | 112 const GURL url("http://example.com/worker.js"); |
113 | 113 |
114 ServiceWorkerStatusCode status; | 114 ServiceWorkerStatusCode status; |
115 base::RunLoop run_loop; | 115 base::RunLoop run_loop; |
116 // Begin starting the worker. | 116 // Begin starting the worker. |
117 std::vector<int> available_process; | 117 std::vector<int> available_process; |
118 available_process.push_back(kRenderProcessId); | 118 available_process.push_back(kRenderProcessId); |
119 worker->Start( | 119 worker->Start( |
120 service_worker_version_id, | 120 service_worker_version_id, |
121 scope, | 121 scope, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 registering_processes.push_back(1); | 161 registering_processes.push_back(1); |
162 registering_processes.push_back(4); | 162 registering_processes.push_back(4); |
163 EXPECT_THAT(worker->SortProcesses(registering_processes), | 163 EXPECT_THAT(worker->SortProcesses(registering_processes), |
164 testing::ElementsAre(1, 3, 2, 4)); | 164 testing::ElementsAre(1, 3, 2, 4)); |
165 | 165 |
166 EXPECT_THAT(worker->SortProcesses(std::vector<int>()), | 166 EXPECT_THAT(worker->SortProcesses(std::vector<int>()), |
167 testing::ElementsAre(3, 2, 1)); | 167 testing::ElementsAre(3, 2, 1)); |
168 } | 168 } |
169 | 169 |
170 } // namespace content | 170 } // namespace content |
OLD | NEW |