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_registration.h" | 10 #include "content/browser/service_worker/service_worker_registration.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 DISALLOW_COPY_AND_ASSIGN(MessageReceiverFromWorker); | 107 DISALLOW_COPY_AND_ASSIGN(MessageReceiverFromWorker); |
108 }; | 108 }; |
109 | 109 |
110 } // namespace | 110 } // namespace |
111 | 111 |
112 class ServiceWorkerVersionTest : public testing::Test { | 112 class ServiceWorkerVersionTest : public testing::Test { |
113 protected: | 113 protected: |
114 ServiceWorkerVersionTest() | 114 ServiceWorkerVersionTest() |
115 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} | 115 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} |
116 | 116 |
117 virtual void SetUp() override { | 117 void SetUp() override { |
118 helper_.reset(new MessageReceiver()); | 118 helper_.reset(new MessageReceiver()); |
119 | 119 |
120 pattern_ = GURL("http://www.example.com/"); | 120 pattern_ = GURL("http://www.example.com/"); |
121 registration_ = new ServiceWorkerRegistration( | 121 registration_ = new ServiceWorkerRegistration( |
122 pattern_, | 122 pattern_, |
123 1L, | 123 1L, |
124 helper_->context()->AsWeakPtr()); | 124 helper_->context()->AsWeakPtr()); |
125 version_ = new ServiceWorkerVersion( | 125 version_ = new ServiceWorkerVersion( |
126 registration_.get(), | 126 registration_.get(), |
127 GURL("http://www.example.com/service_worker.js"), | 127 GURL("http://www.example.com/service_worker.js"), |
128 1L, | 128 1L, |
129 helper_->context()->AsWeakPtr()); | 129 helper_->context()->AsWeakPtr()); |
130 | 130 |
131 // Simulate adding one process to the pattern. | 131 // Simulate adding one process to the pattern. |
132 helper_->SimulateAddProcessToPattern(pattern_, kRenderProcessId); | 132 helper_->SimulateAddProcessToPattern(pattern_, kRenderProcessId); |
133 ASSERT_TRUE(helper_->context()->process_manager() | 133 ASSERT_TRUE(helper_->context()->process_manager() |
134 ->PatternHasProcessToRun(pattern_)); | 134 ->PatternHasProcessToRun(pattern_)); |
135 } | 135 } |
136 | 136 |
137 virtual void TearDown() override { | 137 void TearDown() override { |
138 version_ = 0; | 138 version_ = 0; |
139 registration_ = 0; | 139 registration_ = 0; |
140 helper_.reset(); | 140 helper_.reset(); |
141 } | 141 } |
142 | 142 |
143 TestBrowserThreadBundle thread_bundle_; | 143 TestBrowserThreadBundle thread_bundle_; |
144 scoped_ptr<MessageReceiver> helper_; | 144 scoped_ptr<MessageReceiver> helper_; |
145 scoped_refptr<ServiceWorkerRegistration> registration_; | 145 scoped_refptr<ServiceWorkerRegistration> registration_; |
146 scoped_refptr<ServiceWorkerVersion> version_; | 146 scoped_refptr<ServiceWorkerVersion> version_; |
147 GURL pattern_; | 147 GURL pattern_; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 388 |
389 version_->StartWorker( | 389 version_->StartWorker( |
390 CreateReceiverOnCurrentThread(&status)); | 390 CreateReceiverOnCurrentThread(&status)); |
391 base::RunLoop().RunUntilIdle(); | 391 base::RunLoop().RunUntilIdle(); |
392 | 392 |
393 // Recreated when the worker starts again. | 393 // Recreated when the worker starts again. |
394 EXPECT_TRUE(version_->cache_listener_.get()); | 394 EXPECT_TRUE(version_->cache_listener_.get()); |
395 } | 395 } |
396 | 396 |
397 } // namespace content | 397 } // namespace content |
OLD | NEW |