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

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

Issue 2393113002: ImageResource: Reset the encoded image size after receiving all data (Closed)
Patch Set: Rename encodedSizeMemoryUsage -> encodedSizeMemoryUsageForTesting Created 4 years, 2 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
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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.cpp ('k') | third_party/WebKit/Source/core/fetch/Resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698