Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: content/browser/service_worker/service_worker_handle_unittest.cc

Issue 2653493009: Add two interfaces for ServiceWorkerProviderContext/ProviderHost (Closed)
Patch Set: Skip unittest for CrossSiteTransfer when PlzNavigate Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <tuple> 5 #include <tuple>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "content/browser/service_worker/embedded_worker_registry.h" 10 #include "content/browser/service_worker/embedded_worker_registry.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; 106 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
107 helper_->context()->storage()->StoreRegistration( 107 helper_->context()->storage()->StoreRegistration(
108 registration_.get(), 108 registration_.get(),
109 version_.get(), 109 version_.get(),
110 CreateReceiverOnCurrentThread(&status)); 110 CreateReceiverOnCurrentThread(&status));
111 base::RunLoop().RunUntilIdle(); 111 base::RunLoop().RunUntilIdle();
112 ASSERT_EQ(SERVICE_WORKER_OK, status); 112 ASSERT_EQ(SERVICE_WORKER_OK, status);
113 113
114 provider_host_ = CreateProviderHostWithDispatcherHost( 114 provider_host_ = CreateProviderHostWithDispatcherHost(
115 helper_->mock_render_process_id(), 1 /* provider_id */, 115 helper_->mock_render_process_id(), 1 /* provider_id */,
116 helper_->context()->AsWeakPtr(), kRenderFrameId, 116 helper_->context()->AsWeakPtr(), kRenderFrameId, dispatcher_host_.get(),
117 dispatcher_host_.get()); 117 &remote_endpoint_);
118 helper_->SimulateAddProcessToPattern(pattern, 118 helper_->SimulateAddProcessToPattern(pattern,
119 helper_->mock_render_process_id()); 119 helper_->mock_render_process_id());
120 } 120 }
121 121
122 void TearDown() override { 122 void TearDown() override {
123 dispatcher_host_ = NULL; 123 dispatcher_host_ = NULL;
124 registration_ = NULL; 124 registration_ = NULL;
125 version_ = NULL; 125 version_ = NULL;
126 provider_host_.reset(); 126 provider_host_.reset();
127 helper_.reset(); 127 helper_.reset();
128 } 128 }
129 129
130 IPC::TestSink* ipc_sink() { return helper_->ipc_sink(); } 130 IPC::TestSink* ipc_sink() { return helper_->ipc_sink(); }
131 131
132 TestBrowserThreadBundle browser_thread_bundle_; 132 TestBrowserThreadBundle browser_thread_bundle_;
133 MockResourceContext resource_context_; 133 MockResourceContext resource_context_;
134 134
135 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; 135 std::unique_ptr<EmbeddedWorkerTestHelper> helper_;
136 std::unique_ptr<ServiceWorkerProviderHost> provider_host_; 136 std::unique_ptr<ServiceWorkerProviderHost> provider_host_;
137 scoped_refptr<ServiceWorkerRegistration> registration_; 137 scoped_refptr<ServiceWorkerRegistration> registration_;
138 scoped_refptr<ServiceWorkerVersion> version_; 138 scoped_refptr<ServiceWorkerVersion> version_;
139 scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host_; 139 scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host_;
140 ServiceWorkerRemoteProviderEndpoint remote_endpoint_;
140 141
141 private: 142 private:
142 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandleTest); 143 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandleTest);
143 }; 144 };
144 145
145 TEST_F(ServiceWorkerHandleTest, OnVersionStateChanged) { 146 TEST_F(ServiceWorkerHandleTest, OnVersionStateChanged) {
146 std::unique_ptr<ServiceWorkerHandle> handle = 147 std::unique_ptr<ServiceWorkerHandle> handle =
147 ServiceWorkerHandle::Create(helper_->context()->AsWeakPtr(), 148 ServiceWorkerHandle::Create(helper_->context()->AsWeakPtr(),
148 provider_host_->AsWeakPtr(), version_.get()); 149 provider_host_->AsWeakPtr(), version_.get());
149 150
(...skipping 13 matching lines...) Expand all
163 // StartWorker shouldn't be recorded here. 164 // StartWorker shouldn't be recorded here.
164 ASSERT_EQ(1UL, ipc_sink()->message_count()); 165 ASSERT_EQ(1UL, ipc_sink()->message_count());
165 message = ipc_sink()->GetMessageAt(0); 166 message = ipc_sink()->GetMessageAt(0);
166 167
167 // StateChanged (state == Installed). 168 // StateChanged (state == Installed).
168 VerifyStateChangedMessage(handle->handle_id(), 169 VerifyStateChangedMessage(handle->handle_id(),
169 blink::kWebServiceWorkerStateInstalled, message); 170 blink::kWebServiceWorkerStateInstalled, message);
170 } 171 }
171 172
172 } // namespace content 173 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698