| 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 "ios/web/public/image_fetcher/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 36 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 = path.AppendASCII("ios/chrome/test/data/webp_transcode") | 62 path = |
| 63 .Append(filename); | 63 path.AppendASCII("ios/web/test/data/webp_transcode").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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 EXPECT_EQ(0u, [delegate_->GetImage() length]); | 287 EXPECT_EQ(0u, [delegate_->GetImage() length]); |
| 288 } | 288 } |
| 289 | 289 |
| 290 TEST_F(WebpDecoderTest, DecodeAborted) { | 290 TEST_F(WebpDecoderTest, DecodeAborted) { |
| 291 EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1); | 291 EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1); |
| 292 decoder_->Stop(); | 292 decoder_->Stop(); |
| 293 EXPECT_EQ(0u, [delegate_->GetImage() length]); | 293 EXPECT_EQ(0u, [delegate_->GetImage() length]); |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace webp_transcode | 296 } // namespace webp_transcode |
| OLD | NEW |