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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 ImageFrame* lastFrame = decoder->frameBufferAtIndex(frameCount - 1); | 445 ImageFrame* lastFrame = decoder->frameBufferAtIndex(frameCount - 1); |
446 EXPECT_EQ(baselineHashes[frameCount - 1], hashSkBitmap(lastFrame->getSkBitma p())); | 446 EXPECT_EQ(baselineHashes[frameCount - 1], hashSkBitmap(lastFrame->getSkBitma p())); |
447 decoder->clearCacheExceptFrame(kNotFound); | 447 decoder->clearCacheExceptFrame(kNotFound); |
448 | 448 |
449 // Resume decoding of the first frame. | 449 // Resume decoding of the first frame. |
450 ImageFrame* firstFrame = decoder->frameBufferAtIndex(0); | 450 ImageFrame* firstFrame = decoder->frameBufferAtIndex(0); |
451 EXPECT_EQ(ImageFrame::FrameComplete, firstFrame->status()); | 451 EXPECT_EQ(ImageFrame::FrameComplete, firstFrame->status()); |
452 EXPECT_EQ(baselineHashes[0], hashSkBitmap(firstFrame->getSkBitmap())); | 452 EXPECT_EQ(baselineHashes[0], hashSkBitmap(firstFrame->getSkBitmap())); |
453 } | 453 } |
454 | 454 |
455 // The first LZW codes in the image is invalid that try to create a loop in | |
456 // dictionary. Decoding should fail, but not infinitely loop or corrupt memory. | |
Peter Kasting
2013/10/03 17:52:27
Nit: This first sentence got quite mangled and is
| |
457 TEST(GIFImageDecoderTest, badInitialCode) | |
458 { | |
459 RefPtr<SharedBuffer> testData = readFile("/Source/core/platform/image-decode rs/testing/bad-initial-code.gif"); | |
460 ASSERT_TRUE(testData.get()); | |
461 | |
462 OwnPtr<GIFImageDecoder> testDecoder(createDecoder()); | |
463 testDecoder->setData(testData.get(), true); | |
464 EXPECT_EQ(1u, testDecoder->frameCount()); | |
465 ASSERT_TRUE(testDecoder->frameBufferAtIndex(0)); | |
466 EXPECT_TRUE(testDecoder->failed()); | |
467 } | |
468 | |
469 // Image has an invalid LZW code that exceeds dictionary size. Decoding should f ail. | |
Peter Kasting
2013/10/03 17:52:27
Nit: Add missing articles: "The image has an inval
| |
470 TEST(GIFImageDecoderTest, badCode) | |
471 { | |
472 RefPtr<SharedBuffer> testData = readFile("/Source/core/platform/image-decode rs/testing/bad-code.gif"); | |
473 ASSERT_TRUE(testData.get()); | |
474 | |
475 OwnPtr<GIFImageDecoder> testDecoder(createDecoder()); | |
476 testDecoder->setData(testData.get(), true); | |
477 EXPECT_EQ(1u, testDecoder->frameCount()); | |
478 ASSERT_TRUE(testDecoder->frameBufferAtIndex(0)); | |
479 EXPECT_TRUE(testDecoder->failed()); | |
480 } | |
481 | |
455 TEST(GIFImageDecoderTest, invalidDisposalMethod) | 482 TEST(GIFImageDecoderTest, invalidDisposalMethod) |
456 { | 483 { |
457 OwnPtr<GIFImageDecoder> decoder = createDecoder(); | 484 OwnPtr<GIFImageDecoder> decoder = createDecoder(); |
458 | 485 |
459 // The image has 2 frames, with disposal method 4 and 5, respectively. | 486 // The image has 2 frames, with disposal method 4 and 5, respectively. |
460 RefPtr<SharedBuffer> data = readFile("/Source/web/tests/data/invalid-disposa l-method.gif"); | 487 RefPtr<SharedBuffer> data = readFile("/Source/web/tests/data/invalid-disposa l-method.gif"); |
461 ASSERT_TRUE(data.get()); | 488 ASSERT_TRUE(data.get()); |
462 decoder->setData(data.get(), true); | 489 decoder->setData(data.get(), true); |
463 | 490 |
464 EXPECT_EQ(2u, decoder->frameCount()); | 491 EXPECT_EQ(2u, decoder->frameCount()); |
465 // Disposal method 4 is converted to ImageFrame::DisposeOverwritePrevious. | 492 // Disposal method 4 is converted to ImageFrame::DisposeOverwritePrevious. |
466 EXPECT_EQ(ImageFrame::DisposeOverwritePrevious, decoder->frameBufferAtIndex( 0)->disposalMethod()); | 493 EXPECT_EQ(ImageFrame::DisposeOverwritePrevious, decoder->frameBufferAtIndex( 0)->disposalMethod()); |
467 // Disposal method 5 is ignored. | 494 // Disposal method 5 is ignored. |
468 EXPECT_EQ(ImageFrame::DisposeNotSpecified, decoder->frameBufferAtIndex(1)->d isposalMethod()); | 495 EXPECT_EQ(ImageFrame::DisposeNotSpecified, decoder->frameBufferAtIndex(1)->d isposalMethod()); |
469 } | 496 } |
OLD | NEW |