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 14 matching lines...) Expand all Loading... |
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 "core/platform/image-decoders/gif/GIFImageDecoder.h" |
34 | 34 |
35 #include "core/platform/FileSystem.h" | |
36 #include "core/platform/SharedBuffer.h" | 35 #include "core/platform/SharedBuffer.h" |
37 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
38 #include "public/platform/WebData.h" | 37 #include "public/platform/WebData.h" |
39 #include "public/platform/WebSize.h" | 38 #include "public/platform/WebSize.h" |
40 #include "public/platform/WebUnitTestSupport.h" | 39 #include "public/platform/WebUnitTestSupport.h" |
41 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
42 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
43 #include "wtf/StringHasher.h" | 42 #include "wtf/StringHasher.h" |
44 #include "wtf/Vector.h" | 43 #include "wtf/Vector.h" |
45 #include <gtest/gtest.h> | 44 #include <gtest/gtest.h> |
46 | 45 |
47 using namespace WebCore; | 46 using namespace WebCore; |
48 using namespace WebKit; | 47 using namespace WebKit; |
49 | 48 |
50 #if !OS(ANDROID) | 49 #if !OS(ANDROID) |
51 | 50 |
52 namespace { | 51 namespace { |
53 | 52 |
54 PassRefPtr<SharedBuffer> readFile(const char* fileName) | 53 PassRefPtr<SharedBuffer> readFile(const char* fileName) |
55 { | 54 { |
56 String filePath = Platform::current()->unitTestSupport()->webKitRootDir(); | 55 String filePath = Platform::current()->unitTestSupport()->webKitRootDir(); |
57 filePath.append(fileName); | 56 filePath.append(fileName); |
58 | 57 |
59 long long fileSize; | 58 return Platform::current()->unitTestSupport()->readFromFile(filePath); |
60 if (!getFileSize(filePath, fileSize)) | |
61 return 0; | |
62 | |
63 PlatformFileHandle handle = openFile(filePath, OpenForRead); | |
64 int fileLength = static_cast<int>(fileSize); | |
65 Vector<char> buffer(fileLength); | |
66 readFromFile(handle, buffer.data(), fileLength); | |
67 closeFile(handle); | |
68 return SharedBuffer::adoptVector(buffer); | |
69 } | 59 } |
70 | 60 |
71 PassOwnPtr<GIFImageDecoder> createDecoder() | 61 PassOwnPtr<GIFImageDecoder> createDecoder() |
72 { | 62 { |
73 return adoptPtr(new GIFImageDecoder(ImageSource::AlphaNotPremultiplied, Imag
eSource::GammaAndColorProfileApplied)); | 63 return adoptPtr(new GIFImageDecoder(ImageSource::AlphaNotPremultiplied, Imag
eSource::GammaAndColorProfileApplied)); |
74 } | 64 } |
75 | 65 |
76 unsigned hashSkBitmap(const SkBitmap& bitmap) | 66 unsigned hashSkBitmap(const SkBitmap& bitmap) |
77 { | 67 { |
78 return StringHasher::hashMemory(bitmap.getPixels(), bitmap.getSize()); | 68 return StringHasher::hashMemory(bitmap.getPixels(), bitmap.getSize()); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 EXPECT_EQ(baselineHashes[frameCount - 1], hashSkBitmap(lastFrame->getSkBitma
p())); | 448 EXPECT_EQ(baselineHashes[frameCount - 1], hashSkBitmap(lastFrame->getSkBitma
p())); |
459 decoder->clearCacheExceptFrame(notFound); | 449 decoder->clearCacheExceptFrame(notFound); |
460 | 450 |
461 // Resume decoding of the first frame. | 451 // Resume decoding of the first frame. |
462 ImageFrame* firstFrame = decoder->frameBufferAtIndex(0); | 452 ImageFrame* firstFrame = decoder->frameBufferAtIndex(0); |
463 EXPECT_EQ(ImageFrame::FrameComplete, firstFrame->status()); | 453 EXPECT_EQ(ImageFrame::FrameComplete, firstFrame->status()); |
464 EXPECT_EQ(baselineHashes[0], hashSkBitmap(firstFrame->getSkBitmap())); | 454 EXPECT_EQ(baselineHashes[0], hashSkBitmap(firstFrame->getSkBitmap())); |
465 } | 455 } |
466 | 456 |
467 #endif | 457 #endif |
OLD | NEW |