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

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: nits Created 4 years, 4 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 void dispatchMatchAll(CacheWithResponsesCallbacks* callbacks, const WebServi ceWorkerRequest& webRequest, const QueryParams& queryParams) override 124 void dispatchMatchAll(CacheWithResponsesCallbacks* callbacks, const WebServi ceWorkerRequest& webRequest, const QueryParams& queryParams) override
125 { 125 {
126 m_lastErrorWebCacheMethodCalled = "dispatchMatchAll"; 126 m_lastErrorWebCacheMethodCalled = "dispatchMatchAll";
127 checkUrlIfProvided(webRequest.url()); 127 checkUrlIfProvided(webRequest.url());
128 checkQueryParamsIfProvided(queryParams); 128 checkQueryParamsIfProvided(queryParams);
129 129
130 std::unique_ptr<CacheWithResponsesCallbacks> ownedCallbacks(wrapUnique(c allbacks)); 130 std::unique_ptr<CacheWithResponsesCallbacks> ownedCallbacks(wrapUnique(c allbacks));
131 return callbacks->onError(m_error); 131 return callbacks->onError(m_error);
132 } 132 }
133 133
134 void dispatchKeys(CacheWithRequestsCallbacks* callbacks, const WebServiceWor kerRequest* webRequest, const QueryParams& queryParams) override 134 void dispatchKeys(CacheWithRequestsCallbacks* callbacks, const WebServiceWor kerRequest& webRequest, const QueryParams& queryParams) override
135 { 135 {
136 m_lastErrorWebCacheMethodCalled = "dispatchKeys"; 136 m_lastErrorWebCacheMethodCalled = "dispatchKeys";
137 if (webRequest) { 137 if (!webRequest.url().isEmpty()) {
138 checkUrlIfProvided(webRequest->url()); 138 checkUrlIfProvided(webRequest.url());
139 checkQueryParamsIfProvided(queryParams); 139 checkQueryParamsIfProvided(queryParams);
140 } 140 }
141 141
142 std::unique_ptr<CacheWithRequestsCallbacks> ownedCallbacks(wrapUnique(ca llbacks)); 142 std::unique_ptr<CacheWithRequestsCallbacks> ownedCallbacks(wrapUnique(ca llbacks));
143 return callbacks->onError(m_error); 143 return callbacks->onError(m_error);
144 } 144 }
145 145
146 void dispatchBatch(CacheBatchCallbacks* callbacks, const WebVector<BatchOper ation>& batchOperations) override 146 void dispatchBatch(CacheBatchCallbacks* callbacks, const WebVector<BatchOper ation>& batchOperations) override
147 { 147 {
148 m_lastErrorWebCacheMethodCalled = "dispatchBatch"; 148 m_lastErrorWebCacheMethodCalled = "dispatchBatch";
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 Response* response = V8Response::toImplWithTypeCheck(isolate(), scriptValue. v8Value()); 506 Response* response = V8Response::toImplWithTypeCheck(isolate(), scriptValue. v8Value());
507 ASSERT_TRUE(response); 507 ASSERT_TRUE(response);
508 EXPECT_EQ(responseUrl, response->url()); 508 EXPECT_EQ(responseUrl, response->url());
509 } 509 }
510 510
511 class KeysTestCache : public NotImplementedErrorCache { 511 class KeysTestCache : public NotImplementedErrorCache {
512 public: 512 public:
513 KeysTestCache(WebVector<WebServiceWorkerRequest>& requests) 513 KeysTestCache(WebVector<WebServiceWorkerRequest>& requests)
514 : m_requests(requests) { } 514 : m_requests(requests) { }
515 515
516 void dispatchKeys(CacheWithRequestsCallbacks* callbacks, const WebServiceWor kerRequest* webRequest, const QueryParams& queryParams) override 516 void dispatchKeys(CacheWithRequestsCallbacks* callbacks, const WebServiceWor kerRequest& webRequest, const QueryParams& queryParams) override
517 { 517 {
518 std::unique_ptr<CacheWithRequestsCallbacks> ownedCallbacks(wrapUnique(ca llbacks)); 518 std::unique_ptr<CacheWithRequestsCallbacks> ownedCallbacks(wrapUnique(ca llbacks));
519 return callbacks->onSuccess(m_requests); 519 return callbacks->onSuccess(m_requests);
520 } 520 }
521 521
522 private: 522 private:
523 WebVector<WebServiceWorkerRequest>& m_requests; 523 WebVector<WebServiceWorkerRequest>& m_requests;
524 }; 524 };
525 525
526 TEST_F(CacheStorageTest, KeysResponseTest) 526 TEST_F(CacheStorageTest, KeysResponseTest)
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 641
642 ScriptPromise addResult = cache->add(getScriptState(), requestToRequestInfo( request), exceptionState()); 642 ScriptPromise addResult = cache->add(getScriptState(), requestToRequestInfo( request), exceptionState());
643 643
644 EXPECT_EQ(kNotImplementedString, getRejectString(addResult)); 644 EXPECT_EQ(kNotImplementedString, getRejectString(addResult));
645 EXPECT_EQ(1, fetcher->fetchCount()); 645 EXPECT_EQ(1, fetcher->fetchCount());
646 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall ed()); 646 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall ed());
647 } 647 }
648 648
649 } // namespace 649 } // namespace
650 } // namespace blink 650 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698