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

Unified Diff: third_party/WebKit/Source/core/loader/resource/ImageResourceTest.cpp

Issue 2645953005: Add more unit tests for ImageResource's DecodeError (Closed)
Patch Set: Include path fix Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/loader/resource/MockImageResourceObserver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/loader/resource/ImageResourceTest.cpp
diff --git a/third_party/WebKit/Source/core/loader/resource/ImageResourceTest.cpp b/third_party/WebKit/Source/core/loader/resource/ImageResourceTest.cpp
index c5c2ac20f78d64407e5bdd77dff2f6bda247bfb5..ca8926fb235ca9389f6575a0a5f6b94d43103e3e 100644
--- a/third_party/WebKit/Source/core/loader/resource/ImageResourceTest.cpp
+++ b/third_party/WebKit/Source/core/loader/resource/ImageResourceTest.cpp
@@ -853,6 +853,8 @@ TEST(ImageResourceTest, CancelOnDecodeError) {
ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
FetchRequest request(testURL, FetchInitiatorInfo());
ImageResource* imageResource = ImageResource::fetch(request, fetcher);
+ std::unique_ptr<MockImageResourceObserver> observer =
+ MockImageResourceObserver::create(imageResource->getContent());
imageResource->loader()->didReceiveResponse(
WrappedResourceResponse(
@@ -860,6 +862,37 @@ TEST(ImageResourceTest, CancelOnDecodeError) {
nullptr);
imageResource->loader()->didReceiveData("notactuallyanimage", 18);
EXPECT_EQ(ResourceStatus::DecodeError, imageResource->getStatus());
+ EXPECT_TRUE(observer->imageNotifyFinishedCalled());
+ EXPECT_EQ(ResourceStatus::DecodeError,
+ observer->statusOnImageNotifyFinished());
+ EXPECT_FALSE(imageResource->isLoading());
+}
+
+TEST(ImageResourceTest, DecodeErrorWithEmptyBody) {
+ KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
+ ScopedRegisteredURL scopedRegisteredURL(testURL);
+
+ ResourceFetcher* fetcher =
+ ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
+ FetchRequest request(testURL, FetchInitiatorInfo());
+ ImageResource* imageResource = ImageResource::fetch(request, fetcher);
+ std::unique_ptr<MockImageResourceObserver> observer =
+ MockImageResourceObserver::create(imageResource->getContent());
+
+ imageResource->loader()->didReceiveResponse(
+ WrappedResourceResponse(
+ ResourceResponse(testURL, "image/jpeg", 0, nullAtom, String())),
+ nullptr);
+
+ EXPECT_EQ(ResourceStatus::Pending, imageResource->getStatus());
+ EXPECT_FALSE(observer->imageNotifyFinishedCalled());
+
+ imageResource->loader()->didFinishLoading(0.0, 0, 0);
+
+ EXPECT_EQ(ResourceStatus::DecodeError, imageResource->getStatus());
+ EXPECT_TRUE(observer->imageNotifyFinishedCalled());
+ EXPECT_EQ(ResourceStatus::DecodeError,
+ observer->statusOnImageNotifyFinished());
EXPECT_FALSE(imageResource->isLoading());
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/loader/resource/MockImageResourceObserver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698