| 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 "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "wtf/StringHasher.h" | 12 #include "wtf/StringHasher.h" |
| 13 #include "wtf/text/StringBuilder.h" |
| 13 #include <memory> | 14 #include <memory> |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| 17 PassRefPtr<SharedBuffer> readFile(const char* fileName) | 18 PassRefPtr<SharedBuffer> readFile(const char* fileName) |
| 18 { | 19 { |
| 19 String filePath = testing::blinkRootDir(); | 20 String filePath = testing::blinkRootDir(); |
| 20 filePath.append(fileName); | 21 filePath.append(fileName); |
| 21 return testing::readFromFile(filePath); | 22 return testing::readFromFile(filePath); |
| 22 } | 23 } |
| 23 | 24 |
| 24 PassRefPtr<SharedBuffer> readFile(const char* dir, const char* fileName) | 25 PassRefPtr<SharedBuffer> readFile(const char* dir, const char* fileName) |
| 25 { | 26 { |
| 26 String filePath = testing::blinkRootDir(); | 27 StringBuilder filePath; |
| 27 filePath.append("/"); | 28 filePath.append(testing::blinkRootDir()); |
| 29 filePath.append('/'); |
| 28 filePath.append(dir); | 30 filePath.append(dir); |
| 29 filePath.append("/"); | 31 filePath.append('/'); |
| 30 filePath.append(fileName); | 32 filePath.append(fileName); |
| 31 | 33 return testing::readFromFile(filePath.toString()); |
| 32 return testing::readFromFile(filePath); | |
| 33 } | 34 } |
| 34 | 35 |
| 35 unsigned hashBitmap(const SkBitmap& bitmap) | 36 unsigned hashBitmap(const SkBitmap& bitmap) |
| 36 { | 37 { |
| 37 return StringHasher::hashMemory(bitmap.getPixels(), bitmap.getSize()); | 38 return StringHasher::hashMemory(bitmap.getPixels(), bitmap.getSize()); |
| 38 } | 39 } |
| 39 | 40 |
| 40 static unsigned createDecodingBaseline(DecoderCreator createDecoder, SharedBuffe
r* data) | 41 static unsigned createDecodingBaseline(DecoderCreator createDecoder, SharedBuffe
r* data) |
| 41 { | 42 { |
| 42 std::unique_ptr<ImageDecoder> decoder = createDecoder(); | 43 std::unique_ptr<ImageDecoder> decoder = createDecoder(); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // data in a segment, its pointer would no longer be valid. | 140 // data in a segment, its pointer would no longer be valid. |
| 140 segmentedData->data(); | 141 segmentedData->data(); |
| 141 | 142 |
| 142 ImageFrame* frame = decoder->frameBufferAtIndex(0); | 143 ImageFrame* frame = decoder->frameBufferAtIndex(0); |
| 143 ASSERT_FALSE(decoder->failed()); | 144 ASSERT_FALSE(decoder->failed()); |
| 144 EXPECT_EQ(frame->getStatus(), ImageFrame::FrameComplete); | 145 EXPECT_EQ(frame->getStatus(), ImageFrame::FrameComplete); |
| 145 EXPECT_EQ(hashBitmap(frame->bitmap()), hash); | 146 EXPECT_EQ(hashBitmap(frame->bitmap()), hash); |
| 146 } | 147 } |
| 147 | 148 |
| 148 } // namespace blink | 149 } // namespace blink |
| OLD | NEW |