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 #include "ios/chrome/browser/webp_transcode/webp_decoder.h" | 5 #include "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> |
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" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 class WebpDecoderTest : public testing::Test { | 49 class WebpDecoderTest : public testing::Test { |
50 public: | 50 public: |
51 WebpDecoderTest() | 51 WebpDecoderTest() |
52 : delegate_(new WebpDecoderDelegate), | 52 : delegate_(new WebpDecoderDelegate), |
53 decoder_(new WebpDecoder(delegate_.get())) {} | 53 decoder_(new WebpDecoder(delegate_.get())) {} |
54 | 54 |
55 NSData* LoadImage(const base::FilePath& filename) { | 55 NSData* LoadImage(const base::FilePath& filename) { |
56 base::FilePath path; | 56 base::FilePath path; |
57 PathService::Get(base::DIR_SOURCE_ROOT, &path); | 57 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
58 path = path.AppendASCII("ios/chrome/test/data/webp_transcode") | 58 path = path.AppendASCII("components/test/data/webp_transcode") |
59 .Append(filename); | 59 .Append(filename); |
60 return | 60 return |
61 [NSData dataWithContentsOfFile:base::SysUTF8ToNSString(path.value())]; | 61 [NSData dataWithContentsOfFile:base::SysUTF8ToNSString(path.value())]; |
62 } | 62 } |
63 | 63 |
64 std::vector<uint8_t>* DecompressData(NSData* data, | 64 std::vector<uint8_t>* DecompressData(NSData* data, |
65 WebpDecoder::DecodedImageFormat format) { | 65 WebpDecoder::DecodedImageFormat format) { |
66 base::ScopedCFTypeRef<CGDataProviderRef> provider( | 66 base::ScopedCFTypeRef<CGDataProviderRef> provider( |
67 CGDataProviderCreateWithCFData((CFDataRef)data)); | 67 CGDataProviderCreateWithCFData((CFDataRef)data)); |
68 base::ScopedCFTypeRef<CGImageRef> image; | 68 base::ScopedCFTypeRef<CGImageRef> image; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 EXPECT_EQ(0u, [delegate_->GetImage() length]); | 283 EXPECT_EQ(0u, [delegate_->GetImage() length]); |
284 } | 284 } |
285 | 285 |
286 TEST_F(WebpDecoderTest, DecodeAborted) { | 286 TEST_F(WebpDecoderTest, DecodeAborted) { |
287 EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1); | 287 EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1); |
288 decoder_->Stop(); | 288 decoder_->Stop(); |
289 EXPECT_EQ(0u, [delegate_->GetImage() length]); | 289 EXPECT_EQ(0u, [delegate_->GetImage() length]); |
290 } | 290 } |
291 | 291 |
292 } // namespace webp_transcode | 292 } // namespace webp_transcode |
OLD | NEW |