| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "public/web/WebEmbeddedWorker.h" | 5 #include "public/web/WebEmbeddedWorker.h" |
| 6 | 6 |
| 7 #include "platform/testing/URLTestHelpers.h" | 7 #include "platform/testing/URLTestHelpers.h" |
| 8 #include "platform/testing/UnitTestHelpers.h" | 8 #include "platform/testing/UnitTestHelpers.h" |
| 9 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
| 10 #include "public/platform/WebURLResponse.h" | 10 #include "public/platform/WebURLResponse.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class MockServiceWorkerContextClient | 22 class MockServiceWorkerContextClient |
| 23 : public WebServiceWorkerContextClient { | 23 : public WebServiceWorkerContextClient { |
| 24 public: | 24 public: |
| 25 MockServiceWorkerContextClient() { } | 25 MockServiceWorkerContextClient() { } |
| 26 ~MockServiceWorkerContextClient() override { } | 26 ~MockServiceWorkerContextClient() override { } |
| 27 MOCK_METHOD0(workerReadyForInspection, void()); | 27 MOCK_METHOD0(workerReadyForInspection, void()); |
| 28 MOCK_METHOD0(workerContextFailedToStart, void()); | 28 MOCK_METHOD0(workerContextFailedToStart, void()); |
| 29 MOCK_METHOD0(workerScriptLoaded, void()); | 29 MOCK_METHOD0(workerScriptLoaded, void()); |
| 30 MOCK_METHOD1(createServiceWorkerNetworkProvider, WebServiceWorkerNetworkProv
ider*(WebDataSource*)); | 30 MOCK_METHOD1(createServiceWorkerNetworkProvider, WebServiceWorkerNetworkProv
ider*(WebDataSource*)); |
| 31 MOCK_METHOD0(createServiceWorkerProvider, WebServiceWorkerProvider*()); | 31 MOCK_METHOD0(createServiceWorkerProvider, WebServiceWorkerProvider*()); |
| 32 void getClient(const WebString&, WebServiceWorkerClientCallbacks*) override
{ NOTREACHED(); } |
| 33 void getClients(const WebServiceWorkerClientQueryOptions&, WebServiceWorkerC
lientsCallbacks*) override { NOTREACHED(); } |
| 34 void openWindow(const WebURL&, WebServiceWorkerClientCallbacks*) override {
NOTREACHED(); } |
| 35 void postMessageToClient(const WebString& uuid, const WebString&, WebMessage
PortChannelArray*) override { NOTREACHED(); } |
| 36 void postMessageToCrossOriginClient(const WebCrossOriginServiceWorkerClient&
, const WebString&, WebMessagePortChannelArray*) override { NOTREACHED(); } |
| 37 void skipWaiting(WebServiceWorkerSkipWaitingCallbacks*) override { NOTREACHE
D(); } |
| 38 void claim(WebServiceWorkerClientsClaimCallbacks*) override { NOTREACHED();
} |
| 39 void focus(const WebString& uuid, WebServiceWorkerClientCallbacks*) override
{ NOTREACHED(); } |
| 40 void navigate(const WebString& uuid, const WebURL&, WebServiceWorkerClientCa
llbacks*) override { NOTREACHED(); } |
| 41 void registerForeignFetchScopes(const WebVector<WebURL>& subScopes, const We
bVector<WebSecurityOrigin>& origins) override { NOTREACHED(); } |
| 32 }; | 42 }; |
| 33 | 43 |
| 34 class WebEmbeddedWorkerImplTest : public ::testing::Test { | 44 class WebEmbeddedWorkerImplTest : public ::testing::Test { |
| 35 protected: | 45 protected: |
| 36 void SetUp() override | 46 void SetUp() override |
| 37 { | 47 { |
| 38 m_mockClient = new MockServiceWorkerContextClient(); | 48 m_mockClient = new MockServiceWorkerContextClient(); |
| 39 m_worker = adoptPtr(WebEmbeddedWorker::create(m_mockClient, nullptr)); | 49 m_worker = adoptPtr(WebEmbeddedWorker::create(m_mockClient, nullptr)); |
| 40 | 50 |
| 41 WebURL scriptURL = URLTestHelpers::toKURL("https://www.example.com/sw.js
"); | 51 WebURL scriptURL = URLTestHelpers::toKURL("https://www.example.com/sw.js
"); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 ::testing::Mock::VerifyAndClearExpectations(m_mockClient); | 239 ::testing::Mock::VerifyAndClearExpectations(m_mockClient); |
| 230 | 240 |
| 231 // Resume after download. | 241 // Resume after download. |
| 232 EXPECT_CALL(*m_mockClient, createServiceWorkerProvider()) | 242 EXPECT_CALL(*m_mockClient, createServiceWorkerProvider()) |
| 233 .WillOnce(::testing::Return(nullptr)); | 243 .WillOnce(::testing::Return(nullptr)); |
| 234 m_worker->resumeAfterDownload(); | 244 m_worker->resumeAfterDownload(); |
| 235 ::testing::Mock::VerifyAndClearExpectations(m_mockClient); | 245 ::testing::Mock::VerifyAndClearExpectations(m_mockClient); |
| 236 } | 246 } |
| 237 | 247 |
| 238 } // namespace blink | 248 } // namespace blink |
| OLD | NEW |