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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 179 } |
180 | 180 |
181 TEST(GIFImageDecoderTest, brokenSecondFrame) | 181 TEST(GIFImageDecoderTest, brokenSecondFrame) |
182 { | 182 { |
183 OwnPtr<GIFImageDecoder> decoder(createDecoder()); | 183 OwnPtr<GIFImageDecoder> decoder(createDecoder()); |
184 | 184 |
185 RefPtr<SharedBuffer> data = readFile("/Source/WebKit/chromium/tests/data/bro
ken.gif"); | 185 RefPtr<SharedBuffer> data = readFile("/Source/WebKit/chromium/tests/data/bro
ken.gif"); |
186 ASSERT_TRUE(data.get()); | 186 ASSERT_TRUE(data.get()); |
187 decoder->setData(data.get(), true); | 187 decoder->setData(data.get(), true); |
188 | 188 |
189 EXPECT_EQ(0u, decoder->frameCount()); | 189 // One frame is detected but cannot be decoded. |
190 ImageFrame* frame = decoder->frameBufferAtIndex(0); | 190 EXPECT_EQ(1u, decoder->frameCount()); |
| 191 ImageFrame* frame = decoder->frameBufferAtIndex(1); |
191 EXPECT_FALSE(frame); | 192 EXPECT_FALSE(frame); |
192 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount()); | |
193 } | 193 } |
194 | 194 |
195 TEST(GIFImageDecoderTest, progressiveDecode) | 195 TEST(GIFImageDecoderTest, progressiveDecode) |
196 { | 196 { |
197 RefPtr<SharedBuffer> fullData = readFile("/Source/WebKit/chromium/tests/data
/radient.gif"); | 197 RefPtr<SharedBuffer> fullData = readFile("/Source/WebKit/chromium/tests/data
/radient.gif"); |
198 ASSERT_TRUE(fullData.get()); | 198 ASSERT_TRUE(fullData.get()); |
199 const size_t fullLength = fullData->size(); | 199 const size_t fullLength = fullData->size(); |
200 | 200 |
201 OwnPtr<GIFImageDecoder> decoder; | 201 OwnPtr<GIFImageDecoder> decoder; |
202 ImageFrame* frame; | 202 ImageFrame* frame; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 EXPECT_FALSE(decoder->failed()); | 290 EXPECT_FALSE(decoder->failed()); |
291 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0)); | 291 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0)); |
292 EXPECT_FALSE(decoder->frameIsCompleteAtIndex(1)); | 292 EXPECT_FALSE(decoder->frameIsCompleteAtIndex(1)); |
293 | 293 |
294 decoder->setData(data.get(), true); | 294 decoder->setData(data.get(), true); |
295 EXPECT_EQ(2u, decoder->frameCount()); | 295 EXPECT_EQ(2u, decoder->frameCount()); |
296 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0)); | 296 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0)); |
297 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(1)); | 297 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(1)); |
298 } | 298 } |
299 | 299 |
| 300 TEST(GIFImageDecoderTest, badTerminator) |
| 301 { |
| 302 RefPtr<SharedBuffer> referenceData = readFile("/Source/WebKit/chromium/tests
/data/radient.gif"); |
| 303 RefPtr<SharedBuffer> testData = readFile("/Source/WebKit/chromium/tests/data
/radient-bad-terminator.gif"); |
| 304 ASSERT_TRUE(referenceData.get()); |
| 305 ASSERT_TRUE(testData.get()); |
| 306 |
| 307 OwnPtr<GIFImageDecoder> referenceDecoder(createDecoder()); |
| 308 referenceDecoder->setData(referenceData.get(), true); |
| 309 EXPECT_EQ(1u, referenceDecoder->frameCount()); |
| 310 ImageFrame* referenceFrame = referenceDecoder->frameBufferAtIndex(0); |
| 311 ASSERT(referenceFrame); |
| 312 |
| 313 OwnPtr<GIFImageDecoder> testDecoder(createDecoder()); |
| 314 testDecoder->setData(testData.get(), true); |
| 315 EXPECT_EQ(1u, testDecoder->frameCount()); |
| 316 ImageFrame* testFrame = testDecoder->frameBufferAtIndex(0); |
| 317 ASSERT(testFrame); |
| 318 |
| 319 EXPECT_EQ(hashSkBitmap(referenceFrame->getSkBitmap()), hashSkBitmap(testFram
e->getSkBitmap())); |
| 320 } |
| 321 |
300 #endif | 322 #endif |
301 | 323 |
302 } // namespace | 324 } // namespace |
OLD | NEW |