| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 cachedImage->loader()->didReceiveResponse(nullptr, WrappedResourceResponse(r
esourceResponse), nullptr); | 300 cachedImage->loader()->didReceiveResponse(nullptr, WrappedResourceResponse(r
esourceResponse), nullptr); |
| 301 cachedImage->loader()->didReceiveData(nullptr, reinterpret_cast<const char*>
(jpeg.data()), jpeg.size(), jpeg.size()); | 301 cachedImage->loader()->didReceiveData(nullptr, reinterpret_cast<const char*>
(jpeg.data()), jpeg.size(), jpeg.size()); |
| 302 cachedImage->loader()->didFinishLoading(nullptr, 0.0, jpeg.size()); | 302 cachedImage->loader()->didFinishLoading(nullptr, 0.0, jpeg.size()); |
| 303 ASSERT_FALSE(cachedImage->errorOccurred()); | 303 ASSERT_FALSE(cachedImage->errorOccurred()); |
| 304 ASSERT_TRUE(cachedImage->hasImage()); | 304 ASSERT_TRUE(cachedImage->hasImage()); |
| 305 ASSERT_FALSE(cachedImage->getImage()->isNull()); | 305 ASSERT_FALSE(cachedImage->getImage()->isNull()); |
| 306 ASSERT_TRUE(client->notifyFinishedCalled()); | 306 ASSERT_TRUE(client->notifyFinishedCalled()); |
| 307 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage()); | 307 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage()); |
| 308 } | 308 } |
| 309 | 309 |
| 310 // Tests for pruning. | |
| 311 | |
| 312 TEST(ImageResourceTest, AddClientAfterPrune) | |
| 313 { | |
| 314 KURL url(ParsedURLString, "http://127.0.0.1:8000/foo"); | |
| 315 ImageResource* imageResource = ImageResource::create(ResourceRequest(url)); | |
| 316 | |
| 317 // Adds a ResourceClient but not ImageResourceObserver. | |
| 318 Persistent<MockResourceClient> client1 = new MockResourceClient(imageResourc
e); | |
| 319 | |
| 320 receiveResponse(imageResource, url, "image/jpeg", jpegImage()); | |
| 321 | |
| 322 EXPECT_FALSE(imageResource->errorOccurred()); | |
| 323 ASSERT_TRUE(imageResource->hasImage()); | |
| 324 EXPECT_FALSE(imageResource->getImage()->isNull()); | |
| 325 EXPECT_EQ(1, imageResource->getImage()->width()); | |
| 326 EXPECT_EQ(1, imageResource->getImage()->height()); | |
| 327 EXPECT_TRUE(client1->notifyFinishedCalled()); | |
| 328 | |
| 329 client1->removeAsClient(); | |
| 330 | |
| 331 EXPECT_FALSE(imageResource->hasClientsOrObservers()); | |
| 332 | |
| 333 imageResource->prune(); | |
| 334 | |
| 335 EXPECT_FALSE(imageResource->hasImage()); | |
| 336 | |
| 337 // Re-adds a ResourceClient but not ImageResourceObserver. | |
| 338 Persistent<MockResourceClient> client2 = new MockResourceClient(imageResourc
e); | |
| 339 | |
| 340 ASSERT_TRUE(imageResource->hasImage()); | |
| 341 EXPECT_FALSE(imageResource->getImage()->isNull()); | |
| 342 EXPECT_EQ(1, imageResource->getImage()->width()); | |
| 343 EXPECT_EQ(1, imageResource->getImage()->height()); | |
| 344 EXPECT_TRUE(client2->notifyFinishedCalled()); | |
| 345 } | |
| 346 | |
| 347 } // namespace blink | 310 } // namespace blink |
| OLD | NEW |