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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 EXPECT_EQ(frameCount, decoder->frameCount()); | 444 EXPECT_EQ(frameCount, decoder->frameCount()); |
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(notFound); | 447 decoder->clearCacheExceptFrame(notFound); |
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 | |
455 // The first LZW code in the image is invalid. Decoding should fail. | |
Peter Kasting
2013/09/05 06:13:01
Nit: Perhaps:
The first LZW codes in the image ar
Alpha Left Google
2013/09/05 17:02:28
Done.
| |
456 TEST(GIFImageDecoderTest, badInitialCode) | |
457 { | |
458 RefPtr<SharedBuffer> testData = readFile("/Source/web/tests/data/bad-initial -code.gif"); | |
459 ASSERT_TRUE(testData.get()); | |
460 | |
461 OwnPtr<GIFImageDecoder> testDecoder(createDecoder()); | |
462 testDecoder->setData(testData.get(), true); | |
463 EXPECT_EQ(1u, testDecoder->frameCount()); | |
464 ASSERT_TRUE(testDecoder->frameBufferAtIndex(0)); | |
465 EXPECT_TRUE(testDecoder->failed()); | |
466 } | |
467 | |
468 // Image has an invalid LZW code. Decoding should fail. | |
469 TEST(GIFImageDecoderTest, badCode) | |
470 { | |
471 RefPtr<SharedBuffer> testData = readFile("/Source/web/tests/data/bad-code.gi f"); | |
472 ASSERT_TRUE(testData.get()); | |
473 | |
474 OwnPtr<GIFImageDecoder> testDecoder(createDecoder()); | |
475 testDecoder->setData(testData.get(), true); | |
476 EXPECT_EQ(1u, testDecoder->frameCount()); | |
477 ASSERT_TRUE(testDecoder->frameBufferAtIndex(0)); | |
478 EXPECT_TRUE(testDecoder->failed()); | |
479 } | |
OLD | NEW |