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

Side by Side Diff: Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp

Issue 813943003: Fix handling of broken GIFs with weird frame sizes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: commens Created 5 years, 11 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
« no previous file with comments | « no previous file | Source/platform/image-decoders/gif/GIFImageReader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 RefPtr<SharedBuffer> data = readFile("/Source/web/tests/data/invalid-disposa l-method.gif"); 492 RefPtr<SharedBuffer> data = readFile("/Source/web/tests/data/invalid-disposa l-method.gif");
493 ASSERT_TRUE(data.get()); 493 ASSERT_TRUE(data.get());
494 decoder->setData(data.get(), true); 494 decoder->setData(data.get(), true);
495 495
496 EXPECT_EQ(2u, decoder->frameCount()); 496 EXPECT_EQ(2u, decoder->frameCount());
497 // Disposal method 4 is converted to ImageFrame::DisposeOverwritePrevious. 497 // Disposal method 4 is converted to ImageFrame::DisposeOverwritePrevious.
498 EXPECT_EQ(ImageFrame::DisposeOverwritePrevious, decoder->frameBufferAtIndex( 0)->disposalMethod()); 498 EXPECT_EQ(ImageFrame::DisposeOverwritePrevious, decoder->frameBufferAtIndex( 0)->disposalMethod());
499 // Disposal method 5 is ignored. 499 // Disposal method 5 is ignored.
500 EXPECT_EQ(ImageFrame::DisposeNotSpecified, decoder->frameBufferAtIndex(1)->d isposalMethod()); 500 EXPECT_EQ(ImageFrame::DisposeNotSpecified, decoder->frameBufferAtIndex(1)->d isposalMethod());
501 } 501 }
502
503 TEST(GIFImageDecoderTest, firstFrameHasGreaterSizeThanScreenSize)
504 {
505 RefPtr<SharedBuffer> fullData = readFile("/Source/platform/image-decoders/te sting/first-frame-has-greater-size-than-screen-size.gif");
Stephen White 2015/01/14 22:17:02 Not new to this CL, but we should probably shorten
Alpha Left Google 2015/01/14 23:14:59 Done.
506 ASSERT_TRUE(fullData.get());
507
508 OwnPtr<GIFImageDecoder> decoder;
509 IntSize frameSize;
510
511 // Compute hashes when the file is truncated.
512 for (size_t i = 1; i <= fullData->size(); ++i) {
513 decoder = createDecoder();
514 RefPtr<SharedBuffer> data = SharedBuffer::create(fullData->data(), i);
515 decoder->setData(data.get(), i == fullData->size());
516
517 if (decoder->isSizeAvailable() && !frameSize.width() && !frameSize.heigh t()) {
518 frameSize = decoder->decodedSize();
519 continue;
520 }
521
522 ASSERT_EQ(frameSize.width(), decoder->decodedSize().width());
523 ASSERT_EQ(frameSize.height(), decoder->decodedSize().height());
524 }
525 }
OLDNEW
« no previous file with comments | « no previous file | Source/platform/image-decoders/gif/GIFImageReader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698