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

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp

Issue 1227783004: Fix virtual/override/final usage in Source/modules/. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 5 years, 5 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 | Annotate | Revision Log
OLDNEW
1 1
2 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Copyright 2014 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 #include "config.h" 6 #include "config.h"
7 #include "modules/serviceworkers/ServiceWorkerContainer.h" 7 #include "modules/serviceworkers/ServiceWorkerContainer.h"
8 8
9 #include "bindings/core/v8/Dictionary.h" 9 #include "bindings/core/v8/Dictionary.h"
10 #include "bindings/core/v8/ScriptFunction.h" 10 #include "bindings/core/v8/ScriptFunction.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return self->bindToV8Function(); 63 return self->bindToV8Function();
64 } 64 }
65 65
66 private: 66 private:
67 ScriptFunctionImpl(ScriptState* scriptState, StubScriptFunction& owner) 67 ScriptFunctionImpl(ScriptState* scriptState, StubScriptFunction& owner)
68 : ScriptFunction(scriptState) 68 : ScriptFunction(scriptState)
69 , m_owner(owner) 69 , m_owner(owner)
70 { 70 {
71 } 71 }
72 72
73 virtual ScriptValue call(ScriptValue arg) override 73 ScriptValue call(ScriptValue arg) override
74 { 74 {
75 m_owner.m_arg = arg; 75 m_owner.m_arg = arg;
76 m_owner.m_callCount++; 76 m_owner.m_callCount++;
77 return ScriptValue(); 77 return ScriptValue();
78 } 78 }
79 79
80 StubScriptFunction& m_owner; 80 StubScriptFunction& m_owner;
81 }; 81 };
82 }; 82 };
83 83
(...skipping 20 matching lines...) Expand all
104 104
105 // Matches a ScriptValue and a DOMException with a specific name and message. 105 // Matches a ScriptValue and a DOMException with a specific name and message.
106 class ExpectDOMException : public ScriptValueTest { 106 class ExpectDOMException : public ScriptValueTest {
107 public: 107 public:
108 ExpectDOMException(const String& expectedName, const String& expectedMessage ) 108 ExpectDOMException(const String& expectedName, const String& expectedMessage )
109 : m_expectedName(expectedName) 109 : m_expectedName(expectedName)
110 , m_expectedMessage(expectedMessage) 110 , m_expectedMessage(expectedMessage)
111 { 111 {
112 } 112 }
113 113
114 virtual ~ExpectDOMException() override { } 114 ~ExpectDOMException() override { }
115 115
116 virtual void operator()(ScriptValue value) const override 116 void operator()(ScriptValue value) const override
117 { 117 {
118 DOMException* exception = V8DOMException::toImplWithTypeCheck(value.isol ate(), value.v8Value()); 118 DOMException* exception = V8DOMException::toImplWithTypeCheck(value.isol ate(), value.v8Value());
119 EXPECT_TRUE(exception) << "the value should be a DOMException"; 119 EXPECT_TRUE(exception) << "the value should be a DOMException";
120 if (!exception) 120 if (!exception)
121 return; 121 return;
122 EXPECT_EQ(m_expectedName, exception->name()); 122 EXPECT_EQ(m_expectedName, exception->name());
123 EXPECT_EQ(m_expectedMessage, exception->message()); 123 EXPECT_EQ(m_expectedMessage, exception->message());
124 } 124 }
125 125
126 private: 126 private:
127 String m_expectedName; 127 String m_expectedName;
128 String m_expectedMessage; 128 String m_expectedMessage;
129 }; 129 };
130 130
131 // Service Worker-specific tests. 131 // Service Worker-specific tests.
132 132
133 class NotReachedWebServiceWorkerProvider : public WebServiceWorkerProvider { 133 class NotReachedWebServiceWorkerProvider : public WebServiceWorkerProvider {
134 public: 134 public:
135 virtual ~NotReachedWebServiceWorkerProvider() override { } 135 ~NotReachedWebServiceWorkerProvider() override { }
136 136
137 virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scri ptURL, WebServiceWorkerRegistrationCallbacks* callbacks) override 137 void registerServiceWorker(const WebURL& pattern, const WebURL& scriptURL, W ebServiceWorkerRegistrationCallbacks* callbacks) override
138 { 138 {
139 ADD_FAILURE() << "the provider should not be called to register a Servic e Worker"; 139 ADD_FAILURE() << "the provider should not be called to register a Servic e Worker";
140 delete callbacks; 140 delete callbacks;
141 } 141 }
142 }; 142 };
143 143
144 class ServiceWorkerContainerTest : public ::testing::Test { 144 class ServiceWorkerContainerTest : public ::testing::Test {
145 protected: 145 protected:
146 ServiceWorkerContainerTest() 146 ServiceWorkerContainerTest()
147 : m_page(DummyPageHolder::create()) 147 : m_page(DummyPageHolder::create())
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 const WebURL& getRegistrationURL() { return m_getRegistrationURL; } 271 const WebURL& getRegistrationURL() { return m_getRegistrationURL; }
272 272
273 private: 273 private:
274 class WebServiceWorkerProviderImpl : public WebServiceWorkerProvider { 274 class WebServiceWorkerProviderImpl : public WebServiceWorkerProvider {
275 public: 275 public:
276 WebServiceWorkerProviderImpl(StubWebServiceWorkerProvider& owner) 276 WebServiceWorkerProviderImpl(StubWebServiceWorkerProvider& owner)
277 : m_owner(owner) 277 : m_owner(owner)
278 { 278 {
279 } 279 }
280 280
281 virtual ~WebServiceWorkerProviderImpl() override { } 281 ~WebServiceWorkerProviderImpl() override { }
282 282
283 virtual void registerServiceWorker(const WebURL& pattern, const WebURL& scriptURL, WebServiceWorkerRegistrationCallbacks* callbacks) override 283 void registerServiceWorker(const WebURL& pattern, const WebURL& scriptUR L, WebServiceWorkerRegistrationCallbacks* callbacks) override
284 { 284 {
285 m_owner.m_registerCallCount++; 285 m_owner.m_registerCallCount++;
286 m_owner.m_registerScope = pattern; 286 m_owner.m_registerScope = pattern;
287 m_owner.m_registerScriptURL = scriptURL; 287 m_owner.m_registerScriptURL = scriptURL;
288 m_registrationCallbacksToDelete.append(adoptPtr(callbacks)); 288 m_registrationCallbacksToDelete.append(adoptPtr(callbacks));
289 } 289 }
290 290
291 virtual void getRegistration(const WebURL& documentURL, WebServiceWorker GetRegistrationCallbacks* callbacks) override 291 void getRegistration(const WebURL& documentURL, WebServiceWorkerGetRegis trationCallbacks* callbacks) override
292 { 292 {
293 m_owner.m_getRegistrationCallCount++; 293 m_owner.m_getRegistrationCallCount++;
294 m_owner.m_getRegistrationURL = documentURL; 294 m_owner.m_getRegistrationURL = documentURL;
295 m_getRegistrationCallbacksToDelete.append(adoptPtr(callbacks)); 295 m_getRegistrationCallbacksToDelete.append(adoptPtr(callbacks));
296 } 296 }
297 297
298 private: 298 private:
299 StubWebServiceWorkerProvider& m_owner; 299 StubWebServiceWorkerProvider& m_owner;
300 Vector<OwnPtr<WebServiceWorkerRegistrationCallbacks>> m_registrationCall backsToDelete; 300 Vector<OwnPtr<WebServiceWorkerRegistrationCallbacks>> m_registrationCall backsToDelete;
301 Vector<OwnPtr<WebServiceWorkerGetRegistrationCallbacks>> m_getRegistrati onCallbacksToDelete; 301 Vector<OwnPtr<WebServiceWorkerGetRegistrationCallbacks>> m_getRegistrati onCallbacksToDelete;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 container->getRegistration(scriptState(), ""); 347 container->getRegistration(scriptState(), "");
348 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount()); 348 EXPECT_EQ(1ul, stubProvider.getRegistrationCallCount());
349 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro vider.getRegistrationURL()); 349 EXPECT_EQ(WebURL(KURL(KURL(), "http://localhost/x/index.html")), stubPro vider.getRegistrationURL());
350 } 350 }
351 351
352 container->willBeDetachedFromFrame(); 352 container->willBeDetachedFromFrame();
353 } 353 }
354 354
355 } // namespace 355 } // namespace
356 } // namespace blink 356 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.cpp ('k') | Source/modules/serviceworkers/ServiceWorkerGlobalScope.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698