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

Side by Side Diff: third_party/WebKit/Source/web/WebEmbeddedWorkerImplTest.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 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 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"
11 #include "public/platform/WebURLResponse.h" 11 #include "public/platform/WebURLResponse.h"
12 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" 12 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h"
13 #include "public/web/WebCache.h" 13 #include "public/web/WebCache.h"
14 #include "public/web/WebEmbeddedWorkerStartData.h" 14 #include "public/web/WebEmbeddedWorkerStartData.h"
15 #include "public/web/WebSettings.h" 15 #include "public/web/WebSettings.h"
16 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" 16 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "wtf/PtrUtil.h"
20 #include <memory>
19 21
20 namespace blink { 22 namespace blink {
21 namespace { 23 namespace {
22 24
23 class MockServiceWorkerContextClient 25 class MockServiceWorkerContextClient
24 : public WebServiceWorkerContextClient { 26 : public WebServiceWorkerContextClient {
25 public: 27 public:
26 MockServiceWorkerContextClient() 28 MockServiceWorkerContextClient()
27 : m_hasAssociatedRegistration(true) 29 : m_hasAssociatedRegistration(true)
28 { 30 {
(...skipping 25 matching lines...) Expand all
54 56
55 private: 57 private:
56 bool m_hasAssociatedRegistration; 58 bool m_hasAssociatedRegistration;
57 }; 59 };
58 60
59 class WebEmbeddedWorkerImplTest : public ::testing::Test { 61 class WebEmbeddedWorkerImplTest : public ::testing::Test {
60 protected: 62 protected:
61 void SetUp() override 63 void SetUp() override
62 { 64 {
63 m_mockClient = new MockServiceWorkerContextClient(); 65 m_mockClient = new MockServiceWorkerContextClient();
64 m_worker = adoptPtr(WebEmbeddedWorker::create(m_mockClient, nullptr)); 66 m_worker = wrapUnique(WebEmbeddedWorker::create(m_mockClient, nullptr));
65 67
66 WebURL scriptURL = URLTestHelpers::toKURL("https://www.example.com/sw.js "); 68 WebURL scriptURL = URLTestHelpers::toKURL("https://www.example.com/sw.js ");
67 WebURLResponse response; 69 WebURLResponse response;
68 response.initialize(); 70 response.initialize();
69 response.setMIMEType("text/javascript"); 71 response.setMIMEType("text/javascript");
70 response.setHTTPStatusCode(200); 72 response.setHTTPStatusCode(200);
71 Platform::current()->getURLLoaderMockFactory()->registerURL(scriptURL, r esponse, ""); 73 Platform::current()->getURLLoaderMockFactory()->registerURL(scriptURL, r esponse, "");
72 74
73 m_startData.scriptURL = scriptURL; 75 m_startData.scriptURL = scriptURL;
74 m_startData.userAgent = WebString("dummy user agent"); 76 m_startData.userAgent = WebString("dummy user agent");
75 m_startData.pauseAfterDownloadMode = WebEmbeddedWorkerStartData::DontPau seAfterDownload; 77 m_startData.pauseAfterDownloadMode = WebEmbeddedWorkerStartData::DontPau seAfterDownload;
76 m_startData.waitForDebuggerMode = WebEmbeddedWorkerStartData::DontWaitFo rDebugger; 78 m_startData.waitForDebuggerMode = WebEmbeddedWorkerStartData::DontWaitFo rDebugger;
77 m_startData.v8CacheOptions = WebSettings::V8CacheOptionsDefault; 79 m_startData.v8CacheOptions = WebSettings::V8CacheOptionsDefault;
78 } 80 }
79 81
80 void TearDown() override 82 void TearDown() override
81 { 83 {
82 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 84 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
83 WebCache::clear(); 85 WebCache::clear();
84 } 86 }
85 87
86 WebEmbeddedWorkerStartData m_startData; 88 WebEmbeddedWorkerStartData m_startData;
87 MockServiceWorkerContextClient* m_mockClient; 89 MockServiceWorkerContextClient* m_mockClient;
88 OwnPtr<WebEmbeddedWorker> m_worker; 90 std::unique_ptr<WebEmbeddedWorker> m_worker;
89 }; 91 };
90 92
91 } // namespace 93 } // namespace
92 94
93 TEST_F(WebEmbeddedWorkerImplTest, TerminateSoonAfterStart) 95 TEST_F(WebEmbeddedWorkerImplTest, TerminateSoonAfterStart)
94 { 96 {
95 EXPECT_CALL(*m_mockClient, workerReadyForInspection()).Times(1); 97 EXPECT_CALL(*m_mockClient, workerReadyForInspection()).Times(1);
96 m_worker->startWorkerContext(m_startData); 98 m_worker->startWorkerContext(m_startData);
97 ::testing::Mock::VerifyAndClearExpectations(m_mockClient); 99 ::testing::Mock::VerifyAndClearExpectations(m_mockClient);
98 100
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 ::testing::Mock::VerifyAndClearExpectations(m_mockClient); 283 ::testing::Mock::VerifyAndClearExpectations(m_mockClient);
282 284
283 // Resume after download. 285 // Resume after download.
284 EXPECT_CALL(*m_mockClient, createServiceWorkerProvider()) 286 EXPECT_CALL(*m_mockClient, createServiceWorkerProvider())
285 .WillOnce(::testing::Return(nullptr)); 287 .WillOnce(::testing::Return(nullptr));
286 m_worker->resumeAfterDownload(); 288 m_worker->resumeAfterDownload();
287 ::testing::Mock::VerifyAndClearExpectations(m_mockClient); 289 ::testing::Mock::VerifyAndClearExpectations(m_mockClient);
288 } 290 }
289 291
290 } // namespace blink 292 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp ('k') | third_party/WebKit/Source/web/WebFrameWidgetImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698