| Index: third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp b/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
|
| index e7765ce3f8239b1753ff6d56c9a1117106ac96b3..3d39d8737d391f68043f6776251ddd4512aa5179 100644
|
| --- a/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
|
| +++ b/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
|
| @@ -80,9 +80,43 @@ static Vector<unsigned char> jpegImage()
|
| return jpeg;
|
| }
|
|
|
| +namespace {
|
| +
|
| +class MockTaskRunner : public blink::WebTaskRunner {
|
| + void postTask(const WebTraceLocation&, Task*) override { }
|
| + void postDelayedTask(const WebTraceLocation&, Task*, double) override { }
|
| + WebTaskRunner* clone() override { return nullptr; }
|
| + double virtualTimeSeconds() const override { return 0.0; }
|
| + double monotonicallyIncreasingVirtualTimeSeconds() const override { return 0.0; }
|
| +};
|
| +
|
| +}
|
| +
|
| +class ImageResourceTestMockFetchContext : public FetchContext {
|
| +public:
|
| + static ImageResourceTestMockFetchContext* create()
|
| + {
|
| + return new ImageResourceTestMockFetchContext;
|
| + }
|
| +
|
| + virtual ~ImageResourceTestMockFetchContext() { }
|
| +
|
| + bool allowImage(bool imagesEnabled, const KURL&) const override { return true; }
|
| + bool canRequest(Resource::Type, const ResourceRequest&, const KURL&, const ResourceLoaderOptions&, bool forPreload, FetchRequest::OriginRestriction) const override { return true; }
|
| + bool shouldLoadNewResource(Resource::Type) const override { return true; }
|
| + WebTaskRunner* loadingTaskRunner() const override { return m_runner.get(); }
|
| +
|
| +private:
|
| + ImageResourceTestMockFetchContext()
|
| + : m_runner(adoptPtr(new MockTaskRunner))
|
| + { }
|
| +
|
| + OwnPtr<MockTaskRunner> m_runner;
|
| +};
|
| +
|
| TEST(ImageResourceTest, MultipartImage)
|
| {
|
| - ResourceFetcher* fetcher = ResourceFetcher::create(nullptr);
|
| + ResourceFetcher* fetcher = ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
|
| KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
|
| URLTestHelpers::registerMockedURLLoad(testURL, "cancelTest.html", "text/html");
|
|
|
| @@ -148,7 +182,7 @@ TEST(ImageResourceTest, CancelOnDetach)
|
| KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
|
| URLTestHelpers::registerMockedURLLoad(testURL, "cancelTest.html", "text/html");
|
|
|
| - ResourceFetcher* fetcher = ResourceFetcher::create(nullptr);
|
| + ResourceFetcher* fetcher = ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
|
|
|
| // Emulate starting a real load.
|
| ImageResource* cachedImage = ImageResource::create(ResourceRequest(testURL));
|
| @@ -234,7 +268,7 @@ TEST(ImageResourceTest, ReloadIfLoFi)
|
| cachedImage->setStatus(Resource::Pending);
|
|
|
| MockImageResourceClient client(cachedImage);
|
| - ResourceFetcher* fetcher = ResourceFetcher::create(nullptr);
|
| + ResourceFetcher* fetcher = ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
|
|
|
| // Send the image response.
|
| Vector<unsigned char> jpeg = jpegImage();
|
|
|