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

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

Issue 2516353002: Introduce url_list to the Response scheme of CacheStorage. (Closed)
Patch Set: Created 4 years 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 *m_expectedBatchOperations; 193 *m_expectedBatchOperations;
194 EXPECT_EQ(expectedBatchOperations.size(), batchOperations.size()); 194 EXPECT_EQ(expectedBatchOperations.size(), batchOperations.size());
195 for (int i = 0, minsize = std::min(expectedBatchOperations.size(), 195 for (int i = 0, minsize = std::min(expectedBatchOperations.size(),
196 batchOperations.size()); 196 batchOperations.size());
197 i < minsize; ++i) { 197 i < minsize; ++i) {
198 EXPECT_EQ(expectedBatchOperations[i].operationType, 198 EXPECT_EQ(expectedBatchOperations[i].operationType,
199 batchOperations[i].operationType); 199 batchOperations[i].operationType);
200 const String expectedRequestUrl = 200 const String expectedRequestUrl =
201 KURL(expectedBatchOperations[i].request.url()); 201 KURL(expectedBatchOperations[i].request.url());
202 EXPECT_EQ(expectedRequestUrl, KURL(batchOperations[i].request.url())); 202 EXPECT_EQ(expectedRequestUrl, KURL(batchOperations[i].request.url()));
203 const String expectedResponseUrl = 203 EXPECT_EQ(expectedBatchOperations[i].response.urlList().size(),
204 KURL(expectedBatchOperations[i].response.url()); 204 batchOperations[i].response.urlList().size());
205 EXPECT_EQ(expectedResponseUrl, KURL(batchOperations[i].response.url())); 205 for (size_t j = 0;
206 j < expectedBatchOperations[i].response.urlList().size(); ++j) {
207 EXPECT_EQ(expectedBatchOperations[i].response.urlList()[j],
208 batchOperations[i].response.urlList()[j]);
209 }
206 CompareQueryParamsForTest(expectedBatchOperations[i].matchParams, 210 CompareQueryParamsForTest(expectedBatchOperations[i].matchParams,
207 batchOperations[i].matchParams); 211 batchOperations[i].matchParams);
208 } 212 }
209 } 213 }
210 214
211 private: 215 private:
212 static void CompareQueryParamsForTest(const QueryParams& expectedQueryParams, 216 static void CompareQueryParamsForTest(const QueryParams& expectedQueryParams,
213 const QueryParams& queryParams) { 217 const QueryParams& queryParams) {
214 EXPECT_EQ(expectedQueryParams.ignoreSearch, queryParams.ignoreSearch); 218 EXPECT_EQ(expectedQueryParams.ignoreSearch, queryParams.ignoreSearch);
215 EXPECT_EQ(expectedQueryParams.ignoreMethod, queryParams.ignoreMethod); 219 EXPECT_EQ(expectedQueryParams.ignoreMethod, queryParams.ignoreMethod);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 testCache->setExpectedQueryParams(&expectedQueryParams); 470 testCache->setExpectedQueryParams(&expectedQueryParams);
467 471
468 CacheQueryOptions options; 472 CacheQueryOptions options;
469 options.setCacheName(expectedQueryParams.cacheName); 473 options.setCacheName(expectedQueryParams.cacheName);
470 474
471 const String url = "http://batch.operations.test/"; 475 const String url = "http://batch.operations.test/";
472 Request* request = newRequestFromUrl(url); 476 Request* request = newRequestFromUrl(url);
473 ASSERT(request); 477 ASSERT(request);
474 478
475 WebServiceWorkerResponse webResponse; 479 WebServiceWorkerResponse webResponse;
476 webResponse.setURL(KURL(ParsedURLString, url)); 480 std::vector<KURL> urlList;
481 urlList.push_back(KURL(ParsedURLString, url));
482 webResponse.setURLList(urlList);
477 Response* response = Response::create(getScriptState(), webResponse); 483 Response* response = Response::create(getScriptState(), webResponse);
478 484
479 WebVector<WebServiceWorkerCache::BatchOperation> expectedDeleteOperations( 485 WebVector<WebServiceWorkerCache::BatchOperation> expectedDeleteOperations(
480 size_t(1)); 486 size_t(1));
481 { 487 {
482 WebServiceWorkerCache::BatchOperation deleteOperation; 488 WebServiceWorkerCache::BatchOperation deleteOperation;
483 deleteOperation.operationType = WebServiceWorkerCache::OperationTypeDelete; 489 deleteOperation.operationType = WebServiceWorkerCache::OperationTypeDelete;
484 request->populateWebServiceWorkerRequest(deleteOperation.request); 490 request->populateWebServiceWorkerRequest(deleteOperation.request);
485 deleteOperation.matchParams = expectedQueryParams; 491 deleteOperation.matchParams = expectedQueryParams;
486 expectedDeleteOperations[0] = deleteOperation; 492 expectedDeleteOperations[0] = deleteOperation;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 }; 551 };
546 552
547 TEST_F(CacheStorageTest, MatchResponseTest) { 553 TEST_F(CacheStorageTest, MatchResponseTest) {
548 ScriptState::Scope scope(getScriptState()); 554 ScriptState::Scope scope(getScriptState());
549 NonThrowableExceptionState exceptionState; 555 NonThrowableExceptionState exceptionState;
550 ScopedFetcherForTests* fetcher = ScopedFetcherForTests::create(); 556 ScopedFetcherForTests* fetcher = ScopedFetcherForTests::create();
551 const String requestUrl = "http://request.url/"; 557 const String requestUrl = "http://request.url/";
552 const String responseUrl = "http://match.response.test/"; 558 const String responseUrl = "http://match.response.test/";
553 559
554 WebServiceWorkerResponse webResponse; 560 WebServiceWorkerResponse webResponse;
555 webResponse.setURL(KURL(ParsedURLString, responseUrl)); 561 std::vector<KURL> urlList;
562 urlList.push_back(KURL(ParsedURLString, responseUrl));
563 webResponse.setURLList(urlList);
556 webResponse.setResponseType(WebServiceWorkerResponseTypeDefault); 564 webResponse.setResponseType(WebServiceWorkerResponseTypeDefault);
557 565
558 Cache* cache = createCache(fetcher, new MatchTestCache(webResponse)); 566 Cache* cache = createCache(fetcher, new MatchTestCache(webResponse));
559 CacheQueryOptions options; 567 CacheQueryOptions options;
560 568
561 ScriptPromise result = 569 ScriptPromise result =
562 cache->match(getScriptState(), stringToRequestInfo(requestUrl), options, 570 cache->match(getScriptState(), stringToRequestInfo(requestUrl), options,
563 exceptionState); 571 exceptionState);
564 ScriptValue scriptValue = getResolveValue(result); 572 ScriptValue scriptValue = getResolveValue(result);
565 Response* response = 573 Response* response =
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 NonThrowableExceptionState exceptionState; 655 NonThrowableExceptionState exceptionState;
648 ScopedFetcherForTests* fetcher = ScopedFetcherForTests::create(); 656 ScopedFetcherForTests* fetcher = ScopedFetcherForTests::create();
649 const String url1 = "http://first.response/"; 657 const String url1 = "http://first.response/";
650 const String url2 = "http://second.response/"; 658 const String url2 = "http://second.response/";
651 659
652 Vector<String> expectedUrls(size_t(2)); 660 Vector<String> expectedUrls(size_t(2));
653 expectedUrls[0] = url1; 661 expectedUrls[0] = url1;
654 expectedUrls[1] = url2; 662 expectedUrls[1] = url2;
655 663
656 WebVector<WebServiceWorkerResponse> webResponses(size_t(2)); 664 WebVector<WebServiceWorkerResponse> webResponses(size_t(2));
657 webResponses[0].setURL(KURL(ParsedURLString, url1)); 665 std::vector<KURL> urlList1;
666 urlList1.push_back(KURL(ParsedURLString, url1));
667 webResponses[0].setURLList(urlList1);
658 webResponses[0].setResponseType(WebServiceWorkerResponseTypeDefault); 668 webResponses[0].setResponseType(WebServiceWorkerResponseTypeDefault);
659 webResponses[1].setURL(KURL(ParsedURLString, url2)); 669 std::vector<KURL> urlList2;
670 urlList2.push_back(KURL(ParsedURLString, url2));
671 webResponses[1].setURLList(urlList2);
660 webResponses[1].setResponseType(WebServiceWorkerResponseTypeDefault); 672 webResponses[1].setResponseType(WebServiceWorkerResponseTypeDefault);
661 673
662 Cache* cache = 674 Cache* cache =
663 createCache(fetcher, new MatchAllAndBatchTestCache(webResponses)); 675 createCache(fetcher, new MatchAllAndBatchTestCache(webResponses));
664 676
665 CacheQueryOptions options; 677 CacheQueryOptions options;
666 ScriptPromise result = 678 ScriptPromise result =
667 cache->matchAll(getScriptState(), stringToRequestInfo("http://some.url/"), 679 cache->matchAll(getScriptState(), stringToRequestInfo("http://some.url/"),
668 options, exceptionState); 680 options, exceptionState);
669 ScriptValue scriptValue = getResolveValue(result); 681 ScriptValue scriptValue = getResolveValue(result);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 739
728 EXPECT_EQ(kNotImplementedString, getRejectString(addResult)); 740 EXPECT_EQ(kNotImplementedString, getRejectString(addResult));
729 EXPECT_EQ(1, fetcher->fetchCount()); 741 EXPECT_EQ(1, fetcher->fetchCount());
730 EXPECT_EQ("dispatchBatch", 742 EXPECT_EQ("dispatchBatch",
731 testCache->getAndClearLastErrorWebCacheMethodCalled()); 743 testCache->getAndClearLastErrorWebCacheMethodCalled());
732 } 744 }
733 745
734 } // namespace 746 } // namespace
735 747
736 } // namespace blink 748 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698