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

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

Issue 1278983003: Adding allocator annotations to blink classes and structs. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed patch conflict Created 5 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 "config.h" 5 #include "config.h"
6 #include "modules/cachestorage/Cache.h" 6 #include "modules/cachestorage/Cache.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptFunction.h" 9 #include "bindings/core/v8/ScriptFunction.h"
10 #include "bindings/core/v8/ScriptPromise.h" 10 #include "bindings/core/v8/ScriptPromise.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 class NotImplementedErrorCache : public ErrorWebCacheForTests { 198 class NotImplementedErrorCache : public ErrorWebCacheForTests {
199 public: 199 public:
200 NotImplementedErrorCache() : ErrorWebCacheForTests(WebServiceWorkerCacheErro rNotImplemented) { } 200 NotImplementedErrorCache() : ErrorWebCacheForTests(WebServiceWorkerCacheErro rNotImplemented) { }
201 }; 201 };
202 202
203 class CacheStorageTest : public ::testing::Test { 203 class CacheStorageTest : public ::testing::Test {
204 public: 204 public:
205 CacheStorageTest() 205 CacheStorageTest()
206 : m_page(DummyPageHolder::create(IntSize(1, 1))) { } 206 : m_page(DummyPageHolder::create(IntSize(1, 1))) { }
207 207
208 Cache* createCache(WebServiceWorkerCache* webCache) 208 Cache* createCache(ScopedFetcherForTests* fetcher, WebServiceWorkerCache* we bCache)
209 { 209 {
210 return Cache::create(m_scopedFetcherForTests->weakPtr(), adoptPtr(webCac he)); 210 return Cache::create(fetcher->weakPtr(), adoptPtr(webCache));
211 } 211 }
212 212
213 ScriptState* scriptState() { return ScriptState::forMainWorld(m_page->docume nt().frame()); } 213 ScriptState* scriptState() { return ScriptState::forMainWorld(m_page->docume nt().frame()); }
214 ExecutionContext* executionContext() { return scriptState()->executionContex t(); } 214 ExecutionContext* executionContext() { return scriptState()->executionContex t(); }
215 v8::Isolate* isolate() { return scriptState()->isolate(); } 215 v8::Isolate* isolate() { return scriptState()->isolate(); }
216 v8::Local<v8::Context> context() { return scriptState()->context(); } 216 v8::Local<v8::Context> context() { return scriptState()->context(); }
217 ScopedFetcherForTests* fetcher() { return m_scopedFetcherForTests.get(); }
218 217
219 Request* newRequestFromUrl(const String& url) 218 Request* newRequestFromUrl(const String& url)
220 { 219 {
221 TrackExceptionState exceptionState; 220 TrackExceptionState exceptionState;
222 Request* request = Request::create(scriptState(), url, exceptionState); 221 Request* request = Request::create(scriptState(), url, exceptionState);
223 EXPECT_FALSE(exceptionState.hadException()); 222 EXPECT_FALSE(exceptionState.hadException());
224 return exceptionState.hadException() ? 0 : request; 223 return exceptionState.hadException() ? 0 : request;
225 } 224 }
226 225
227 // Convenience methods for testing the returned promises. 226 // Convenience methods for testing the returned promises.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 *m_value = value; 292 *m_value = value;
294 return value; 293 return value;
295 } 294 }
296 295
297 private: 296 private:
298 TestFunction(ScriptState* scriptState, ScriptValue* outValue) : ScriptFu nction(scriptState), m_value(outValue) { } 297 TestFunction(ScriptState* scriptState, ScriptValue* outValue) : ScriptFu nction(scriptState), m_value(outValue) { }
299 298
300 ScriptValue* m_value; 299 ScriptValue* m_value;
301 }; 300 };
302 301
303 // From ::testing::Test:
304 void SetUp() override
305 {
306 EXPECT_FALSE(m_scopedFetcherForTests);
307 m_scopedFetcherForTests = adoptPtr(new ScopedFetcherForTests());
308 EXPECT_FALSE(m_scriptScope);
309 m_scriptScope = adoptPtr(new ScriptState::Scope(scriptState()));
310 }
311
312 void TearDown() override
313 {
314 m_scopedFetcherForTests = nullptr;
315 m_scriptScope = 0;
316 }
317
318 OwnPtr<ScopedFetcherForTests> m_scopedFetcherForTests;
319
320 // Lifetime is that of the text fixture. 302 // Lifetime is that of the text fixture.
321 OwnPtr<DummyPageHolder> m_page; 303 OwnPtr<DummyPageHolder> m_page;
322 304
323 // Lifetime is per test instance.
324 OwnPtr<ScriptState::Scope> m_scriptScope;
325
326 NonThrowableExceptionState m_exceptionState; 305 NonThrowableExceptionState m_exceptionState;
327 }; 306 };
328 307
329 RequestInfo stringToRequestInfo(const String& value) 308 RequestInfo stringToRequestInfo(const String& value)
330 { 309 {
331 RequestInfo info; 310 RequestInfo info;
332 info.setUSVString(value); 311 info.setUSVString(value);
333 return info; 312 return info;
334 } 313 }
335 314
336 RequestInfo requestToRequestInfo(Request* value) 315 RequestInfo requestToRequestInfo(Request* value)
337 { 316 {
338 RequestInfo info; 317 RequestInfo info;
339 info.setRequest(value); 318 info.setRequest(value);
340 return info; 319 return info;
341 } 320 }
342 321
343 TEST_F(CacheStorageTest, Basics) 322 TEST_F(CacheStorageTest, Basics)
344 { 323 {
324 ScriptState::Scope scope(scriptState());
325 OwnPtr<ScopedFetcherForTests> fetcher = adoptPtr(new ScopedFetcherForTests() );
345 ErrorWebCacheForTests* testCache; 326 ErrorWebCacheForTests* testCache;
346 Cache* cache = createCache(testCache = new NotImplementedErrorCache()); 327 Cache* cache = createCache(fetcher.get(), testCache = new NotImplementedErro rCache());
347 ASSERT(cache); 328 ASSERT(cache);
348 329
349 const String url = "http://www.cachetest.org/"; 330 const String url = "http://www.cachetest.org/";
350 331
351 CacheQueryOptions options; 332 CacheQueryOptions options;
352 ScriptPromise matchPromise = cache->match(scriptState(), stringToRequestInfo (url), options, exceptionState()); 333 ScriptPromise matchPromise = cache->match(scriptState(), stringToRequestInfo (url), options, exceptionState());
353 EXPECT_EQ(kNotImplementedString, getRejectString(matchPromise)); 334 EXPECT_EQ(kNotImplementedString, getRejectString(matchPromise));
354 335
355 cache = createCache(testCache = new ErrorWebCacheForTests(WebServiceWorkerCa cheErrorNotFound)); 336 cache = createCache(fetcher.get(), testCache = new ErrorWebCacheForTests(Web ServiceWorkerCacheErrorNotFound));
356 matchPromise = cache->match(scriptState(), stringToRequestInfo(url), options , exceptionState()); 337 matchPromise = cache->match(scriptState(), stringToRequestInfo(url), options , exceptionState());
357 ScriptValue scriptValue = getResolveValue(matchPromise); 338 ScriptValue scriptValue = getResolveValue(matchPromise);
358 EXPECT_TRUE(scriptValue.isUndefined()); 339 EXPECT_TRUE(scriptValue.isUndefined());
359 340
360 cache = createCache(testCache = new ErrorWebCacheForTests(WebServiceWorkerCa cheErrorExists)); 341 cache = createCache(fetcher.get(), testCache = new ErrorWebCacheForTests(Web ServiceWorkerCacheErrorExists));
361 matchPromise = cache->match(scriptState(), stringToRequestInfo(url), options , exceptionState()); 342 matchPromise = cache->match(scriptState(), stringToRequestInfo(url), options , exceptionState());
362 EXPECT_EQ("InvalidAccessError: Entry already exists.", getRejectString(match Promise)); 343 EXPECT_EQ("InvalidAccessError: Entry already exists.", getRejectString(match Promise));
363 } 344 }
364 345
365 // Tests that arguments are faithfully passed on calls to Cache methods, except for methods which use batch operations, 346 // Tests that arguments are faithfully passed on calls to Cache methods, except for methods which use batch operations,
366 // which are tested later. 347 // which are tested later.
367 TEST_F(CacheStorageTest, BasicArguments) 348 TEST_F(CacheStorageTest, BasicArguments)
368 { 349 {
350 ScriptState::Scope scope(scriptState());
351 OwnPtr<ScopedFetcherForTests> fetcher = adoptPtr(new ScopedFetcherForTests() );
369 ErrorWebCacheForTests* testCache; 352 ErrorWebCacheForTests* testCache;
370 Cache* cache = createCache(testCache = new NotImplementedErrorCache()); 353 Cache* cache = createCache(fetcher.get(), testCache = new NotImplementedErro rCache());
371 ASSERT(cache); 354 ASSERT(cache);
372 355
373 const String url = "http://www.cache.arguments.test/"; 356 const String url = "http://www.cache.arguments.test/";
374 testCache->setExpectedUrl(&url); 357 testCache->setExpectedUrl(&url);
375 358
376 WebServiceWorkerCache::QueryParams expectedQueryParams; 359 WebServiceWorkerCache::QueryParams expectedQueryParams;
377 expectedQueryParams.ignoreVary = true; 360 expectedQueryParams.ignoreVary = true;
378 expectedQueryParams.cacheName = "this is a cache name"; 361 expectedQueryParams.cacheName = "this is a cache name";
379 testCache->setExpectedQueryParams(&expectedQueryParams); 362 testCache->setExpectedQueryParams(&expectedQueryParams);
380 363
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 EXPECT_EQ(kNotImplementedString, getRejectString(keysResult2)); 396 EXPECT_EQ(kNotImplementedString, getRejectString(keysResult2));
414 397
415 ScriptPromise stringKeysResult2 = cache->keys(scriptState(), stringToRequest Info(url), options, exceptionState()); 398 ScriptPromise stringKeysResult2 = cache->keys(scriptState(), stringToRequest Info(url), options, exceptionState());
416 EXPECT_EQ("dispatchKeys", testCache->getAndClearLastErrorWebCacheMethodCalle d()); 399 EXPECT_EQ("dispatchKeys", testCache->getAndClearLastErrorWebCacheMethodCalle d());
417 EXPECT_EQ(kNotImplementedString, getRejectString(stringKeysResult2)); 400 EXPECT_EQ(kNotImplementedString, getRejectString(stringKeysResult2));
418 } 401 }
419 402
420 // Tests that arguments are faithfully passed to API calls that degrade to batch operations. 403 // Tests that arguments are faithfully passed to API calls that degrade to batch operations.
421 TEST_F(CacheStorageTest, BatchOperationArguments) 404 TEST_F(CacheStorageTest, BatchOperationArguments)
422 { 405 {
406 ScriptState::Scope scope(scriptState());
407 OwnPtr<ScopedFetcherForTests> fetcher = adoptPtr(new ScopedFetcherForTests() );
423 ErrorWebCacheForTests* testCache; 408 ErrorWebCacheForTests* testCache;
424 Cache* cache = createCache(testCache = new NotImplementedErrorCache()); 409 Cache* cache = createCache(fetcher.get(), testCache = new NotImplementedErro rCache());
425 ASSERT(cache); 410 ASSERT(cache);
426 411
427 WebServiceWorkerCache::QueryParams expectedQueryParams; 412 WebServiceWorkerCache::QueryParams expectedQueryParams;
428 expectedQueryParams.cacheName = "this is another cache name"; 413 expectedQueryParams.cacheName = "this is another cache name";
429 testCache->setExpectedQueryParams(&expectedQueryParams); 414 testCache->setExpectedQueryParams(&expectedQueryParams);
430 415
431 CacheQueryOptions options; 416 CacheQueryOptions options;
432 options.setCacheName(expectedQueryParams.cacheName); 417 options.setCacheName(expectedQueryParams.cacheName);
433 418
434 const String url = "http://batch.operations.test/"; 419 const String url = "http://batch.operations.test/";
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 OwnPtr<CacheMatchCallbacks> ownedCallbacks(adoptPtr(callbacks)); 476 OwnPtr<CacheMatchCallbacks> ownedCallbacks(adoptPtr(callbacks));
492 return callbacks->onSuccess(&m_response); 477 return callbacks->onSuccess(&m_response);
493 } 478 }
494 479
495 private: 480 private:
496 WebServiceWorkerResponse& m_response; 481 WebServiceWorkerResponse& m_response;
497 }; 482 };
498 483
499 TEST_F(CacheStorageTest, MatchResponseTest) 484 TEST_F(CacheStorageTest, MatchResponseTest)
500 { 485 {
486 ScriptState::Scope scope(scriptState());
487 OwnPtr<ScopedFetcherForTests> fetcher = adoptPtr(new ScopedFetcherForTests() );
501 const String requestUrl = "http://request.url/"; 488 const String requestUrl = "http://request.url/";
502 const String responseUrl = "http://match.response.test/"; 489 const String responseUrl = "http://match.response.test/";
503 490
504 WebServiceWorkerResponse webResponse; 491 WebServiceWorkerResponse webResponse;
505 webResponse.setURL(KURL(ParsedURLString, responseUrl)); 492 webResponse.setURL(KURL(ParsedURLString, responseUrl));
506 webResponse.setResponseType(WebServiceWorkerResponseTypeDefault); 493 webResponse.setResponseType(WebServiceWorkerResponseTypeDefault);
507 494
508 Cache* cache = createCache(new MatchTestCache(webResponse)); 495 Cache* cache = createCache(fetcher.get(), new MatchTestCache(webResponse));
509 CacheQueryOptions options; 496 CacheQueryOptions options;
510 497
511 ScriptPromise result = cache->match(scriptState(), stringToRequestInfo(reque stUrl), options, exceptionState()); 498 ScriptPromise result = cache->match(scriptState(), stringToRequestInfo(reque stUrl), options, exceptionState());
512 ScriptValue scriptValue = getResolveValue(result); 499 ScriptValue scriptValue = getResolveValue(result);
513 Response* response = V8Response::toImplWithTypeCheck(isolate(), scriptValue. v8Value()); 500 Response* response = V8Response::toImplWithTypeCheck(isolate(), scriptValue. v8Value());
514 ASSERT_TRUE(response); 501 ASSERT_TRUE(response);
515 EXPECT_EQ(responseUrl, response->url()); 502 EXPECT_EQ(responseUrl, response->url());
516 } 503 }
517 504
518 class KeysTestCache : public NotImplementedErrorCache { 505 class KeysTestCache : public NotImplementedErrorCache {
519 public: 506 public:
520 KeysTestCache(WebVector<WebServiceWorkerRequest>& requests) 507 KeysTestCache(WebVector<WebServiceWorkerRequest>& requests)
521 : m_requests(requests) { } 508 : m_requests(requests) { }
522 509
523 void dispatchKeys(CacheWithRequestsCallbacks* callbacks, const WebServiceWor kerRequest* webRequest, const QueryParams& queryParams) override 510 void dispatchKeys(CacheWithRequestsCallbacks* callbacks, const WebServiceWor kerRequest* webRequest, const QueryParams& queryParams) override
524 { 511 {
525 OwnPtr<CacheWithRequestsCallbacks> ownedCallbacks(adoptPtr(callbacks)); 512 OwnPtr<CacheWithRequestsCallbacks> ownedCallbacks(adoptPtr(callbacks));
526 return callbacks->onSuccess(&m_requests); 513 return callbacks->onSuccess(&m_requests);
527 } 514 }
528 515
529 private: 516 private:
530 WebVector<WebServiceWorkerRequest>& m_requests; 517 WebVector<WebServiceWorkerRequest>& m_requests;
531 }; 518 };
532 519
533 TEST_F(CacheStorageTest, KeysResponseTest) 520 TEST_F(CacheStorageTest, KeysResponseTest)
534 { 521 {
522 ScriptState::Scope scope(scriptState());
523 OwnPtr<ScopedFetcherForTests> fetcher = adoptPtr(new ScopedFetcherForTests() );
535 const String url1 = "http://first.request/"; 524 const String url1 = "http://first.request/";
536 const String url2 = "http://second.request/"; 525 const String url2 = "http://second.request/";
537 526
538 Vector<String> expectedUrls(size_t(2)); 527 Vector<String> expectedUrls(size_t(2));
539 expectedUrls[0] = url1; 528 expectedUrls[0] = url1;
540 expectedUrls[1] = url2; 529 expectedUrls[1] = url2;
541 530
542 WebVector<WebServiceWorkerRequest> webRequests(size_t(2)); 531 WebVector<WebServiceWorkerRequest> webRequests(size_t(2));
543 webRequests[0].setURL(KURL(ParsedURLString, url1)); 532 webRequests[0].setURL(KURL(ParsedURLString, url1));
544 webRequests[1].setURL(KURL(ParsedURLString, url2)); 533 webRequests[1].setURL(KURL(ParsedURLString, url2));
545 534
546 Cache* cache = createCache(new KeysTestCache(webRequests)); 535 Cache* cache = createCache(fetcher.get(), new KeysTestCache(webRequests));
547 536
548 ScriptPromise result = cache->keys(scriptState(), exceptionState()); 537 ScriptPromise result = cache->keys(scriptState(), exceptionState());
549 ScriptValue scriptValue = getResolveValue(result); 538 ScriptValue scriptValue = getResolveValue(result);
550 539
551 Vector<v8::Local<v8::Value>> requests = toImplArray<Vector<v8::Local<v8::Val ue>>>(scriptValue.v8Value(), 0, isolate(), exceptionState()); 540 Vector<v8::Local<v8::Value>> requests = toImplArray<Vector<v8::Local<v8::Val ue>>>(scriptValue.v8Value(), 0, isolate(), exceptionState());
552 EXPECT_EQ(expectedUrls.size(), requests.size()); 541 EXPECT_EQ(expectedUrls.size(), requests.size());
553 for (int i = 0, minsize = std::min(expectedUrls.size(), requests.size()); i < minsize; ++i) { 542 for (int i = 0, minsize = std::min(expectedUrls.size(), requests.size()); i < minsize; ++i) {
554 Request* request = V8Request::toImplWithTypeCheck(isolate(), requests[i] ); 543 Request* request = V8Request::toImplWithTypeCheck(isolate(), requests[i] );
555 EXPECT_TRUE(request); 544 EXPECT_TRUE(request);
556 if (request) 545 if (request)
(...skipping 17 matching lines...) Expand all
574 OwnPtr<CacheBatchCallbacks> ownedCallbacks(adoptPtr(callbacks)); 563 OwnPtr<CacheBatchCallbacks> ownedCallbacks(adoptPtr(callbacks));
575 return callbacks->onSuccess(); 564 return callbacks->onSuccess();
576 } 565 }
577 566
578 private: 567 private:
579 WebVector<WebServiceWorkerResponse>& m_responses; 568 WebVector<WebServiceWorkerResponse>& m_responses;
580 }; 569 };
581 570
582 TEST_F(CacheStorageTest, MatchAllAndBatchResponseTest) 571 TEST_F(CacheStorageTest, MatchAllAndBatchResponseTest)
583 { 572 {
573 ScriptState::Scope scope(scriptState());
574 OwnPtr<ScopedFetcherForTests> fetcher = adoptPtr(new ScopedFetcherForTests() );
584 const String url1 = "http://first.response/"; 575 const String url1 = "http://first.response/";
585 const String url2 = "http://second.response/"; 576 const String url2 = "http://second.response/";
586 577
587 Vector<String> expectedUrls(size_t(2)); 578 Vector<String> expectedUrls(size_t(2));
588 expectedUrls[0] = url1; 579 expectedUrls[0] = url1;
589 expectedUrls[1] = url2; 580 expectedUrls[1] = url2;
590 581
591 WebVector<WebServiceWorkerResponse> webResponses(size_t(2)); 582 WebVector<WebServiceWorkerResponse> webResponses(size_t(2));
592 webResponses[0].setURL(KURL(ParsedURLString, url1)); 583 webResponses[0].setURL(KURL(ParsedURLString, url1));
593 webResponses[0].setResponseType(WebServiceWorkerResponseTypeDefault); 584 webResponses[0].setResponseType(WebServiceWorkerResponseTypeDefault);
594 webResponses[1].setURL(KURL(ParsedURLString, url2)); 585 webResponses[1].setURL(KURL(ParsedURLString, url2));
595 webResponses[1].setResponseType(WebServiceWorkerResponseTypeDefault); 586 webResponses[1].setResponseType(WebServiceWorkerResponseTypeDefault);
596 587
597 Cache* cache = createCache(new MatchAllAndBatchTestCache(webResponses)); 588 Cache* cache = createCache(fetcher.get(), new MatchAllAndBatchTestCache(webR esponses));
598 589
599 CacheQueryOptions options; 590 CacheQueryOptions options;
600 ScriptPromise result = cache->matchAll(scriptState(), stringToRequestInfo("h ttp://some.url/"), options, exceptionState()); 591 ScriptPromise result = cache->matchAll(scriptState(), stringToRequestInfo("h ttp://some.url/"), options, exceptionState());
601 ScriptValue scriptValue = getResolveValue(result); 592 ScriptValue scriptValue = getResolveValue(result);
602 593
603 Vector<v8::Local<v8::Value>> responses = toImplArray<Vector<v8::Local<v8::Va lue>>>(scriptValue.v8Value(), 0, isolate(), exceptionState()); 594 Vector<v8::Local<v8::Value>> responses = toImplArray<Vector<v8::Local<v8::Va lue>>>(scriptValue.v8Value(), 0, isolate(), exceptionState());
604 EXPECT_EQ(expectedUrls.size(), responses.size()); 595 EXPECT_EQ(expectedUrls.size(), responses.size());
605 for (int i = 0, minsize = std::min(expectedUrls.size(), responses.size()); i < minsize; ++i) { 596 for (int i = 0, minsize = std::min(expectedUrls.size(), responses.size()); i < minsize; ++i) {
606 Response* response = V8Response::toImplWithTypeCheck(isolate(), response s[i]); 597 Response* response = V8Response::toImplWithTypeCheck(isolate(), response s[i]);
607 EXPECT_TRUE(response); 598 EXPECT_TRUE(response);
608 if (response) 599 if (response)
609 EXPECT_EQ(expectedUrls[i], response->url()); 600 EXPECT_EQ(expectedUrls[i], response->url());
610 } 601 }
611 602
612 result = cache->deleteFunction(scriptState(), stringToRequestInfo("http://so me.url/"), options, exceptionState()); 603 result = cache->deleteFunction(scriptState(), stringToRequestInfo("http://so me.url/"), options, exceptionState());
613 scriptValue = getResolveValue(result); 604 scriptValue = getResolveValue(result);
614 EXPECT_TRUE(scriptValue.v8Value()->IsBoolean()); 605 EXPECT_TRUE(scriptValue.v8Value()->IsBoolean());
615 EXPECT_EQ(true, scriptValue.v8Value().As<v8::Boolean>()->Value()); 606 EXPECT_EQ(true, scriptValue.v8Value().As<v8::Boolean>()->Value());
616 } 607 }
617 608
618 TEST_F(CacheStorageTest, Add) 609 TEST_F(CacheStorageTest, Add)
619 { 610 {
611 ScriptState::Scope scope(scriptState());
612 OwnPtr<ScopedFetcherForTests> fetcher = adoptPtr(new ScopedFetcherForTests() );
620 const String url = "http://www.cacheadd.test/"; 613 const String url = "http://www.cacheadd.test/";
621 const KURL kurl(ParsedURLString, url); 614 const KURL kurl(ParsedURLString, url);
622 615
623 ErrorWebCacheForTests* testCache; 616 ErrorWebCacheForTests* testCache;
624 Cache* cache = createCache(testCache = new NotImplementedErrorCache()); 617 Cache* cache = createCache(fetcher.get(), testCache = new NotImplementedErro rCache());
625 618
626 fetcher()->setExpectedFetchUrl(&url); 619 fetcher->setExpectedFetchUrl(&url);
627 620
628 Request* request = newRequestFromUrl(url); 621 Request* request = newRequestFromUrl(url);
629 WebServiceWorkerResponse webResponse; 622 WebServiceWorkerResponse webResponse;
630 webResponse.setURL(kurl); 623 webResponse.setURL(kurl);
631 Response* response = Response::create(executionContext(), webResponse); 624 Response* response = Response::create(executionContext(), webResponse);
632 fetcher()->setResponse(response); 625 fetcher->setResponse(response);
633 626
634 WebVector<WebServiceWorkerCache::BatchOperation> expectedPutOperations(size_ t(1)); 627 WebVector<WebServiceWorkerCache::BatchOperation> expectedPutOperations(size_ t(1));
635 { 628 {
636 WebServiceWorkerCache::BatchOperation putOperation; 629 WebServiceWorkerCache::BatchOperation putOperation;
637 putOperation.operationType = WebServiceWorkerCache::OperationTypePut; 630 putOperation.operationType = WebServiceWorkerCache::OperationTypePut;
638 request->populateWebServiceWorkerRequest(putOperation.request); 631 request->populateWebServiceWorkerRequest(putOperation.request);
639 response->populateWebServiceWorkerResponse(putOperation.response); 632 response->populateWebServiceWorkerResponse(putOperation.response);
640 expectedPutOperations[0] = putOperation; 633 expectedPutOperations[0] = putOperation;
641 } 634 }
642 testCache->setExpectedBatchOperations(&expectedPutOperations); 635 testCache->setExpectedBatchOperations(&expectedPutOperations);
643 636
644 ScriptPromise addResult = cache->add(scriptState(), requestToRequestInfo(req uest), exceptionState()); 637 ScriptPromise addResult = cache->add(scriptState(), requestToRequestInfo(req uest), exceptionState());
645 638
646 EXPECT_EQ(kNotImplementedString, getRejectString(addResult)); 639 EXPECT_EQ(kNotImplementedString, getRejectString(addResult));
647 EXPECT_EQ(1, fetcher()->fetchCount()); 640 EXPECT_EQ(1, fetcher->fetchCount());
648 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall ed()); 641 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall ed());
649 } 642 }
650 643
651 } // namespace 644 } // namespace
652 } // namespace blink 645 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698