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

Side by Side Diff: Source/web/tests/GIFImageDecoderTest.cpp

Issue 99103006: Moving GraphicsContext and dependencies from core to platform. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final patch - fixes Android Created 7 years 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
« no previous file with comments | « Source/web/tests/FilterOperationsTest.cpp ('k') | Source/web/tests/GraphicsContextTest.cpp » ('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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 32
33 #include "core/platform/image-decoders/gif/GIFImageDecoder.h" 33 #include "platform/image-decoders/gif/GIFImageDecoder.h"
34 34
35 #include "platform/SharedBuffer.h" 35 #include "platform/SharedBuffer.h"
36 #include "public/platform/Platform.h" 36 #include "public/platform/Platform.h"
37 #include "public/platform/WebData.h" 37 #include "public/platform/WebData.h"
38 #include "public/platform/WebSize.h" 38 #include "public/platform/WebSize.h"
39 #include "public/platform/WebUnitTestSupport.h" 39 #include "public/platform/WebUnitTestSupport.h"
40 #include "wtf/OwnPtr.h" 40 #include "wtf/OwnPtr.h"
41 #include "wtf/PassOwnPtr.h" 41 #include "wtf/PassOwnPtr.h"
42 #include "wtf/StringHasher.h" 42 #include "wtf/StringHasher.h"
43 #include "wtf/Vector.h" 43 #include "wtf/Vector.h"
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 // Resume decoding of the first frame. 452 // Resume decoding of the first frame.
453 ImageFrame* firstFrame = decoder->frameBufferAtIndex(0); 453 ImageFrame* firstFrame = decoder->frameBufferAtIndex(0);
454 EXPECT_EQ(ImageFrame::FrameComplete, firstFrame->status()); 454 EXPECT_EQ(ImageFrame::FrameComplete, firstFrame->status());
455 EXPECT_EQ(baselineHashes[0], hashSkBitmap(firstFrame->getSkBitmap())); 455 EXPECT_EQ(baselineHashes[0], hashSkBitmap(firstFrame->getSkBitmap()));
456 } 456 }
457 457
458 // The first LZW codes in the image are invalid values that try to create a loop 458 // The first LZW codes in the image are invalid values that try to create a loop
459 // in the dictionary. Decoding should fail, but not infinitely loop or corrupt m emory. 459 // in the dictionary. Decoding should fail, but not infinitely loop or corrupt m emory.
460 TEST(GIFImageDecoderTest, badInitialCode) 460 TEST(GIFImageDecoderTest, badInitialCode)
461 { 461 {
462 RefPtr<SharedBuffer> testData = readFile("/Source/core/platform/image-decode rs/testing/bad-initial-code.gif"); 462 RefPtr<SharedBuffer> testData = readFile("/Source/platform/image-decoders/te sting/bad-initial-code.gif");
463 ASSERT_TRUE(testData.get()); 463 ASSERT_TRUE(testData.get());
464 464
465 OwnPtr<GIFImageDecoder> testDecoder(createDecoder()); 465 OwnPtr<GIFImageDecoder> testDecoder(createDecoder());
466 testDecoder->setData(testData.get(), true); 466 testDecoder->setData(testData.get(), true);
467 EXPECT_EQ(1u, testDecoder->frameCount()); 467 EXPECT_EQ(1u, testDecoder->frameCount());
468 ASSERT_TRUE(testDecoder->frameBufferAtIndex(0)); 468 ASSERT_TRUE(testDecoder->frameBufferAtIndex(0));
469 EXPECT_TRUE(testDecoder->failed()); 469 EXPECT_TRUE(testDecoder->failed());
470 } 470 }
471 471
472 // The image has an invalid LZW code that exceeds dictionary size. Decoding shou ld fail. 472 // The image has an invalid LZW code that exceeds dictionary size. Decoding shou ld fail.
473 TEST(GIFImageDecoderTest, badCode) 473 TEST(GIFImageDecoderTest, badCode)
474 { 474 {
475 RefPtr<SharedBuffer> testData = readFile("/Source/core/platform/image-decode rs/testing/bad-code.gif"); 475 RefPtr<SharedBuffer> testData = readFile("/Source/platform/image-decoders/te sting/bad-code.gif");
476 ASSERT_TRUE(testData.get()); 476 ASSERT_TRUE(testData.get());
477 477
478 OwnPtr<GIFImageDecoder> testDecoder(createDecoder()); 478 OwnPtr<GIFImageDecoder> testDecoder(createDecoder());
479 testDecoder->setData(testData.get(), true); 479 testDecoder->setData(testData.get(), true);
480 EXPECT_EQ(1u, testDecoder->frameCount()); 480 EXPECT_EQ(1u, testDecoder->frameCount());
481 ASSERT_TRUE(testDecoder->frameBufferAtIndex(0)); 481 ASSERT_TRUE(testDecoder->frameBufferAtIndex(0));
482 EXPECT_TRUE(testDecoder->failed()); 482 EXPECT_TRUE(testDecoder->failed());
483 } 483 }
484 484
485 TEST(GIFImageDecoderTest, invalidDisposalMethod) 485 TEST(GIFImageDecoderTest, invalidDisposalMethod)
486 { 486 {
487 OwnPtr<GIFImageDecoder> decoder = createDecoder(); 487 OwnPtr<GIFImageDecoder> decoder = createDecoder();
488 488
489 // The image has 2 frames, with disposal method 4 and 5, respectively. 489 // The image has 2 frames, with disposal method 4 and 5, respectively.
490 RefPtr<SharedBuffer> data = readFile("/Source/web/tests/data/invalid-disposa l-method.gif"); 490 RefPtr<SharedBuffer> data = readFile("/Source/web/tests/data/invalid-disposa l-method.gif");
491 ASSERT_TRUE(data.get()); 491 ASSERT_TRUE(data.get());
492 decoder->setData(data.get(), true); 492 decoder->setData(data.get(), true);
493 493
494 EXPECT_EQ(2u, decoder->frameCount()); 494 EXPECT_EQ(2u, decoder->frameCount());
495 // Disposal method 4 is converted to ImageFrame::DisposeOverwritePrevious. 495 // Disposal method 4 is converted to ImageFrame::DisposeOverwritePrevious.
496 EXPECT_EQ(ImageFrame::DisposeOverwritePrevious, decoder->frameBufferAtIndex( 0)->disposalMethod()); 496 EXPECT_EQ(ImageFrame::DisposeOverwritePrevious, decoder->frameBufferAtIndex( 0)->disposalMethod());
497 // Disposal method 5 is ignored. 497 // Disposal method 5 is ignored.
498 EXPECT_EQ(ImageFrame::DisposeNotSpecified, decoder->frameBufferAtIndex(1)->d isposalMethod()); 498 EXPECT_EQ(ImageFrame::DisposeNotSpecified, decoder->frameBufferAtIndex(1)->d isposalMethod());
499 } 499 }
OLDNEW
« no previous file with comments | « Source/web/tests/FilterOperationsTest.cpp ('k') | Source/web/tests/GraphicsContextTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698