| 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/WebURLLoaderMockFactory.h" | 10 #include "public/platform/WebURLLoaderMockFactory.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 bool m_hasAssociatedRegistration; | 86 bool m_hasAssociatedRegistration; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 class WebEmbeddedWorkerImplTest : public ::testing::Test { | 89 class WebEmbeddedWorkerImplTest : public ::testing::Test { |
| 90 protected: | 90 protected: |
| 91 void SetUp() override { | 91 void SetUp() override { |
| 92 m_mockClient = new MockServiceWorkerContextClient(); | 92 m_mockClient = new MockServiceWorkerContextClient(); |
| 93 m_worker = wrapUnique(WebEmbeddedWorker::create(m_mockClient, nullptr)); | 93 m_worker = |
| 94 WTF::wrapUnique(WebEmbeddedWorker::create(m_mockClient, nullptr)); |
| 94 | 95 |
| 95 WebURL scriptURL = URLTestHelpers::toKURL("https://www.example.com/sw.js"); | 96 WebURL scriptURL = URLTestHelpers::toKURL("https://www.example.com/sw.js"); |
| 96 WebURLResponse response; | 97 WebURLResponse response; |
| 97 response.setMIMEType("text/javascript"); | 98 response.setMIMEType("text/javascript"); |
| 98 response.setHTTPStatusCode(200); | 99 response.setHTTPStatusCode(200); |
| 99 Platform::current()->getURLLoaderMockFactory()->registerURL(scriptURL, | 100 Platform::current()->getURLLoaderMockFactory()->registerURL(scriptURL, |
| 100 response, ""); | 101 response, ""); |
| 101 | 102 |
| 102 m_startData.scriptURL = scriptURL; | 103 m_startData.scriptURL = scriptURL; |
| 103 m_startData.userAgent = WebString("dummy user agent"); | 104 m_startData.userAgent = WebString("dummy user agent"); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 ::testing::Mock::VerifyAndClearExpectations(m_mockClient); | 291 ::testing::Mock::VerifyAndClearExpectations(m_mockClient); |
| 291 | 292 |
| 292 // Resume after download. | 293 // Resume after download. |
| 293 EXPECT_CALL(*m_mockClient, createServiceWorkerProvider()) | 294 EXPECT_CALL(*m_mockClient, createServiceWorkerProvider()) |
| 294 .WillOnce(::testing::Return(nullptr)); | 295 .WillOnce(::testing::Return(nullptr)); |
| 295 m_worker->resumeAfterDownload(); | 296 m_worker->resumeAfterDownload(); |
| 296 ::testing::Mock::VerifyAndClearExpectations(m_mockClient); | 297 ::testing::Mock::VerifyAndClearExpectations(m_mockClient); |
| 297 } | 298 } |
| 298 | 299 |
| 299 } // namespace blink | 300 } // namespace blink |
| OLD | NEW |