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

Side by Side Diff: ios/web/public/image_fetcher/webp_decoder_unittest.mm

Issue 2665673002: Re-enable WebP tests (Closed)
Patch Set: 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
« no previous file with comments | « ios/web/public/image_fetcher/image_data_fetcher_unittest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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>
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 162
163 protected: 163 protected:
164 scoped_refptr<WebpDecoderDelegate> delegate_; 164 scoped_refptr<WebpDecoderDelegate> delegate_;
165 scoped_refptr<WebpDecoder> decoder_; 165 scoped_refptr<WebpDecoder> decoder_;
166 }; 166 };
167 167
168 } // namespace 168 } // namespace
169 169
170 TEST_F(WebpDecoderTest, DecodeToJpeg) { 170 TEST_F(WebpDecoderTest, DecodeToJpeg) {
171 // TODO(droger): This test fails on iOS 9 x64 devices. http://crbug.com/523235
172 #if defined(OS_IOS) && defined(ARCH_CPU_ARM64) && !TARGET_IPHONE_SIMULATOR
173 if (base::ios::IsRunningOnIOS9OrLater())
174 return;
175 #endif
176 // Load a WebP image from disk. 171 // Load a WebP image from disk.
177 base::scoped_nsobject<NSData> webp_image( 172 base::scoped_nsobject<NSData> webp_image(
178 LoadImage(base::FilePath("test.webp"))); 173 LoadImage(base::FilePath("test.webp")));
179 ASSERT_TRUE(webp_image != nil); 174 ASSERT_TRUE(webp_image != nil);
180 // Load reference image. 175 // Load reference image.
181 base::scoped_nsobject<NSData> jpg_image( 176 base::scoped_nsobject<NSData> jpg_image(
182 LoadImage(base::FilePath("test.jpg"))); 177 LoadImage(base::FilePath("test.jpg")));
183 ASSERT_TRUE(jpg_image != nil); 178 ASSERT_TRUE(jpg_image != nil);
184 // Convert to JPEG. 179 // Convert to JPEG.
185 EXPECT_CALL(*delegate_, OnFinishedDecoding(true)).Times(1); 180 EXPECT_CALL(*delegate_, OnFinishedDecoding(true)).Times(1);
186 EXPECT_CALL(*delegate_, SetImageFeatures(testing::_, WebpDecoder::JPEG)) 181 EXPECT_CALL(*delegate_, SetImageFeatures(testing::_, WebpDecoder::JPEG))
187 .Times(1); 182 .Times(1);
188 decoder_->OnDataReceived(webp_image); 183 decoder_->OnDataReceived(webp_image);
189 // Compare to reference image. 184 // Compare to reference image.
190 EXPECT_TRUE(CheckCompressedImagesEqual(jpg_image, delegate_->GetImage(), 185 EXPECT_TRUE(CheckCompressedImagesEqual(jpg_image, delegate_->GetImage(),
191 WebpDecoder::JPEG)); 186 WebpDecoder::JPEG));
192 } 187 }
193 188
194 TEST_F(WebpDecoderTest, DecodeToPng) { 189 TEST_F(WebpDecoderTest, DecodeToPng) {
195 // TODO(droger): This test fails on iOS 9 x64 devices. http://crbug.com/523235
196 #if defined(OS_IOS) && defined(ARCH_CPU_ARM64) && !TARGET_IPHONE_SIMULATOR
197 if (base::ios::IsRunningOnIOS9OrLater())
198 return;
199 #endif
200 // Load a WebP image from disk. 190 // Load a WebP image from disk.
201 base::scoped_nsobject<NSData> webp_image( 191 base::scoped_nsobject<NSData> webp_image(
202 LoadImage(base::FilePath("test_alpha.webp"))); 192 LoadImage(base::FilePath("test_alpha.webp")));
203 ASSERT_TRUE(webp_image != nil); 193 ASSERT_TRUE(webp_image != nil);
204 // Load reference image. 194 // Load reference image.
205 base::scoped_nsobject<NSData> png_image( 195 base::scoped_nsobject<NSData> png_image(
206 LoadImage(base::FilePath("test_alpha.png"))); 196 LoadImage(base::FilePath("test_alpha.png")));
207 ASSERT_TRUE(png_image != nil); 197 ASSERT_TRUE(png_image != nil);
208 // Convert to PNG. 198 // Convert to PNG.
209 EXPECT_CALL(*delegate_, OnFinishedDecoding(true)).Times(1); 199 EXPECT_CALL(*delegate_, OnFinishedDecoding(true)).Times(1);
210 EXPECT_CALL(*delegate_, SetImageFeatures(testing::_, WebpDecoder::PNG)) 200 EXPECT_CALL(*delegate_, SetImageFeatures(testing::_, WebpDecoder::PNG))
211 .Times(1); 201 .Times(1);
212 decoder_->OnDataReceived(webp_image); 202 decoder_->OnDataReceived(webp_image);
213 // Compare to reference image. 203 // Compare to reference image.
214 EXPECT_TRUE(CheckCompressedImagesEqual(png_image, delegate_->GetImage(), 204 EXPECT_TRUE(CheckCompressedImagesEqual(png_image, delegate_->GetImage(),
215 WebpDecoder::PNG)); 205 WebpDecoder::PNG));
216 } 206 }
217 207
218 TEST_F(WebpDecoderTest, DecodeToTiff) { 208 TEST_F(WebpDecoderTest, DecodeToTiff) {
219 // TODO(droger): This test fails on iOS 9 x64 devices. http://crbug.com/523235
220 #if defined(OS_IOS) && defined(ARCH_CPU_ARM64) && !TARGET_IPHONE_SIMULATOR
221 if (base::ios::IsRunningOnIOS9OrLater())
222 return;
223 #endif
224 // Load a WebP image from disk. 209 // Load a WebP image from disk.
225 base::scoped_nsobject<NSData> webp_image( 210 base::scoped_nsobject<NSData> webp_image(
226 LoadImage(base::FilePath("test_small.webp"))); 211 LoadImage(base::FilePath("test_small.webp")));
227 ASSERT_TRUE(webp_image != nil); 212 ASSERT_TRUE(webp_image != nil);
228 // Load reference image. 213 // Load reference image.
229 base::scoped_nsobject<NSData> tiff_image( 214 base::scoped_nsobject<NSData> tiff_image(
230 LoadImage(base::FilePath("test_small.tiff"))); 215 LoadImage(base::FilePath("test_small.tiff")));
231 ASSERT_TRUE(tiff_image != nil); 216 ASSERT_TRUE(tiff_image != nil);
232 // Convert to TIFF. 217 // Convert to TIFF.
233 EXPECT_CALL(*delegate_, OnFinishedDecoding(true)).Times(1); 218 EXPECT_CALL(*delegate_, OnFinishedDecoding(true)).Times(1);
234 EXPECT_CALL(*delegate_, 219 EXPECT_CALL(*delegate_,
235 SetImageFeatures([tiff_image length], WebpDecoder::TIFF)) 220 SetImageFeatures([tiff_image length], WebpDecoder::TIFF))
236 .Times(1); 221 .Times(1);
237 decoder_->OnDataReceived(webp_image); 222 decoder_->OnDataReceived(webp_image);
238 // Compare to reference image. 223 // Compare to reference image.
239 EXPECT_TRUE(CheckTiffImagesEqual(tiff_image, delegate_->GetImage())); 224 EXPECT_TRUE(CheckTiffImagesEqual(tiff_image, delegate_->GetImage()));
240 } 225 }
241 226
242 TEST_F(WebpDecoderTest, StreamedDecode) { 227 TEST_F(WebpDecoderTest, StreamedDecode) {
243 // TODO(droger): This test fails on iOS 9 x64 devices. http://crbug.com/523235
244 #if defined(OS_IOS) && defined(ARCH_CPU_ARM64) && !TARGET_IPHONE_SIMULATOR
245 if (base::ios::IsRunningOnIOS9OrLater())
246 return;
247 #endif
248 // Load a WebP image from disk. 228 // Load a WebP image from disk.
249 base::scoped_nsobject<NSData> webp_image( 229 base::scoped_nsobject<NSData> webp_image(
250 LoadImage(base::FilePath("test.webp"))); 230 LoadImage(base::FilePath("test.webp")));
251 ASSERT_TRUE(webp_image != nil); 231 ASSERT_TRUE(webp_image != nil);
252 // Load reference image. 232 // Load reference image.
253 base::scoped_nsobject<NSData> jpg_image( 233 base::scoped_nsobject<NSData> jpg_image(
254 LoadImage(base::FilePath("test.jpg"))); 234 LoadImage(base::FilePath("test.jpg")));
255 ASSERT_TRUE(jpg_image != nil); 235 ASSERT_TRUE(jpg_image != nil);
256 // Convert to JPEG in chunks. 236 // Convert to JPEG in chunks.
257 EXPECT_CALL(*delegate_, OnFinishedDecoding(true)).Times(1); 237 EXPECT_CALL(*delegate_, OnFinishedDecoding(true)).Times(1);
(...skipping 29 matching lines...) Expand all
287 EXPECT_EQ(0u, [delegate_->GetImage() length]); 267 EXPECT_EQ(0u, [delegate_->GetImage() length]);
288 } 268 }
289 269
290 TEST_F(WebpDecoderTest, DecodeAborted) { 270 TEST_F(WebpDecoderTest, DecodeAborted) {
291 EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1); 271 EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1);
292 decoder_->Stop(); 272 decoder_->Stop();
293 EXPECT_EQ(0u, [delegate_->GetImage() length]); 273 EXPECT_EQ(0u, [delegate_->GetImage() length]);
294 } 274 }
295 275
296 } // namespace webp_transcode 276 } // namespace webp_transcode
OLDNEW
« no previous file with comments | « ios/web/public/image_fetcher/image_data_fetcher_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698