本文整理汇总了C++中ImageResource::loader方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageResource::loader方法的具体用法?C++ ImageResource::loader怎么用?C++ ImageResource::loader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageResource
的用法示例。
在下文中一共展示了ImageResource::loader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testURL
TEST(ImageResourceTest, CancelOnDecodeError) {
KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
ScopedRegisteredURL scopedRegisteredURL(testURL);
ResourceFetcher* fetcher =
ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
FetchRequest request(testURL, FetchInitiatorInfo());
ImageResource* cachedImage = ImageResource::fetch(request, fetcher);
cachedImage->loader()->didReceiveResponse(
nullptr, WrappedResourceResponse(ResourceResponse(
testURL, "image/jpeg", 18, nullAtom, String())),
nullptr);
cachedImage->loader()->didReceiveData(nullptr, "notactuallyanimage", 18, 18,
18);
EXPECT_EQ(Resource::DecodeError, cachedImage->getStatus());
EXPECT_FALSE(cachedImage->isLoading());
}
示例2: testURL
TEST(ImageResourceTest, ReloadIfLoFi)
{
KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
URLTestHelpers::registerMockedURLLoad(testURL, "cancelTest.html", "text/html");
ResourceRequest request = ResourceRequest(testURL);
request.setLoFiState(WebURLRequest::LoFiOn);
ImageResource* cachedImage = ImageResource::create(request);
cachedImage->setStatus(Resource::Pending);
Persistent<MockImageResourceClient> client = new MockImageResourceClient(cachedImage);
ResourceFetcher* fetcher = ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
// Send the image response.
Vector<unsigned char> jpeg = jpegImage();
ResourceResponse resourceResponse(KURL(), "image/jpeg", jpeg.size(), nullAtom, String());
resourceResponse.addHTTPHeaderField("chrome-proxy", "q=low");
cachedImage->responseReceived(resourceResponse, nullptr);
cachedImage->appendData(reinterpret_cast<const char*>(jpeg.data()), jpeg.size());
cachedImage->finish();
ASSERT_FALSE(cachedImage->errorOccurred());
ASSERT_TRUE(cachedImage->hasImage());
ASSERT_FALSE(cachedImage->getImage()->isNull());
ASSERT_EQ(client->imageChangedCount(), 2);
ASSERT_TRUE(client->notifyFinishedCalled());
ASSERT_TRUE(cachedImage->getImage()->isBitmapImage());
EXPECT_EQ(1, cachedImage->getImage()->width());
EXPECT_EQ(1, cachedImage->getImage()->height());
cachedImage->reloadIfLoFi(fetcher);
ASSERT_FALSE(cachedImage->errorOccurred());
ASSERT_FALSE(cachedImage->resourceBuffer());
ASSERT_FALSE(cachedImage->hasImage());
ASSERT_EQ(client->imageChangedCount(), 3);
cachedImage->loader()->didReceiveResponse(nullptr, WrappedResourceResponse(resourceResponse), nullptr);
cachedImage->loader()->didReceiveData(nullptr, reinterpret_cast<const char*>(jpeg.data()), jpeg.size(), jpeg.size());
cachedImage->loader()->didFinishLoading(nullptr, 0.0, jpeg.size());
ASSERT_FALSE(cachedImage->errorOccurred());
ASSERT_TRUE(cachedImage->hasImage());
ASSERT_FALSE(cachedImage->getImage()->isNull());
ASSERT_TRUE(client->notifyFinishedCalled());
ASSERT_TRUE(cachedImage->getImage()->isBitmapImage());
}