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 25 matching lines...) Expand all Loading... |
36 EXPECT_EQ(expected_state, param.c); | 36 EXPECT_EQ(expected_state, param.c); |
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 virtual void SetUp() OVERRIDE { | 46 virtual void SetUp() override { |
47 helper_.reset(new EmbeddedWorkerTestHelper(kRenderProcessId)); | 47 helper_.reset(new EmbeddedWorkerTestHelper(kRenderProcessId)); |
48 | 48 |
49 const GURL pattern("http://www.example.com/"); | 49 const GURL pattern("http://www.example.com/"); |
50 registration_ = new ServiceWorkerRegistration( | 50 registration_ = new ServiceWorkerRegistration( |
51 pattern, | 51 pattern, |
52 1L, | 52 1L, |
53 helper_->context()->AsWeakPtr()); | 53 helper_->context()->AsWeakPtr()); |
54 version_ = new ServiceWorkerVersion( | 54 version_ = new ServiceWorkerVersion( |
55 registration_.get(), | 55 registration_.get(), |
56 GURL("http://www.example.com/service_worker.js"), | 56 GURL("http://www.example.com/service_worker.js"), |
57 1L, | 57 1L, |
58 helper_->context()->AsWeakPtr()); | 58 helper_->context()->AsWeakPtr()); |
59 | 59 |
60 helper_->SimulateAddProcessToPattern(pattern, kRenderProcessId); | 60 helper_->SimulateAddProcessToPattern(pattern, kRenderProcessId); |
61 } | 61 } |
62 | 62 |
63 virtual void TearDown() OVERRIDE { | 63 virtual void TearDown() override { |
64 registration_ = NULL; | 64 registration_ = NULL; |
65 version_ = NULL; | 65 version_ = NULL; |
66 helper_.reset(); | 66 helper_.reset(); |
67 } | 67 } |
68 | 68 |
69 IPC::TestSink* ipc_sink() { return helper_->ipc_sink(); } | 69 IPC::TestSink* ipc_sink() { return helper_->ipc_sink(); } |
70 | 70 |
71 TestBrowserThreadBundle browser_thread_bundle_; | 71 TestBrowserThreadBundle browser_thread_bundle_; |
72 scoped_ptr<EmbeddedWorkerTestHelper> helper_; | 72 scoped_ptr<EmbeddedWorkerTestHelper> helper_; |
73 scoped_refptr<ServiceWorkerRegistration> registration_; | 73 scoped_refptr<ServiceWorkerRegistration> registration_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // 3. SendMessageToWorker (to send InstallEvent), and | 112 // 3. SendMessageToWorker (to send InstallEvent), and |
113 EXPECT_EQ(EmbeddedWorkerContextMsg_MessageToWorker::ID, | 113 EXPECT_EQ(EmbeddedWorkerContextMsg_MessageToWorker::ID, |
114 ipc_sink()->GetMessageAt(2)->type()); | 114 ipc_sink()->GetMessageAt(2)->type()); |
115 // 4. StateChanged (state == Installed). | 115 // 4. StateChanged (state == Installed). |
116 VerifyStateChangedMessage(handle->handle_id(), | 116 VerifyStateChangedMessage(handle->handle_id(), |
117 blink::WebServiceWorkerStateInstalled, | 117 blink::WebServiceWorkerStateInstalled, |
118 ipc_sink()->GetMessageAt(3)); | 118 ipc_sink()->GetMessageAt(3)); |
119 } | 119 } |
120 | 120 |
121 } // namespace content | 121 } // namespace content |
OLD | NEW |