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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp

Issue 2122123002: Add a test for a multipart image as cache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // This part finishes. The image is created, callbacks are sent, and the dat a buffer is cleared. 238 // This part finishes. The image is created, callbacks are sent, and the dat a buffer is cleared.
239 cachedImage->loader()->didFinishLoading(nullptr, 0.0, 0); 239 cachedImage->loader()->didFinishLoading(nullptr, 0.0, 0);
240 ASSERT_FALSE(cachedImage->resourceBuffer()); 240 ASSERT_FALSE(cachedImage->resourceBuffer());
241 ASSERT_FALSE(cachedImage->errorOccurred()); 241 ASSERT_FALSE(cachedImage->errorOccurred());
242 ASSERT_TRUE(cachedImage->hasImage()); 242 ASSERT_TRUE(cachedImage->hasImage());
243 ASSERT_FALSE(cachedImage->getImage()->isNull()); 243 ASSERT_FALSE(cachedImage->getImage()->isNull());
244 ASSERT_EQ(cachedImage->getImage()->width(), 1); 244 ASSERT_EQ(cachedImage->getImage()->width(), 1);
245 ASSERT_EQ(cachedImage->getImage()->height(), 1); 245 ASSERT_EQ(cachedImage->getImage()->height(), 1);
246 ASSERT_EQ(client->imageChangedCount(), 1); 246 ASSERT_EQ(client->imageChangedCount(), 1);
247 ASSERT_TRUE(client->notifyFinishedCalled()); 247 ASSERT_TRUE(client->notifyFinishedCalled());
248
249 // When the multipart image is retrieved from the cache, the image is empty.
250 cachedImage = ImageResource::create(ResourceRequest(testURL));
251 ASSERT_FALSE(cachedImage->resourceBuffer());
252 ASSERT_FALSE(cachedImage->errorOccurred());
253 ASSERT_FALSE(cachedImage->hasImage());
254 ASSERT_TRUE(cachedImage->getImage()->isNull());
248 } 255 }
249 256
250 TEST(ImageResourceTest, CancelOnDetach) 257 TEST(ImageResourceTest, CancelOnDetach)
251 { 258 {
252 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html"); 259 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
253 URLTestHelpers::registerMockedURLLoad(testURL, "cancelTest.html", "text/html "); 260 URLTestHelpers::registerMockedURLLoad(testURL, "cancelTest.html", "text/html ");
254 261
255 ResourceFetcher* fetcher = ResourceFetcher::create(ImageResourceTestMockFetc hContext::create()); 262 ResourceFetcher* fetcher = ResourceFetcher::create(ImageResourceTestMockFetc hContext::create());
256 263
257 // Emulate starting a real load. 264 // Emulate starting a real load.
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 ASSERT_TRUE(imageResource->hasImage()); 575 ASSERT_TRUE(imageResource->hasImage());
569 EXPECT_FALSE(imageResource->getImage()->isNull()); 576 EXPECT_FALSE(imageResource->getImage()->isNull());
570 EXPECT_EQ(2, client->imageChangedCount()); 577 EXPECT_EQ(2, client->imageChangedCount());
571 EXPECT_TRUE(client->notifyFinishedCalled()); 578 EXPECT_TRUE(client->notifyFinishedCalled());
572 EXPECT_FALSE(imageResource->getImage()->isBitmapImage()); 579 EXPECT_FALSE(imageResource->getImage()->isBitmapImage());
573 EXPECT_EQ(300, imageResource->getImage()->width()); 580 EXPECT_EQ(300, imageResource->getImage()->width());
574 EXPECT_EQ(300, imageResource->getImage()->height()); 581 EXPECT_EQ(300, imageResource->getImage()->height());
575 } 582 }
576 583
577 } // namespace blink 584 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698