OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |