| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "content/browser/service_worker/embedded_worker_registry.h" | 7 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 8 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 8 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
| 9 #include "content/browser/service_worker/service_worker_context_core.h" | 9 #include "content/browser/service_worker/service_worker_context_core.h" |
| 10 #include "content/browser/service_worker/service_worker_handle.h" | 10 #include "content/browser/service_worker/service_worker_handle.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 version_); | 82 version_); |
| 83 | 83 |
| 84 // Start the worker, and then... | 84 // Start the worker, and then... |
| 85 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; | 85 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; |
| 86 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); | 86 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); |
| 87 base::RunLoop().RunUntilIdle(); | 87 base::RunLoop().RunUntilIdle(); |
| 88 EXPECT_EQ(SERVICE_WORKER_OK, status); | 88 EXPECT_EQ(SERVICE_WORKER_OK, status); |
| 89 | 89 |
| 90 // ...dispatch install event. | 90 // ...dispatch install event. |
| 91 status = SERVICE_WORKER_ERROR_FAILED; | 91 status = SERVICE_WORKER_ERROR_FAILED; |
| 92 version_->SetStatus(ServiceWorkerVersion::INSTALLING); |
| 92 version_->DispatchInstallEvent(-1, CreateReceiverOnCurrentThread(&status)); | 93 version_->DispatchInstallEvent(-1, CreateReceiverOnCurrentThread(&status)); |
| 93 base::RunLoop().RunUntilIdle(); | 94 base::RunLoop().RunUntilIdle(); |
| 94 EXPECT_EQ(SERVICE_WORKER_OK, status); | 95 EXPECT_EQ(SERVICE_WORKER_OK, status); |
| 95 | 96 |
| 97 version_->SetStatus(ServiceWorkerVersion::INSTALLED); |
| 98 |
| 96 ASSERT_EQ(4UL, ipc_sink()->message_count()); | 99 ASSERT_EQ(4UL, ipc_sink()->message_count()); |
| 97 | 100 |
| 98 // We should be sending 1. StartWorker, | 101 // We should be sending 1. StartWorker, |
| 99 EXPECT_EQ(EmbeddedWorkerMsg_StartWorker::ID, | 102 EXPECT_EQ(EmbeddedWorkerMsg_StartWorker::ID, |
| 100 ipc_sink()->GetMessageAt(0)->type()); | 103 ipc_sink()->GetMessageAt(0)->type()); |
| 101 // 2. StateChanged (state == Installing), | 104 // 2. StateChanged (state == Installing), |
| 102 VerifyStateChangedMessage(handle->handle_id(), | 105 VerifyStateChangedMessage(handle->handle_id(), |
| 103 blink::WebServiceWorkerStateInstalling, | 106 blink::WebServiceWorkerStateInstalling, |
| 104 ipc_sink()->GetMessageAt(1)); | 107 ipc_sink()->GetMessageAt(1)); |
| 105 // 3. SendMessageToWorker (to send InstallEvent), and | 108 // 3. SendMessageToWorker (to send InstallEvent), and |
| 106 EXPECT_EQ(EmbeddedWorkerContextMsg_MessageToWorker::ID, | 109 EXPECT_EQ(EmbeddedWorkerContextMsg_MessageToWorker::ID, |
| 107 ipc_sink()->GetMessageAt(2)->type()); | 110 ipc_sink()->GetMessageAt(2)->type()); |
| 108 // 4. StateChanged (state == Installed). | 111 // 4. StateChanged (state == Installed). |
| 109 VerifyStateChangedMessage(handle->handle_id(), | 112 VerifyStateChangedMessage(handle->handle_id(), |
| 110 blink::WebServiceWorkerStateInstalled, | 113 blink::WebServiceWorkerStateInstalled, |
| 111 ipc_sink()->GetMessageAt(3)); | 114 ipc_sink()->GetMessageAt(3)); |
| 112 } | 115 } |
| 113 | 116 |
| 114 } // namespace content | 117 } // namespace content |
| OLD | NEW |