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

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

Issue 19906002: Move data/ directory from WebKit/chromium/tests into web/tests/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 7 years, 5 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 | Annotate | Revision Log
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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 245
246 EXPECT_EQ(5u, decoder->frameCount()); 246 EXPECT_EQ(5u, decoder->frameCount());
247 EXPECT_EQ(5u, framesDecoded); 247 EXPECT_EQ(5u, framesDecoded);
248 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount()); 248 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount());
249 } 249 }
250 250
251 TEST(GIFImageDecoderTest, brokenSecondFrame) 251 TEST(GIFImageDecoderTest, brokenSecondFrame)
252 { 252 {
253 OwnPtr<GIFImageDecoder> decoder = createDecoder(); 253 OwnPtr<GIFImageDecoder> decoder = createDecoder();
254 254
255 RefPtr<SharedBuffer> data = readFile("/Source/WebKit/chromium/tests/data/bro ken.gif"); 255 RefPtr<SharedBuffer> data = readFile("/Source/web/tests/data/broken.gif");
256 ASSERT_TRUE(data.get()); 256 ASSERT_TRUE(data.get());
257 decoder->setData(data.get(), true); 257 decoder->setData(data.get(), true);
258 258
259 // One frame is detected but cannot be decoded. 259 // One frame is detected but cannot be decoded.
260 EXPECT_EQ(1u, decoder->frameCount()); 260 EXPECT_EQ(1u, decoder->frameCount());
261 ImageFrame* frame = decoder->frameBufferAtIndex(1); 261 ImageFrame* frame = decoder->frameBufferAtIndex(1);
262 EXPECT_FALSE(frame); 262 EXPECT_FALSE(frame);
263 } 263 }
264 264
265 TEST(GIFImageDecoderTest, progressiveDecode) 265 TEST(GIFImageDecoderTest, progressiveDecode)
266 { 266 {
267 RefPtr<SharedBuffer> fullData = readFile("/Source/WebKit/chromium/tests/data /radient.gif"); 267 RefPtr<SharedBuffer> fullData = readFile("/Source/web/tests/data/radient.gif ");
268 ASSERT_TRUE(fullData.get()); 268 ASSERT_TRUE(fullData.get());
269 const size_t fullLength = fullData->size(); 269 const size_t fullLength = fullData->size();
270 270
271 OwnPtr<GIFImageDecoder> decoder; 271 OwnPtr<GIFImageDecoder> decoder;
272 ImageFrame* frame; 272 ImageFrame* frame;
273 273
274 Vector<unsigned> truncatedHashes; 274 Vector<unsigned> truncatedHashes;
275 Vector<unsigned> progressiveHashes; 275 Vector<unsigned> progressiveHashes;
276 276
277 // Compute hashes when the file is truncated. 277 // Compute hashes when the file is truncated.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 EXPECT_FALSE(decoder->frameIsCompleteAtIndex(1)); 362 EXPECT_FALSE(decoder->frameIsCompleteAtIndex(1));
363 363
364 decoder->setData(data.get(), true); 364 decoder->setData(data.get(), true);
365 EXPECT_EQ(2u, decoder->frameCount()); 365 EXPECT_EQ(2u, decoder->frameCount());
366 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0)); 366 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0));
367 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(1)); 367 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(1));
368 } 368 }
369 369
370 TEST(GIFImageDecoderTest, badTerminator) 370 TEST(GIFImageDecoderTest, badTerminator)
371 { 371 {
372 RefPtr<SharedBuffer> referenceData = readFile("/Source/WebKit/chromium/tests /data/radient.gif"); 372 RefPtr<SharedBuffer> referenceData = readFile("/Source/web/tests/data/radien t.gif");
373 RefPtr<SharedBuffer> testData = readFile("/Source/WebKit/chromium/tests/data /radient-bad-terminator.gif"); 373 RefPtr<SharedBuffer> testData = readFile("/Source/web/tests/data/radient-bad -terminator.gif");
374 ASSERT_TRUE(referenceData.get()); 374 ASSERT_TRUE(referenceData.get());
375 ASSERT_TRUE(testData.get()); 375 ASSERT_TRUE(testData.get());
376 376
377 OwnPtr<GIFImageDecoder> referenceDecoder(createDecoder()); 377 OwnPtr<GIFImageDecoder> referenceDecoder(createDecoder());
378 referenceDecoder->setData(referenceData.get(), true); 378 referenceDecoder->setData(referenceData.get(), true);
379 EXPECT_EQ(1u, referenceDecoder->frameCount()); 379 EXPECT_EQ(1u, referenceDecoder->frameCount());
380 ImageFrame* referenceFrame = referenceDecoder->frameBufferAtIndex(0); 380 ImageFrame* referenceFrame = referenceDecoder->frameBufferAtIndex(0);
381 ASSERT(referenceFrame); 381 ASSERT(referenceFrame);
382 382
383 OwnPtr<GIFImageDecoder> testDecoder(createDecoder()); 383 OwnPtr<GIFImageDecoder> testDecoder(createDecoder());
(...skipping 27 matching lines...) Expand all
411 EXPECT_EQ(i - 1, decoder->frameBufferAtIndex(i)->requiredPreviousFrameIn dex()); 411 EXPECT_EQ(i - 1, decoder->frameBufferAtIndex(i)->requiredPreviousFrameIn dex());
412 412
413 decoder->setData(fullData.get(), true); 413 decoder->setData(fullData.get(), true);
414 for (size_t i = 0; i < frameCount; ++i) 414 for (size_t i = 0; i < frameCount; ++i)
415 EXPECT_EQ(notFound, decoder->frameBufferAtIndex(i)->requiredPreviousFram eIndex()); 415 EXPECT_EQ(notFound, decoder->frameBufferAtIndex(i)->requiredPreviousFram eIndex());
416 } 416 }
417 417
418 TEST(GIFImageDecoderTest, randomFrameDecode) 418 TEST(GIFImageDecoderTest, randomFrameDecode)
419 { 419 {
420 // Single frame image. 420 // Single frame image.
421 testRandomFrameDecode("/Source/WebKit/chromium/tests/data/radient.gif"); 421 testRandomFrameDecode("/Source/web/tests/data/radient.gif");
422 // Multiple frame images. 422 // Multiple frame images.
423 testRandomFrameDecode("/LayoutTests/fast/images/resources/animated-gif-with- offsets.gif"); 423 testRandomFrameDecode("/LayoutTests/fast/images/resources/animated-gif-with- offsets.gif");
424 testRandomFrameDecode("/LayoutTests/fast/images/resources/animated-10color.g if"); 424 testRandomFrameDecode("/LayoutTests/fast/images/resources/animated-10color.g if");
425 } 425 }
426 426
427 TEST(GIFImageDecoderTest, randomDecodeAfterClearFrameBufferCache) 427 TEST(GIFImageDecoderTest, randomDecodeAfterClearFrameBufferCache)
428 { 428 {
429 // Single frame image. 429 // Single frame image.
430 testRandomDecodeAfterClearFrameBufferCache("/Source/WebKit/chromium/tests/da ta/radient.gif"); 430 testRandomDecodeAfterClearFrameBufferCache("/Source/web/tests/data/radient.g if");
431 // Multiple frame images. 431 // Multiple frame images.
432 testRandomDecodeAfterClearFrameBufferCache("/LayoutTests/fast/images/resourc es/animated-gif-with-offsets.gif"); 432 testRandomDecodeAfterClearFrameBufferCache("/LayoutTests/fast/images/resourc es/animated-gif-with-offsets.gif");
433 testRandomDecodeAfterClearFrameBufferCache("/LayoutTests/fast/images/resourc es/animated-10color.gif"); 433 testRandomDecodeAfterClearFrameBufferCache("/LayoutTests/fast/images/resourc es/animated-10color.gif");
434 } 434 }
435 435
436 TEST(GIFImageDecoderTest, resumePartialDecodeAfterClearFrameBufferCache) 436 TEST(GIFImageDecoderTest, resumePartialDecodeAfterClearFrameBufferCache)
437 { 437 {
438 RefPtr<SharedBuffer> fullData = readFile("/LayoutTests/fast/images/resources /animated-10color.gif"); 438 RefPtr<SharedBuffer> fullData = readFile("/LayoutTests/fast/images/resources /animated-10color.gif");
439 ASSERT_TRUE(fullData.get()); 439 ASSERT_TRUE(fullData.get());
440 Vector<unsigned> baselineHashes; 440 Vector<unsigned> baselineHashes;
(...skipping 17 matching lines...) Expand all
458 EXPECT_EQ(baselineHashes[frameCount - 1], hashSkBitmap(lastFrame->getSkBitma p())); 458 EXPECT_EQ(baselineHashes[frameCount - 1], hashSkBitmap(lastFrame->getSkBitma p()));
459 decoder->clearCacheExceptFrame(notFound); 459 decoder->clearCacheExceptFrame(notFound);
460 460
461 // Resume decoding of the first frame. 461 // Resume decoding of the first frame.
462 ImageFrame* firstFrame = decoder->frameBufferAtIndex(0); 462 ImageFrame* firstFrame = decoder->frameBufferAtIndex(0);
463 EXPECT_EQ(ImageFrame::FrameComplete, firstFrame->status()); 463 EXPECT_EQ(ImageFrame::FrameComplete, firstFrame->status());
464 EXPECT_EQ(baselineHashes[0], hashSkBitmap(firstFrame->getSkBitmap())); 464 EXPECT_EQ(baselineHashes[0], hashSkBitmap(firstFrame->getSkBitmap()));
465 } 465 }
466 466
467 #endif 467 #endif
OLDNEW
« no previous file with comments | « Source/core/loader/cache/CachedImageTest.cpp ('k') | Source/web/tests/AssociatedURLLoaderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698