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

Side by Side Diff: third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp

Issue 1719103002: CacheStorage: Expand cache.keys() method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 "modules/cachestorage/Cache.h" 5 #include "modules/cachestorage/Cache.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptFunction.h" 8 #include "bindings/core/v8/ScriptFunction.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 void dispatchMatchAll(CacheWithResponsesCallbacks* callbacks, const WebServi ceWorkerRequest& webRequest, const QueryParams& queryParams) override 139 void dispatchMatchAll(CacheWithResponsesCallbacks* callbacks, const WebServi ceWorkerRequest& webRequest, const QueryParams& queryParams) override
140 { 140 {
141 m_lastErrorWebCacheMethodCalled = "dispatchMatchAll"; 141 m_lastErrorWebCacheMethodCalled = "dispatchMatchAll";
142 checkUrlIfProvided(webRequest.url()); 142 checkUrlIfProvided(webRequest.url());
143 checkQueryParamsIfProvided(queryParams); 143 checkQueryParamsIfProvided(queryParams);
144 144
145 OwnPtr<CacheWithResponsesCallbacks> ownedCallbacks(adoptPtr(callbacks)); 145 OwnPtr<CacheWithResponsesCallbacks> ownedCallbacks(adoptPtr(callbacks));
146 return callbacks->onError(m_error); 146 return callbacks->onError(m_error);
147 } 147 }
148 148
149 void dispatchKeys(CacheWithRequestsCallbacks* callbacks, const WebServiceWor kerRequest* webRequest, const QueryParams& queryParams) override 149 void dispatchKeys(CacheWithRequestsCallbacks* callbacks, const WebServiceWor kerRequest& webRequest, const QueryParams& queryParams) override
150 { 150 {
151 m_lastErrorWebCacheMethodCalled = "dispatchKeys"; 151 m_lastErrorWebCacheMethodCalled = "dispatchKeys";
152 if (webRequest) { 152 if (!webRequest.url().isEmpty()) {
153 checkUrlIfProvided(webRequest->url()); 153 checkUrlIfProvided(webRequest.url());
154 checkQueryParamsIfProvided(queryParams); 154 checkQueryParamsIfProvided(queryParams);
155 } 155 }
156 156
157 OwnPtr<CacheWithRequestsCallbacks> ownedCallbacks(adoptPtr(callbacks)); 157 OwnPtr<CacheWithRequestsCallbacks> ownedCallbacks(adoptPtr(callbacks));
158 return callbacks->onError(m_error); 158 return callbacks->onError(m_error);
159 } 159 }
160 160
161 void dispatchBatch(CacheBatchCallbacks* callbacks, const WebVector<BatchOper ation>& batchOperations) override 161 void dispatchBatch(CacheBatchCallbacks* callbacks, const WebVector<BatchOper ation>& batchOperations) override
162 { 162 {
163 m_lastErrorWebCacheMethodCalled = "dispatchBatch"; 163 m_lastErrorWebCacheMethodCalled = "dispatchBatch";
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 Response* response = V8Response::toImplWithTypeCheck(isolate(), scriptValue. v8Value()); 521 Response* response = V8Response::toImplWithTypeCheck(isolate(), scriptValue. v8Value());
522 ASSERT_TRUE(response); 522 ASSERT_TRUE(response);
523 EXPECT_EQ(responseUrl, response->url()); 523 EXPECT_EQ(responseUrl, response->url());
524 } 524 }
525 525
526 class KeysTestCache : public NotImplementedErrorCache { 526 class KeysTestCache : public NotImplementedErrorCache {
527 public: 527 public:
528 KeysTestCache(WebVector<WebServiceWorkerRequest>& requests) 528 KeysTestCache(WebVector<WebServiceWorkerRequest>& requests)
529 : m_requests(requests) { } 529 : m_requests(requests) { }
530 530
531 void dispatchKeys(CacheWithRequestsCallbacks* callbacks, const WebServiceWor kerRequest* webRequest, const QueryParams& queryParams) override 531 void dispatchKeys(CacheWithRequestsCallbacks* callbacks, const WebServiceWor kerRequest& webRequest, const QueryParams& queryParams) override
532 { 532 {
533 OwnPtr<CacheWithRequestsCallbacks> ownedCallbacks(adoptPtr(callbacks)); 533 OwnPtr<CacheWithRequestsCallbacks> ownedCallbacks(adoptPtr(callbacks));
534 return callbacks->onSuccess(m_requests); 534 return callbacks->onSuccess(m_requests);
535 } 535 }
536 536
537 private: 537 private:
538 WebVector<WebServiceWorkerRequest>& m_requests; 538 WebVector<WebServiceWorkerRequest>& m_requests;
539 }; 539 };
540 540
541 TEST_F(CacheStorageTest, KeysResponseTest) 541 TEST_F(CacheStorageTest, KeysResponseTest)
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 656
657 ScriptPromise addResult = cache->add(scriptState(), requestToRequestInfo(req uest), exceptionState()); 657 ScriptPromise addResult = cache->add(scriptState(), requestToRequestInfo(req uest), exceptionState());
658 658
659 EXPECT_EQ(kNotImplementedString, getRejectString(addResult)); 659 EXPECT_EQ(kNotImplementedString, getRejectString(addResult));
660 EXPECT_EQ(1, fetcher->fetchCount()); 660 EXPECT_EQ(1, fetcher->fetchCount());
661 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall ed()); 661 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall ed());
662 } 662 }
663 663
664 } // namespace 664 } // namespace
665 } // namespace blink 665 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698