| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/image-decoders/ImageDecoderTestHelpers.h" | 5 #include "platform/image-decoders/ImageDecoderTestHelpers.h" |
| 6 | 6 |
| 7 #include "platform/SharedBuffer.h" | 7 #include "platform/SharedBuffer.h" |
| 8 #include "platform/image-decoders/ImageDecoder.h" | 8 #include "platform/image-decoders/ImageDecoder.h" |
| 9 #include "platform/image-decoders/ImageFrame.h" | 9 #include "platform/image-decoders/ImageFrame.h" |
| 10 #include "platform/testing/UnitTestHelpers.h" | 10 #include "platform/testing/UnitTestHelpers.h" |
| 11 #include "public/platform/Platform.h" | |
| 12 #include "public/platform/WebUnitTestSupport.h" | |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "wtf/OwnPtr.h" | 12 #include "wtf/OwnPtr.h" |
| 15 #include "wtf/StringHasher.h" | 13 #include "wtf/StringHasher.h" |
| 16 | 14 |
| 17 namespace blink { | 15 namespace blink { |
| 18 | 16 |
| 19 PassRefPtr<SharedBuffer> readFile(const char* fileName) | 17 PassRefPtr<SharedBuffer> readFile(const char* fileName) |
| 20 { | 18 { |
| 21 String filePath = testing::blinkRootDir(); | 19 String filePath = testing::blinkRootDir(); |
| 22 filePath.append(fileName); | 20 filePath.append(fileName); |
| 23 return Platform::current()->unitTestSupport()->readFromFile(filePath); | 21 return testing::readFromFile(filePath); |
| 24 } | 22 } |
| 25 | 23 |
| 26 PassRefPtr<SharedBuffer> readFile(const char* dir, const char* fileName) | 24 PassRefPtr<SharedBuffer> readFile(const char* dir, const char* fileName) |
| 27 { | 25 { |
| 28 String filePath = testing::blinkRootDir(); | 26 String filePath = testing::blinkRootDir(); |
| 29 filePath.append("/"); | 27 filePath.append("/"); |
| 30 filePath.append(dir); | 28 filePath.append(dir); |
| 31 filePath.append("/"); | 29 filePath.append("/"); |
| 32 filePath.append(fileName); | 30 filePath.append(fileName); |
| 33 | 31 |
| 34 return Platform::current()->unitTestSupport()->readFromFile(filePath); | 32 return testing::readFromFile(filePath); |
| 35 } | 33 } |
| 36 | 34 |
| 37 unsigned hashBitmap(const SkBitmap& bitmap) | 35 unsigned hashBitmap(const SkBitmap& bitmap) |
| 38 { | 36 { |
| 39 return StringHasher::hashMemory(bitmap.getPixels(), bitmap.getSize()); | 37 return StringHasher::hashMemory(bitmap.getPixels(), bitmap.getSize()); |
| 40 } | 38 } |
| 41 | 39 |
| 42 static unsigned createDecodingBaseline(DecoderCreator createDecoder, SharedBuffe
r* data) | 40 static unsigned createDecodingBaseline(DecoderCreator createDecoder, SharedBuffe
r* data) |
| 43 { | 41 { |
| 44 OwnPtr<ImageDecoder> decoder = createDecoder(); | 42 OwnPtr<ImageDecoder> decoder = createDecoder(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // data in a segment, its pointer would no longer be valid. | 132 // data in a segment, its pointer would no longer be valid. |
| 135 segmentedData->data(); | 133 segmentedData->data(); |
| 136 | 134 |
| 137 ImageFrame* frame = decoder->frameBufferAtIndex(0); | 135 ImageFrame* frame = decoder->frameBufferAtIndex(0); |
| 138 ASSERT_FALSE(decoder->failed()); | 136 ASSERT_FALSE(decoder->failed()); |
| 139 EXPECT_EQ(frame->status(), ImageFrame::FrameComplete); | 137 EXPECT_EQ(frame->status(), ImageFrame::FrameComplete); |
| 140 EXPECT_EQ(hashBitmap(frame->bitmap()), hash); | 138 EXPECT_EQ(hashBitmap(frame->bitmap()), hash); |
| 141 } | 139 } |
| 142 | 140 |
| 143 } // namespace blink | 141 } // namespace blink |
| OLD | NEW |