OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> |
| 6 |
5 #include "base/macros.h" | 7 #include "base/macros.h" |
6 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
7 #include "content/browser/service_worker/embedded_worker_registry.h" | 9 #include "content/browser/service_worker/embedded_worker_registry.h" |
8 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 10 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
9 #include "content/browser/service_worker/service_worker_context_core.h" | 11 #include "content/browser/service_worker/service_worker_context_core.h" |
10 #include "content/browser/service_worker/service_worker_dispatcher_host.h" | 12 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
11 #include "content/browser/service_worker/service_worker_handle.h" | 13 #include "content/browser/service_worker/service_worker_handle.h" |
12 #include "content/browser/service_worker/service_worker_registration.h" | 14 #include "content/browser/service_worker/service_worker_registration.h" |
13 #include "content/browser/service_worker/service_worker_test_utils.h" | 15 #include "content/browser/service_worker/service_worker_test_utils.h" |
14 #include "content/browser/service_worker/service_worker_version.h" | 16 #include "content/browser/service_worker/service_worker_version.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 }; | 137 }; |
136 | 138 |
137 TEST_F(ServiceWorkerHandleTest, OnVersionStateChanged) { | 139 TEST_F(ServiceWorkerHandleTest, OnVersionStateChanged) { |
138 scoped_ptr<ServiceWorkerHandle> handle = | 140 scoped_ptr<ServiceWorkerHandle> handle = |
139 ServiceWorkerHandle::Create(helper_->context()->AsWeakPtr(), | 141 ServiceWorkerHandle::Create(helper_->context()->AsWeakPtr(), |
140 provider_host_->AsWeakPtr(), | 142 provider_host_->AsWeakPtr(), |
141 version_.get()); | 143 version_.get()); |
142 | 144 |
143 // Start the worker, and then... | 145 // Start the worker, and then... |
144 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; | 146 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; |
145 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); | 147 version_->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, |
| 148 CreateReceiverOnCurrentThread(&status)); |
146 base::RunLoop().RunUntilIdle(); | 149 base::RunLoop().RunUntilIdle(); |
147 EXPECT_EQ(SERVICE_WORKER_OK, status); | 150 EXPECT_EQ(SERVICE_WORKER_OK, status); |
148 | 151 |
149 // ...update state to installing... | 152 // ...update state to installing... |
150 version_->SetStatus(ServiceWorkerVersion::INSTALLING); | 153 version_->SetStatus(ServiceWorkerVersion::INSTALLING); |
151 | 154 |
152 // ...and update state to installed. | 155 // ...and update state to installed. |
153 version_->SetStatus(ServiceWorkerVersion::INSTALLED); | 156 version_->SetStatus(ServiceWorkerVersion::INSTALLED); |
154 | 157 |
155 ASSERT_EQ(3UL, ipc_sink()->message_count()); | 158 ASSERT_EQ(3UL, ipc_sink()->message_count()); |
156 ASSERT_EQ(0L, dispatcher_host_->bad_message_received_count_); | 159 ASSERT_EQ(0L, dispatcher_host_->bad_message_received_count_); |
157 | 160 |
158 // We should be sending 1. StartWorker, | 161 // We should be sending 1. StartWorker, |
159 EXPECT_EQ(EmbeddedWorkerMsg_StartWorker::ID, | 162 EXPECT_EQ(EmbeddedWorkerMsg_StartWorker::ID, |
160 ipc_sink()->GetMessageAt(0)->type()); | 163 ipc_sink()->GetMessageAt(0)->type()); |
161 // 2. StateChanged (state == Installing), | 164 // 2. StateChanged (state == Installing), |
162 VerifyStateChangedMessage(handle->handle_id(), | 165 VerifyStateChangedMessage(handle->handle_id(), |
163 blink::WebServiceWorkerStateInstalling, | 166 blink::WebServiceWorkerStateInstalling, |
164 ipc_sink()->GetMessageAt(1)); | 167 ipc_sink()->GetMessageAt(1)); |
165 // 3. StateChanged (state == Installed). | 168 // 3. StateChanged (state == Installed). |
166 VerifyStateChangedMessage(handle->handle_id(), | 169 VerifyStateChangedMessage(handle->handle_id(), |
167 blink::WebServiceWorkerStateInstalled, | 170 blink::WebServiceWorkerStateInstalled, |
168 ipc_sink()->GetMessageAt(2)); | 171 ipc_sink()->GetMessageAt(2)); |
169 } | 172 } |
170 | 173 |
171 } // namespace content | 174 } // namespace content |
OLD | NEW |