| OLD | NEW |
| 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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 const String contentType = "text/plain"; | 697 const String contentType = "text/plain"; |
| 698 const String content = "hello cache"; | 698 const String content = "hello cache"; |
| 699 | 699 |
| 700 ErrorWebCacheForTests* testCache; | 700 ErrorWebCacheForTests* testCache; |
| 701 Cache* cache = | 701 Cache* cache = |
| 702 createCache(fetcher, testCache = new NotImplementedErrorCache()); | 702 createCache(fetcher, testCache = new NotImplementedErrorCache()); |
| 703 | 703 |
| 704 fetcher->setExpectedFetchUrl(&url); | 704 fetcher->setExpectedFetchUrl(&url); |
| 705 | 705 |
| 706 Request* request = newRequestFromUrl(url); | 706 Request* request = newRequestFromUrl(url); |
| 707 Response* response = | 707 Response* response = Response::create( |
| 708 Response::create(getScriptState(), | 708 getScriptState(), |
| 709 new BodyStreamBuffer(getScriptState(), | 709 BodyStreamBuffer::create(getScriptState(), |
| 710 new FormDataBytesConsumer(content)), | 710 new FormDataBytesConsumer(content)), |
| 711 contentType, ResponseInit(), exceptionState); | 711 contentType, ResponseInit(), exceptionState); |
| 712 fetcher->setResponse(response); | 712 fetcher->setResponse(response); |
| 713 | 713 |
| 714 WebVector<WebServiceWorkerCache::BatchOperation> expectedPutOperations( | 714 WebVector<WebServiceWorkerCache::BatchOperation> expectedPutOperations( |
| 715 size_t(1)); | 715 size_t(1)); |
| 716 { | 716 { |
| 717 WebServiceWorkerCache::BatchOperation putOperation; | 717 WebServiceWorkerCache::BatchOperation putOperation; |
| 718 putOperation.operationType = WebServiceWorkerCache::OperationTypePut; | 718 putOperation.operationType = WebServiceWorkerCache::OperationTypePut; |
| 719 request->populateWebServiceWorkerRequest(putOperation.request); | 719 request->populateWebServiceWorkerRequest(putOperation.request); |
| 720 response->populateWebServiceWorkerResponse(putOperation.response); | 720 response->populateWebServiceWorkerResponse(putOperation.response); |
| 721 expectedPutOperations[0] = putOperation; | 721 expectedPutOperations[0] = putOperation; |
| 722 } | 722 } |
| 723 testCache->setExpectedBatchOperations(&expectedPutOperations); | 723 testCache->setExpectedBatchOperations(&expectedPutOperations); |
| 724 | 724 |
| 725 ScriptPromise addResult = cache->add( | 725 ScriptPromise addResult = cache->add( |
| 726 getScriptState(), requestToRequestInfo(request), exceptionState); | 726 getScriptState(), requestToRequestInfo(request), exceptionState); |
| 727 | 727 |
| 728 EXPECT_EQ(kNotImplementedString, getRejectString(addResult)); | 728 EXPECT_EQ(kNotImplementedString, getRejectString(addResult)); |
| 729 EXPECT_EQ(1, fetcher->fetchCount()); | 729 EXPECT_EQ(1, fetcher->fetchCount()); |
| 730 EXPECT_EQ("dispatchBatch", | 730 EXPECT_EQ("dispatchBatch", |
| 731 testCache->getAndClearLastErrorWebCacheMethodCalled()); | 731 testCache->getAndClearLastErrorWebCacheMethodCalled()); |
| 732 } | 732 } |
| 733 | 733 |
| 734 } // namespace | 734 } // namespace |
| 735 | 735 |
| 736 } // namespace blink | 736 } // namespace blink |
| OLD | NEW |