OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #import "ios/web/public/image_fetcher/webp_decoder.h" | 5 #import "components/image_fetcher/ios/webp_decoder.h" |
6 | 6 |
7 #import <CoreGraphics/CoreGraphics.h> | 7 #import <CoreGraphics/CoreGraphics.h> |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 |
9 #include <stddef.h> | 10 #include <stddef.h> |
10 #include <stdint.h> | 11 #include <stdint.h> |
11 | 12 |
12 #include <memory> | 13 #include <memory> |
13 | 14 |
14 #include "base/base_paths.h" | 15 #include "base/base_paths.h" |
15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
16 #include "base/ios/ios_util.h" | 17 #include "base/ios/ios_util.h" |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/mac/scoped_cftyperef.h" | 19 #include "base/mac/scoped_cftyperef.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 53 |
53 class WebpDecoderTest : public testing::Test { | 54 class WebpDecoderTest : public testing::Test { |
54 public: | 55 public: |
55 WebpDecoderTest() | 56 WebpDecoderTest() |
56 : delegate_(new WebpDecoderDelegate), | 57 : delegate_(new WebpDecoderDelegate), |
57 decoder_(new WebpDecoder(delegate_.get())) {} | 58 decoder_(new WebpDecoder(delegate_.get())) {} |
58 | 59 |
59 NSData* LoadImage(const base::FilePath& filename) { | 60 NSData* LoadImage(const base::FilePath& filename) { |
60 base::FilePath path; | 61 base::FilePath path; |
61 PathService::Get(base::DIR_SOURCE_ROOT, &path); | 62 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
62 path = | 63 path = path.AppendASCII("components/test/data/webp_transcode") |
63 path.AppendASCII("ios/web/test/data/webp_transcode").Append(filename); | 64 .Append(filename); |
64 return | 65 return |
65 [NSData dataWithContentsOfFile:base::SysUTF8ToNSString(path.value())]; | 66 [NSData dataWithContentsOfFile:base::SysUTF8ToNSString(path.value())]; |
66 } | 67 } |
67 | 68 |
68 std::vector<uint8_t>* DecompressData(NSData* data, | 69 std::vector<uint8_t>* DecompressData(NSData* data, |
69 WebpDecoder::DecodedImageFormat format) { | 70 WebpDecoder::DecodedImageFormat format) { |
70 base::ScopedCFTypeRef<CGDataProviderRef> provider( | 71 base::ScopedCFTypeRef<CGDataProviderRef> provider( |
71 CGDataProviderCreateWithCFData((CFDataRef)data)); | 72 CGDataProviderCreateWithCFData((CFDataRef)data)); |
72 base::ScopedCFTypeRef<CGImageRef> image; | 73 base::ScopedCFTypeRef<CGImageRef> image; |
73 switch (format) { | 74 switch (format) { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 EXPECT_EQ(0u, [delegate_->GetImage() length]); | 268 EXPECT_EQ(0u, [delegate_->GetImage() length]); |
268 } | 269 } |
269 | 270 |
270 TEST_F(WebpDecoderTest, DecodeAborted) { | 271 TEST_F(WebpDecoderTest, DecodeAborted) { |
271 EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1); | 272 EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1); |
272 decoder_->Stop(); | 273 decoder_->Stop(); |
273 EXPECT_EQ(0u, [delegate_->GetImage() length]); | 274 EXPECT_EQ(0u, [delegate_->GetImage() length]); |
274 } | 275 } |
275 | 276 |
276 } // namespace webp_transcode | 277 } // namespace webp_transcode |
OLD | NEW |