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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 ResourceResponse(KURL(), "multipart/x-mixed-replace", 0, nullAtom, | 341 ResourceResponse(KURL(), "multipart/x-mixed-replace", 0, nullAtom, |
342 String()), | 342 String()), |
343 nullptr); | 343 nullptr); |
344 | 344 |
345 Vector<unsigned char> jpeg = jpegImage(); | 345 Vector<unsigned char> jpeg = jpegImage(); |
346 cachedImage->responseReceived( | 346 cachedImage->responseReceived( |
347 ResourceResponse(KURL(), "image/jpeg", jpeg.size(), nullAtom, String()), | 347 ResourceResponse(KURL(), "image/jpeg", jpeg.size(), nullAtom, String()), |
348 nullptr); | 348 nullptr); |
349 cachedImage->appendData(reinterpret_cast<const char*>(jpeg.data()), | 349 cachedImage->appendData(reinterpret_cast<const char*>(jpeg.data()), |
350 jpeg.size()); | 350 jpeg.size()); |
| 351 EXPECT_NE(0u, cachedImage->encodedSizeMemoryUsageForTesting()); |
351 cachedImage->finish(); | 352 cachedImage->finish(); |
| 353 EXPECT_EQ(0u, cachedImage->encodedSizeMemoryUsageForTesting()); |
352 EXPECT_FALSE(cachedImage->errorOccurred()); | 354 EXPECT_FALSE(cachedImage->errorOccurred()); |
353 ASSERT_TRUE(cachedImage->hasImage()); | 355 ASSERT_TRUE(cachedImage->hasImage()); |
354 EXPECT_FALSE(cachedImage->getImage()->isNull()); | 356 EXPECT_FALSE(cachedImage->getImage()->isNull()); |
355 EXPECT_TRUE(client->notifyFinishedCalled()); | 357 EXPECT_TRUE(client->notifyFinishedCalled()); |
356 | 358 |
357 // The prune comes when the ImageResource still has clients. The image should | 359 // The prune comes when the ImageResource still has clients. The image should |
358 // not be deleted. | 360 // not be deleted. |
359 cachedImage->prune(); | 361 cachedImage->prune(); |
360 EXPECT_TRUE(cachedImage->isAlive()); | 362 EXPECT_TRUE(cachedImage->isAlive()); |
361 ASSERT_TRUE(cachedImage->hasImage()); | 363 ASSERT_TRUE(cachedImage->hasImage()); |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 nullptr, WrappedResourceResponse(ResourceResponse( | 785 nullptr, WrappedResourceResponse(ResourceResponse( |
784 testURL, "image/jpeg", 18, nullAtom, String())), | 786 testURL, "image/jpeg", 18, nullAtom, String())), |
785 nullptr); | 787 nullptr); |
786 cachedImage->loader()->didReceiveData(nullptr, "notactuallyanimage", 18, 18, | 788 cachedImage->loader()->didReceiveData(nullptr, "notactuallyanimage", 18, 18, |
787 18); | 789 18); |
788 EXPECT_EQ(Resource::DecodeError, cachedImage->getStatus()); | 790 EXPECT_EQ(Resource::DecodeError, cachedImage->getStatus()); |
789 EXPECT_FALSE(cachedImage->isLoading()); | 791 EXPECT_FALSE(cachedImage->isLoading()); |
790 } | 792 } |
791 | 793 |
792 } // namespace blink | 794 } // namespace blink |
OLD | NEW |