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

Side by Side Diff: Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp

Issue 1358643002: Fix caching bug in JPEGImageDecoder (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 233
234 TEST(JPEGImageDecoderTest, byteByByte) 234 TEST(JPEGImageDecoderTest, byteByByte)
235 { 235 {
236 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/len na.jpg", 1u, cAnimationNone); 236 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/len na.jpg", 1u, cAnimationNone);
237 // Progressive image 237 // Progressive image
238 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/flo wchart.jpg", 1u, cAnimationNone); 238 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/flo wchart.jpg", 1u, cAnimationNone);
239 // Image with restart markers 239 // Image with restart markers
240 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/red -at-12-oclock-with-color-profile.jpg", 1u, cAnimationNone); 240 testByteByByteDecode(&createDecoder, "/LayoutTests/fast/images/resources/red -at-12-oclock-with-color-profile.jpg", 1u, cAnimationNone);
241 } 241 }
242 242
243 static unsigned createDecodingBaseline(SharedBuffer* data)
244 {
245 OwnPtr<ImageDecoder> decoder = createDecoder();
246 decoder->setData(data, true);
247 ImageFrame* frame = decoder->frameBufferAtIndex(0);
248 return hashBitmap(frame->bitmap());
249 }
250
251 TEST(JPEGImageDecoderTest, mergeBuffer)
252 {
253 const char* jpegFile = "/LayoutTests/fast/images/resources/lenna.jpg"; // 25 6x256
254 RefPtr<SharedBuffer> data = readFile(jpegFile);
255 ASSERT_TRUE(data);
256
257 const unsigned hash = createDecodingBaseline(data.get());
258
259 RefPtr<SharedBuffer> segmentedData = SharedBuffer::create();
260 segmentedData->append(data->data(), data->size());
Peter Kasting 2015/09/19 00:51:34 You should have comments in this test about what y
scroggo_chromium 2015/09/21 18:21:28 Done.
261
262 OwnPtr<ImageDecoder> decoder = createDecoder();
263 decoder->setData(segmentedData.get(), true);
264
265 ASSERT_TRUE(decoder->isSizeAvailable());
266
267 segmentedData->data();
268 ImageFrame* frame = decoder->frameBufferAtIndex(0);
269 ASSERT_FALSE(decoder->failed());
270 EXPECT_EQ(frame->status(), ImageFrame::FrameComplete);
271 EXPECT_EQ(hashBitmap(frame->bitmap()), hash);
272 }
273
243 } // namespace blink 274 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698