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 #include <stddef.h> | 9 #include <stddef.h> |
sdefresne
2017/02/20 09:56:23
nit: blank line to separate system Objective-C hea
gambard
2017/02/20 10:08:50
Done.
| |
10 #include <stdint.h> | 10 #include <stdint.h> |
11 | 11 |
12 #include <memory> | 12 #include <memory> |
13 | 13 |
14 #include "base/base_paths.h" | 14 #include "base/base_paths.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/ios/ios_util.h" | 16 #include "base/ios/ios_util.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/mac/scoped_cftyperef.h" | 18 #include "base/mac/scoped_cftyperef.h" |
19 #import "base/mac/scoped_nsobject.h" | 19 #import "base/mac/scoped_nsobject.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 | 52 |
53 class WebpDecoderTest : public testing::Test { | 53 class WebpDecoderTest : public testing::Test { |
54 public: | 54 public: |
55 WebpDecoderTest() | 55 WebpDecoderTest() |
56 : delegate_(new WebpDecoderDelegate), | 56 : delegate_(new WebpDecoderDelegate), |
57 decoder_(new WebpDecoder(delegate_.get())) {} | 57 decoder_(new WebpDecoder(delegate_.get())) {} |
58 | 58 |
59 NSData* LoadImage(const base::FilePath& filename) { | 59 NSData* LoadImage(const base::FilePath& filename) { |
60 base::FilePath path; | 60 base::FilePath path; |
61 PathService::Get(base::DIR_SOURCE_ROOT, &path); | 61 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
62 path = | 62 path = path.AppendASCII("components/test/data/webp_transcode") |
63 path.AppendASCII("ios/web/test/data/webp_transcode").Append(filename); | 63 .Append(filename); |
64 return | 64 return |
65 [NSData dataWithContentsOfFile:base::SysUTF8ToNSString(path.value())]; | 65 [NSData dataWithContentsOfFile:base::SysUTF8ToNSString(path.value())]; |
66 } | 66 } |
67 | 67 |
68 std::vector<uint8_t>* DecompressData(NSData* data, | 68 std::vector<uint8_t>* DecompressData(NSData* data, |
69 WebpDecoder::DecodedImageFormat format) { | 69 WebpDecoder::DecodedImageFormat format) { |
70 base::ScopedCFTypeRef<CGDataProviderRef> provider( | 70 base::ScopedCFTypeRef<CGDataProviderRef> provider( |
71 CGDataProviderCreateWithCFData((CFDataRef)data)); | 71 CGDataProviderCreateWithCFData((CFDataRef)data)); |
72 base::ScopedCFTypeRef<CGImageRef> image; | 72 base::ScopedCFTypeRef<CGImageRef> image; |
73 switch (format) { | 73 switch (format) { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 EXPECT_EQ(0u, [delegate_->GetImage() length]); | 267 EXPECT_EQ(0u, [delegate_->GetImage() length]); |
268 } | 268 } |
269 | 269 |
270 TEST_F(WebpDecoderTest, DecodeAborted) { | 270 TEST_F(WebpDecoderTest, DecodeAborted) { |
271 EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1); | 271 EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1); |
272 decoder_->Stop(); | 272 decoder_->Stop(); |
273 EXPECT_EQ(0u, [delegate_->GetImage() length]); | 273 EXPECT_EQ(0u, [delegate_->GetImage() length]); |
274 } | 274 } |
275 | 275 |
276 } // namespace webp_transcode | 276 } // namespace webp_transcode |
OLD | NEW |