| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 const int kRenderProcessId = 88; // A dummy ID for testing. | 26 const int kRenderProcessId = 88; // A dummy ID for testing. |
| 27 | 27 |
| 28 void VerifyStateChangedMessage(int expected_handle_id, | 28 void VerifyStateChangedMessage(int expected_handle_id, |
| 29 blink::WebServiceWorkerState expected_state, | 29 blink::WebServiceWorkerState expected_state, |
| 30 const IPC::Message* message) { | 30 const IPC::Message* message) { |
| 31 ASSERT_TRUE(message != NULL); | 31 ASSERT_TRUE(message != NULL); |
| 32 ServiceWorkerMsg_ServiceWorkerStateChanged::Param param; | 32 ServiceWorkerMsg_ServiceWorkerStateChanged::Param param; |
| 33 ASSERT_TRUE(ServiceWorkerMsg_ServiceWorkerStateChanged::Read( | 33 ASSERT_TRUE(ServiceWorkerMsg_ServiceWorkerStateChanged::Read( |
| 34 message, ¶m)); | 34 message, ¶m)); |
| 35 EXPECT_EQ(expected_handle_id, param.b); | 35 EXPECT_EQ(expected_handle_id, get<1>(param)); |
| 36 EXPECT_EQ(expected_state, param.c); | 36 EXPECT_EQ(expected_state, get<2>(param)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 class ServiceWorkerHandleTest : public testing::Test { | 41 class ServiceWorkerHandleTest : public testing::Test { |
| 42 public: | 42 public: |
| 43 ServiceWorkerHandleTest() | 43 ServiceWorkerHandleTest() |
| 44 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} | 44 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} |
| 45 | 45 |
| 46 void SetUp() override { | 46 void SetUp() override { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // 3. SendMessageToWorker (to send InstallEvent), and | 110 // 3. SendMessageToWorker (to send InstallEvent), and |
| 111 EXPECT_EQ(EmbeddedWorkerContextMsg_MessageToWorker::ID, | 111 EXPECT_EQ(EmbeddedWorkerContextMsg_MessageToWorker::ID, |
| 112 ipc_sink()->GetMessageAt(2)->type()); | 112 ipc_sink()->GetMessageAt(2)->type()); |
| 113 // 4. StateChanged (state == Installed). | 113 // 4. StateChanged (state == Installed). |
| 114 VerifyStateChangedMessage(handle->handle_id(), | 114 VerifyStateChangedMessage(handle->handle_id(), |
| 115 blink::WebServiceWorkerStateInstalled, | 115 blink::WebServiceWorkerStateInstalled, |
| 116 ipc_sink()->GetMessageAt(3)); | 116 ipc_sink()->GetMessageAt(3)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace content | 119 } // namespace content |
| OLD | NEW |