Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(663)

Side by Side Diff: components/image_fetcher/ios/webp_decoder_unittest.mm

Issue 2699633006: Move WebpDecoder from ios/web to components/image_fetcher (Closed)
Patch Set: Separate header Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/image_fetcher/ios/webp_decoder.mm ('k') | components/test/data/webp_transcode/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698