Chromium Code Reviews| Index: third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp |
| diff --git a/third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp b/third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp |
| index 873156876f6fe1b75977607bd3a62a25a81e6b11..f57de5388d8bff36e9cc7282186eda7877ace5d6 100644 |
| --- a/third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp |
| +++ b/third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp |
| @@ -34,6 +34,7 @@ |
| #include "core/fetch/FetchInitiatorTypeNames.h" |
| #include "core/fetch/FetchRequest.h" |
| #include "core/fetch/MemoryCache.h" |
| +#include "core/fetch/RawResource.h" |
| #include "core/fetch/ResourceLoader.h" |
| #include "platform/exported/WrappedResourceResponse.h" |
| #include "platform/heap/Handle.h" |
| @@ -237,4 +238,31 @@ TEST_F(ResourceFetcherTest, DontReuseMediaDataUrl) |
| memoryCache()->remove(resource2.get()); |
| } |
| +class ServeRequestsOnCompleteClient : public RawResourceClient { |
| +public: |
| + void notifyFinished(Resource*) override |
| + { |
| + Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
| + } |
| + |
|
hiroshige
2016/03/15 21:52:34
In addition to the RELEASE_ASSERT, how about addin
Nate Chapin
2016/03/16 17:04:03
Done.
|
| + String debugName() const override { return "ServeRequestsOnCompleteClient"; } |
| +}; |
| + |
| +TEST_F(ResourceFetcherTest, ResponseOnCancel) |
|
hiroshige
2016/03/15 21:52:34
How about adding comments that have
- link to Issu
Nate Chapin
2016/03/16 17:04:03
Done.
|
| +{ |
| + KURL url(ParsedURLString, "http://127.0.0.1:8000/foo.html"); |
| + ResourceResponse response; |
| + response.setURL(url); |
| + response.setHTTPStatusCode(200); |
| + URLTestHelpers::registerMockedURLLoadWithCustomResponse(url, "white-1x1.png", WebString::fromUTF8(""), WrappedResourceResponse(response)); |
| + |
| + ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFetchContext::create()); |
| + FetchRequest fetchRequest = FetchRequest(url, FetchInitiatorInfo()); |
| + RefPtrWillBeRawPtr<Resource> resource = fetcher->requestResource(fetchRequest, TestResourceFactory(Resource::Raw)); |
| + ServeRequestsOnCompleteClient client; |
| + resource->addClient(&client); |
| + resource->loader()->cancel(); |
| + Platform::current()->unitTestSupport()->unregisterMockedURL(url); |
| +} |
| + |
| } // namespace blink |