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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoderTest.cpp

Issue 2496663002: Merge css3/image/ and fast/images/ to images/ (Closed)
Patch Set: Address failing tests (3 of them) Created 4 years, 1 month 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 | « third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp ('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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 verifyFramesMatch(webpFile, decoderA->frameBufferAtIndex(i), 136 verifyFramesMatch(webpFile, decoderA->frameBufferAtIndex(i),
137 decoderB->frameBufferAtIndex(i)); 137 decoderB->frameBufferAtIndex(i));
138 } 138 }
139 139
140 } // anonymous namespace 140 } // anonymous namespace
141 141
142 TEST(AnimatedWebPTests, uniqueGenerationIDs) { 142 TEST(AnimatedWebPTests, uniqueGenerationIDs) {
143 std::unique_ptr<ImageDecoder> decoder = createDecoder(); 143 std::unique_ptr<ImageDecoder> decoder = createDecoder();
144 144
145 RefPtr<SharedBuffer> data = 145 RefPtr<SharedBuffer> data =
146 readFile("/LayoutTests/fast/images/resources/webp-animated.webp"); 146 readFile("/LayoutTests/images/resources/webp-animated.webp");
147 ASSERT_TRUE(data.get()); 147 ASSERT_TRUE(data.get());
148 decoder->setData(data.get(), true); 148 decoder->setData(data.get(), true);
149 149
150 ImageFrame* frame = decoder->frameBufferAtIndex(0); 150 ImageFrame* frame = decoder->frameBufferAtIndex(0);
151 uint32_t generationID0 = frame->bitmap().getGenerationID(); 151 uint32_t generationID0 = frame->bitmap().getGenerationID();
152 frame = decoder->frameBufferAtIndex(1); 152 frame = decoder->frameBufferAtIndex(1);
153 uint32_t generationID1 = frame->bitmap().getGenerationID(); 153 uint32_t generationID1 = frame->bitmap().getGenerationID();
154 154
155 EXPECT_TRUE(generationID0 != generationID1); 155 EXPECT_TRUE(generationID0 != generationID1);
156 } 156 }
157 157
158 TEST(AnimatedWebPTests, verifyAnimationParametersTransparentImage) { 158 TEST(AnimatedWebPTests, verifyAnimationParametersTransparentImage) {
159 std::unique_ptr<ImageDecoder> decoder = createDecoder(); 159 std::unique_ptr<ImageDecoder> decoder = createDecoder();
160 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount()); 160 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount());
161 161
162 RefPtr<SharedBuffer> data = 162 RefPtr<SharedBuffer> data =
163 readFile("/LayoutTests/fast/images/resources/webp-animated.webp"); 163 readFile("/LayoutTests/images/resources/webp-animated.webp");
164 ASSERT_TRUE(data.get()); 164 ASSERT_TRUE(data.get());
165 decoder->setData(data.get(), true); 165 decoder->setData(data.get(), true);
166 166
167 const int canvasWidth = 11; 167 const int canvasWidth = 11;
168 const int canvasHeight = 29; 168 const int canvasHeight = 29;
169 const struct AnimParam { 169 const struct AnimParam {
170 int xOffset, yOffset, width, height; 170 int xOffset, yOffset, width, height;
171 ImageFrame::DisposalMethod disposalMethod; 171 ImageFrame::DisposalMethod disposalMethod;
172 ImageFrame::AlphaBlendSource alphaBlendSource; 172 ImageFrame::AlphaBlendSource alphaBlendSource;
173 unsigned duration; 173 unsigned duration;
(...skipping 26 matching lines...) Expand all
200 EXPECT_EQ(WTF_ARRAY_LENGTH(frameParameters), decoder->frameCount()); 200 EXPECT_EQ(WTF_ARRAY_LENGTH(frameParameters), decoder->frameCount());
201 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount()); 201 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount());
202 } 202 }
203 203
204 TEST(AnimatedWebPTests, 204 TEST(AnimatedWebPTests,
205 verifyAnimationParametersOpaqueFramesTransparentBackground) { 205 verifyAnimationParametersOpaqueFramesTransparentBackground) {
206 std::unique_ptr<ImageDecoder> decoder = createDecoder(); 206 std::unique_ptr<ImageDecoder> decoder = createDecoder();
207 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount()); 207 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount());
208 208
209 RefPtr<SharedBuffer> data = 209 RefPtr<SharedBuffer> data =
210 readFile("/LayoutTests/fast/images/resources/webp-animated-opaque.webp"); 210 readFile("/LayoutTests/images/resources/webp-animated-opaque.webp");
211 ASSERT_TRUE(data.get()); 211 ASSERT_TRUE(data.get());
212 decoder->setData(data.get(), true); 212 decoder->setData(data.get(), true);
213 213
214 const int canvasWidth = 94; 214 const int canvasWidth = 94;
215 const int canvasHeight = 87; 215 const int canvasHeight = 87;
216 const struct AnimParam { 216 const struct AnimParam {
217 int xOffset, yOffset, width, height; 217 int xOffset, yOffset, width, height;
218 ImageFrame::DisposalMethod disposalMethod; 218 ImageFrame::DisposalMethod disposalMethod;
219 ImageFrame::AlphaBlendSource alphaBlendSource; 219 ImageFrame::AlphaBlendSource alphaBlendSource;
220 unsigned duration; 220 unsigned duration;
(...skipping 26 matching lines...) Expand all
247 } 247 }
248 248
249 EXPECT_EQ(WTF_ARRAY_LENGTH(frameParameters), decoder->frameCount()); 249 EXPECT_EQ(WTF_ARRAY_LENGTH(frameParameters), decoder->frameCount());
250 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount()); 250 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount());
251 } 251 }
252 252
253 TEST(AnimatedWebPTests, verifyAnimationParametersBlendOverwrite) { 253 TEST(AnimatedWebPTests, verifyAnimationParametersBlendOverwrite) {
254 std::unique_ptr<ImageDecoder> decoder = createDecoder(); 254 std::unique_ptr<ImageDecoder> decoder = createDecoder();
255 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount()); 255 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount());
256 256
257 RefPtr<SharedBuffer> data = readFile( 257 RefPtr<SharedBuffer> data =
258 "/LayoutTests/fast/images/resources/webp-animated-no-blend.webp"); 258 readFile("/LayoutTests/images/resources/webp-animated-no-blend.webp");
259 ASSERT_TRUE(data.get()); 259 ASSERT_TRUE(data.get());
260 decoder->setData(data.get(), true); 260 decoder->setData(data.get(), true);
261 261
262 const int canvasWidth = 94; 262 const int canvasWidth = 94;
263 const int canvasHeight = 87; 263 const int canvasHeight = 87;
264 const struct AnimParam { 264 const struct AnimParam {
265 int xOffset, yOffset, width, height; 265 int xOffset, yOffset, width, height;
266 ImageFrame::DisposalMethod disposalMethod; 266 ImageFrame::DisposalMethod disposalMethod;
267 ImageFrame::AlphaBlendSource alphaBlendSource; 267 ImageFrame::AlphaBlendSource alphaBlendSource;
268 unsigned duration; 268 unsigned duration;
(...skipping 24 matching lines...) Expand all
293 EXPECT_EQ(frameParameters[i].duration, frame->duration()); 293 EXPECT_EQ(frameParameters[i].duration, frame->duration());
294 EXPECT_EQ(frameParameters[i].hasAlpha, frame->hasAlpha()); 294 EXPECT_EQ(frameParameters[i].hasAlpha, frame->hasAlpha());
295 } 295 }
296 296
297 EXPECT_EQ(WTF_ARRAY_LENGTH(frameParameters), decoder->frameCount()); 297 EXPECT_EQ(WTF_ARRAY_LENGTH(frameParameters), decoder->frameCount());
298 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount()); 298 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount());
299 } 299 }
300 300
301 TEST(AnimatedWebPTests, parseAndDecodeByteByByte) { 301 TEST(AnimatedWebPTests, parseAndDecodeByteByByte) {
302 testByteByByteDecode(&createDecoder, 302 testByteByByteDecode(&createDecoder,
303 "/LayoutTests/fast/images/resources/webp-animated.webp", 303 "/LayoutTests/images/resources/webp-animated.webp", 3u,
304 3u, cAnimationLoopInfinite); 304 cAnimationLoopInfinite);
305 testByteByByteDecode( 305 testByteByByteDecode(
306 &createDecoder, 306 &createDecoder,
307 "/LayoutTests/fast/images/resources/webp-animated-icc-xmp.webp", 13u, 307 "/LayoutTests/images/resources/webp-animated-icc-xmp.webp", 13u, 32000);
308 32000);
309 } 308 }
310 309
311 TEST(AnimatedWebPTests, invalidImages) { 310 TEST(AnimatedWebPTests, invalidImages) {
312 // ANMF chunk size is smaller than ANMF header size. 311 // ANMF chunk size is smaller than ANMF header size.
313 testInvalidImage( 312 testInvalidImage("/LayoutTests/images/resources/invalid-animated-webp.webp",
314 "/LayoutTests/fast/images/resources/invalid-animated-webp.webp", true); 313 true);
315 // One of the frame rectangles extends outside the image boundary. 314 // One of the frame rectangles extends outside the image boundary.
316 testInvalidImage( 315 testInvalidImage("/LayoutTests/images/resources/invalid-animated-webp3.webp",
317 "/LayoutTests/fast/images/resources/invalid-animated-webp3.webp", true); 316 true);
318 } 317 }
319 318
320 TEST(AnimatedWebPTests, truncatedLastFrame) { 319 TEST(AnimatedWebPTests, truncatedLastFrame) {
321 std::unique_ptr<ImageDecoder> decoder = createDecoder(); 320 std::unique_ptr<ImageDecoder> decoder = createDecoder();
322 321
323 RefPtr<SharedBuffer> data = readFile( 322 RefPtr<SharedBuffer> data =
324 "/LayoutTests/fast/images/resources/invalid-animated-webp2.webp"); 323 readFile("/LayoutTests/images/resources/invalid-animated-webp2.webp");
325 ASSERT_TRUE(data.get()); 324 ASSERT_TRUE(data.get());
326 decoder->setData(data.get(), true); 325 decoder->setData(data.get(), true);
327 326
328 size_t frameCount = 8; 327 size_t frameCount = 8;
329 EXPECT_EQ(frameCount, decoder->frameCount()); 328 EXPECT_EQ(frameCount, decoder->frameCount());
330 ImageFrame* frame = decoder->frameBufferAtIndex(0); 329 ImageFrame* frame = decoder->frameBufferAtIndex(0);
331 ASSERT_TRUE(frame); 330 ASSERT_TRUE(frame);
332 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus()); 331 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus());
333 EXPECT_FALSE(decoder->failed()); 332 EXPECT_FALSE(decoder->failed());
334 frame = decoder->frameBufferAtIndex(frameCount - 1); 333 frame = decoder->frameBufferAtIndex(frameCount - 1);
335 ASSERT_TRUE(frame); 334 ASSERT_TRUE(frame);
336 EXPECT_EQ(ImageFrame::FramePartial, frame->getStatus()); 335 EXPECT_EQ(ImageFrame::FramePartial, frame->getStatus());
337 EXPECT_TRUE(decoder->failed()); 336 EXPECT_TRUE(decoder->failed());
338 frame = decoder->frameBufferAtIndex(0); 337 frame = decoder->frameBufferAtIndex(0);
339 ASSERT_TRUE(frame); 338 ASSERT_TRUE(frame);
340 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus()); 339 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus());
341 } 340 }
342 341
343 TEST(AnimatedWebPTests, truncatedInBetweenFrame) { 342 TEST(AnimatedWebPTests, truncatedInBetweenFrame) {
344 std::unique_ptr<ImageDecoder> decoder = createDecoder(); 343 std::unique_ptr<ImageDecoder> decoder = createDecoder();
345 344
346 RefPtr<SharedBuffer> fullData = readFile( 345 RefPtr<SharedBuffer> fullData =
347 "/LayoutTests/fast/images/resources/invalid-animated-webp4.webp"); 346 readFile("/LayoutTests/images/resources/invalid-animated-webp4.webp");
348 ASSERT_TRUE(fullData.get()); 347 ASSERT_TRUE(fullData.get());
349 RefPtr<SharedBuffer> data = 348 RefPtr<SharedBuffer> data =
350 SharedBuffer::create(fullData->data(), fullData->size() - 1); 349 SharedBuffer::create(fullData->data(), fullData->size() - 1);
351 decoder->setData(data.get(), false); 350 decoder->setData(data.get(), false);
352 351
353 ImageFrame* frame = decoder->frameBufferAtIndex(1); 352 ImageFrame* frame = decoder->frameBufferAtIndex(1);
354 ASSERT_TRUE(frame); 353 ASSERT_TRUE(frame);
355 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus()); 354 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus());
356 frame = decoder->frameBufferAtIndex(2); 355 frame = decoder->frameBufferAtIndex(2);
357 ASSERT_TRUE(frame); 356 ASSERT_TRUE(frame);
358 EXPECT_EQ(ImageFrame::FramePartial, frame->getStatus()); 357 EXPECT_EQ(ImageFrame::FramePartial, frame->getStatus());
359 EXPECT_TRUE(decoder->failed()); 358 EXPECT_TRUE(decoder->failed());
360 } 359 }
361 360
362 // Tests for a crash that used to happen for a specific file with specific 361 // Tests for a crash that used to happen for a specific file with specific
363 // sequence of method calls. 362 // sequence of method calls.
364 TEST(AnimatedWebPTests, reproCrash) { 363 TEST(AnimatedWebPTests, reproCrash) {
365 std::unique_ptr<ImageDecoder> decoder = createDecoder(); 364 std::unique_ptr<ImageDecoder> decoder = createDecoder();
366 365
367 RefPtr<SharedBuffer> fullData = 366 RefPtr<SharedBuffer> fullData =
368 readFile("/LayoutTests/fast/images/resources/invalid_vp8_vp8x.webp"); 367 readFile("/LayoutTests/images/resources/invalid_vp8_vp8x.webp");
369 ASSERT_TRUE(fullData.get()); 368 ASSERT_TRUE(fullData.get());
370 369
371 // Parse partial data up to which error in bitstream is not detected. 370 // Parse partial data up to which error in bitstream is not detected.
372 const size_t partialSize = 32768; 371 const size_t partialSize = 32768;
373 ASSERT_GT(fullData->size(), partialSize); 372 ASSERT_GT(fullData->size(), partialSize);
374 RefPtr<SharedBuffer> data = 373 RefPtr<SharedBuffer> data =
375 SharedBuffer::create(fullData->data(), partialSize); 374 SharedBuffer::create(fullData->data(), partialSize);
376 decoder->setData(data.get(), false); 375 decoder->setData(data.get(), false);
377 EXPECT_EQ(1u, decoder->frameCount()); 376 EXPECT_EQ(1u, decoder->frameCount());
378 ImageFrame* frame = decoder->frameBufferAtIndex(0); 377 ImageFrame* frame = decoder->frameBufferAtIndex(0);
379 ASSERT_TRUE(frame); 378 ASSERT_TRUE(frame);
380 EXPECT_EQ(ImageFrame::FramePartial, frame->getStatus()); 379 EXPECT_EQ(ImageFrame::FramePartial, frame->getStatus());
381 EXPECT_FALSE(decoder->failed()); 380 EXPECT_FALSE(decoder->failed());
382 381
383 // Parse full data now. The error in bitstream should now be detected. 382 // Parse full data now. The error in bitstream should now be detected.
384 decoder->setData(fullData.get(), true); 383 decoder->setData(fullData.get(), true);
385 EXPECT_EQ(1u, decoder->frameCount()); 384 EXPECT_EQ(1u, decoder->frameCount());
386 frame = decoder->frameBufferAtIndex(0); 385 frame = decoder->frameBufferAtIndex(0);
387 ASSERT_TRUE(frame); 386 ASSERT_TRUE(frame);
388 EXPECT_EQ(ImageFrame::FramePartial, frame->getStatus()); 387 EXPECT_EQ(ImageFrame::FramePartial, frame->getStatus());
389 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount()); 388 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount());
390 EXPECT_TRUE(decoder->failed()); 389 EXPECT_TRUE(decoder->failed());
391 } 390 }
392 391
393 TEST(AnimatedWebPTests, progressiveDecode) { 392 TEST(AnimatedWebPTests, progressiveDecode) {
394 testProgressiveDecoding( 393 testProgressiveDecoding(&createDecoder,
395 &createDecoder, "/LayoutTests/fast/images/resources/webp-animated.webp"); 394 "/LayoutTests/images/resources/webp-animated.webp");
396 } 395 }
397 396
398 TEST(AnimatedWebPTests, frameIsCompleteAndDuration) { 397 TEST(AnimatedWebPTests, frameIsCompleteAndDuration) {
399 std::unique_ptr<ImageDecoder> decoder = createDecoder(); 398 std::unique_ptr<ImageDecoder> decoder = createDecoder();
400 399
401 RefPtr<SharedBuffer> data = 400 RefPtr<SharedBuffer> data =
402 readFile("/LayoutTests/fast/images/resources/webp-animated.webp"); 401 readFile("/LayoutTests/images/resources/webp-animated.webp");
403 ASSERT_TRUE(data.get()); 402 ASSERT_TRUE(data.get());
404 403
405 ASSERT_GE(data->size(), 10u); 404 ASSERT_GE(data->size(), 10u);
406 RefPtr<SharedBuffer> tempData = 405 RefPtr<SharedBuffer> tempData =
407 SharedBuffer::create(data->data(), data->size() - 10); 406 SharedBuffer::create(data->data(), data->size() - 10);
408 decoder->setData(tempData.get(), false); 407 decoder->setData(tempData.get(), false);
409 408
410 EXPECT_EQ(2u, decoder->frameCount()); 409 EXPECT_EQ(2u, decoder->frameCount());
411 EXPECT_FALSE(decoder->failed()); 410 EXPECT_FALSE(decoder->failed());
412 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0)); 411 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0));
413 EXPECT_EQ(1000, decoder->frameDurationAtIndex(0)); 412 EXPECT_EQ(1000, decoder->frameDurationAtIndex(0));
414 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(1)); 413 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(1));
415 EXPECT_EQ(500, decoder->frameDurationAtIndex(1)); 414 EXPECT_EQ(500, decoder->frameDurationAtIndex(1));
416 415
417 decoder->setData(data.get(), true); 416 decoder->setData(data.get(), true);
418 EXPECT_EQ(3u, decoder->frameCount()); 417 EXPECT_EQ(3u, decoder->frameCount());
419 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0)); 418 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0));
420 EXPECT_EQ(1000, decoder->frameDurationAtIndex(0)); 419 EXPECT_EQ(1000, decoder->frameDurationAtIndex(0));
421 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(1)); 420 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(1));
422 EXPECT_EQ(500, decoder->frameDurationAtIndex(1)); 421 EXPECT_EQ(500, decoder->frameDurationAtIndex(1));
423 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(2)); 422 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(2));
424 EXPECT_EQ(1000.0, decoder->frameDurationAtIndex(2)); 423 EXPECT_EQ(1000.0, decoder->frameDurationAtIndex(2));
425 } 424 }
426 425
427 TEST(AnimatedWebPTests, updateRequiredPreviousFrameAfterFirstDecode) { 426 TEST(AnimatedWebPTests, updateRequiredPreviousFrameAfterFirstDecode) {
428 std::unique_ptr<ImageDecoder> decoder = createDecoder(); 427 std::unique_ptr<ImageDecoder> decoder = createDecoder();
429 428
430 RefPtr<SharedBuffer> fullData = 429 RefPtr<SharedBuffer> fullData =
431 readFile("/LayoutTests/fast/images/resources/webp-animated.webp"); 430 readFile("/LayoutTests/images/resources/webp-animated.webp");
432 ASSERT_TRUE(fullData.get()); 431 ASSERT_TRUE(fullData.get());
433 432
434 // Check the status of requiredPreviousFrameIndex before decoding, by 433 // Check the status of requiredPreviousFrameIndex before decoding, by
435 // supplying data sufficient to parse but not decode. 434 // supplying data sufficient to parse but not decode.
436 size_t partialSize = 1; 435 size_t partialSize = 1;
437 do { 436 do {
438 RefPtr<SharedBuffer> data = 437 RefPtr<SharedBuffer> data =
439 SharedBuffer::create(fullData->data(), partialSize); 438 SharedBuffer::create(fullData->data(), partialSize);
440 decoder->setData(data.get(), false); 439 decoder->setData(data.get(), false);
441 ++partialSize; 440 ++partialSize;
442 } while (!decoder->frameCount() || 441 } while (!decoder->frameCount() ||
443 decoder->frameBufferAtIndex(0)->getStatus() == 442 decoder->frameBufferAtIndex(0)->getStatus() ==
444 ImageFrame::FrameEmpty); 443 ImageFrame::FrameEmpty);
445 444
446 EXPECT_EQ(kNotFound, 445 EXPECT_EQ(kNotFound,
447 decoder->frameBufferAtIndex(0)->requiredPreviousFrameIndex()); 446 decoder->frameBufferAtIndex(0)->requiredPreviousFrameIndex());
448 size_t frameCount = decoder->frameCount(); 447 size_t frameCount = decoder->frameCount();
449 for (size_t i = 1; i < frameCount; ++i) 448 for (size_t i = 1; i < frameCount; ++i)
450 EXPECT_EQ(i - 1, 449 EXPECT_EQ(i - 1,
451 decoder->frameBufferAtIndex(i)->requiredPreviousFrameIndex()); 450 decoder->frameBufferAtIndex(i)->requiredPreviousFrameIndex());
452 451
453 decoder->setData(fullData.get(), true); 452 decoder->setData(fullData.get(), true);
454 for (size_t i = 0; i < frameCount; ++i) 453 for (size_t i = 0; i < frameCount; ++i)
455 EXPECT_EQ(kNotFound, 454 EXPECT_EQ(kNotFound,
456 decoder->frameBufferAtIndex(i)->requiredPreviousFrameIndex()); 455 decoder->frameBufferAtIndex(i)->requiredPreviousFrameIndex());
457 } 456 }
458 457
459 TEST(AnimatedWebPTests, randomFrameDecode) { 458 TEST(AnimatedWebPTests, randomFrameDecode) {
460 testRandomFrameDecode( 459 testRandomFrameDecode(&createDecoder,
461 &createDecoder, "/LayoutTests/fast/images/resources/webp-animated.webp"); 460 "/LayoutTests/images/resources/webp-animated.webp");
462 testRandomFrameDecode( 461 testRandomFrameDecode(
463 &createDecoder, 462 &createDecoder,
464 "/LayoutTests/fast/images/resources/webp-animated-opaque.webp"); 463 "/LayoutTests/images/resources/webp-animated-opaque.webp");
464 testRandomFrameDecode(
465 &createDecoder, "/LayoutTests/images/resources/webp-animated-large.webp");
465 testRandomFrameDecode( 466 testRandomFrameDecode(
466 &createDecoder, 467 &createDecoder,
467 "/LayoutTests/fast/images/resources/webp-animated-large.webp"); 468 "/LayoutTests/images/resources/webp-animated-icc-xmp.webp");
468 testRandomFrameDecode(
469 &createDecoder,
470 "/LayoutTests/fast/images/resources/webp-animated-icc-xmp.webp");
471 } 469 }
472 470
473 TEST(AnimatedWebPTests, randomDecodeAfterClearFrameBufferCache) { 471 TEST(AnimatedWebPTests, randomDecodeAfterClearFrameBufferCache) {
474 testRandomDecodeAfterClearFrameBufferCache( 472 testRandomDecodeAfterClearFrameBufferCache(
475 &createDecoder, "/LayoutTests/fast/images/resources/webp-animated.webp"); 473 &createDecoder, "/LayoutTests/images/resources/webp-animated.webp");
476 testRandomDecodeAfterClearFrameBufferCache( 474 testRandomDecodeAfterClearFrameBufferCache(
477 &createDecoder, 475 &createDecoder,
478 "/LayoutTests/fast/images/resources/webp-animated-opaque.webp"); 476 "/LayoutTests/images/resources/webp-animated-opaque.webp");
477 testRandomDecodeAfterClearFrameBufferCache(
478 &createDecoder, "/LayoutTests/images/resources/webp-animated-large.webp");
479 testRandomDecodeAfterClearFrameBufferCache( 479 testRandomDecodeAfterClearFrameBufferCache(
480 &createDecoder, 480 &createDecoder,
481 "/LayoutTests/fast/images/resources/webp-animated-large.webp"); 481 "/LayoutTests/images/resources/webp-animated-icc-xmp.webp");
482 testRandomDecodeAfterClearFrameBufferCache(
483 &createDecoder,
484 "/LayoutTests/fast/images/resources/webp-animated-icc-xmp.webp");
485 } 482 }
486 483
487 TEST(AnimatedWebPTests, 484 TEST(AnimatedWebPTests,
488 DISABLED_resumePartialDecodeAfterClearFrameBufferCache) { 485 DISABLED_resumePartialDecodeAfterClearFrameBufferCache) {
489 RefPtr<SharedBuffer> fullData = 486 RefPtr<SharedBuffer> fullData =
490 readFile("/LayoutTests/fast/images/resources/webp-animated-large.webp"); 487 readFile("/LayoutTests/images/resources/webp-animated-large.webp");
491 ASSERT_TRUE(fullData.get()); 488 ASSERT_TRUE(fullData.get());
492 Vector<unsigned> baselineHashes; 489 Vector<unsigned> baselineHashes;
493 createDecodingBaseline(&createDecoder, fullData.get(), &baselineHashes); 490 createDecodingBaseline(&createDecoder, fullData.get(), &baselineHashes);
494 size_t frameCount = baselineHashes.size(); 491 size_t frameCount = baselineHashes.size();
495 492
496 std::unique_ptr<ImageDecoder> decoder = createDecoder(); 493 std::unique_ptr<ImageDecoder> decoder = createDecoder();
497 494
498 // Let frame 0 be partially decoded. 495 // Let frame 0 be partially decoded.
499 size_t partialSize = 1; 496 size_t partialSize = 1;
500 do { 497 do {
(...skipping 13 matching lines...) Expand all
514 decoder->clearCacheExceptFrame(kNotFound); 511 decoder->clearCacheExceptFrame(kNotFound);
515 512
516 // Resume decoding of the first frame. 513 // Resume decoding of the first frame.
517 ImageFrame* firstFrame = decoder->frameBufferAtIndex(0); 514 ImageFrame* firstFrame = decoder->frameBufferAtIndex(0);
518 EXPECT_EQ(ImageFrame::FrameComplete, firstFrame->getStatus()); 515 EXPECT_EQ(ImageFrame::FrameComplete, firstFrame->getStatus());
519 EXPECT_EQ(baselineHashes[0], hashBitmap(firstFrame->bitmap())); 516 EXPECT_EQ(baselineHashes[0], hashBitmap(firstFrame->bitmap()));
520 } 517 }
521 518
522 TEST(AnimatedWebPTests, decodeAfterReallocatingData) { 519 TEST(AnimatedWebPTests, decodeAfterReallocatingData) {
523 testDecodeAfterReallocatingData( 520 testDecodeAfterReallocatingData(
524 &createDecoder, "/LayoutTests/fast/images/resources/webp-animated.webp"); 521 &createDecoder, "/LayoutTests/images/resources/webp-animated.webp");
525 testDecodeAfterReallocatingData( 522 testDecodeAfterReallocatingData(
526 &createDecoder, 523 &createDecoder,
527 "/LayoutTests/fast/images/resources/webp-animated-icc-xmp.webp"); 524 "/LayoutTests/images/resources/webp-animated-icc-xmp.webp");
528 } 525 }
529 526
530 TEST(AnimatedWebPTests, alphaBlending) { 527 TEST(AnimatedWebPTests, alphaBlending) {
531 testAlphaBlending("/LayoutTests/fast/images/resources/webp-animated.webp"); 528 testAlphaBlending("/LayoutTests/images/resources/webp-animated.webp");
532 testAlphaBlending( 529 testAlphaBlending(
533 "/LayoutTests/fast/images/resources/webp-animated-semitransparent1.webp"); 530 "/LayoutTests/images/resources/webp-animated-semitransparent1.webp");
534 testAlphaBlending( 531 testAlphaBlending(
535 "/LayoutTests/fast/images/resources/webp-animated-semitransparent2.webp"); 532 "/LayoutTests/images/resources/webp-animated-semitransparent2.webp");
536 testAlphaBlending( 533 testAlphaBlending(
537 "/LayoutTests/fast/images/resources/webp-animated-semitransparent3.webp"); 534 "/LayoutTests/images/resources/webp-animated-semitransparent3.webp");
538 testAlphaBlending( 535 testAlphaBlending(
539 "/LayoutTests/fast/images/resources/webp-animated-semitransparent4.webp"); 536 "/LayoutTests/images/resources/webp-animated-semitransparent4.webp");
540 } 537 }
541 538
542 TEST(AnimatedWebPTests, isSizeAvailable) { 539 TEST(AnimatedWebPTests, isSizeAvailable) {
543 testByteByByteSizeAvailable( 540 testByteByByteSizeAvailable(
544 &createDecoder, "/LayoutTests/fast/images/resources/webp-animated.webp", 541 &createDecoder, "/LayoutTests/images/resources/webp-animated.webp", 142u,
545 142u, false, cAnimationLoopInfinite); 542 false, cAnimationLoopInfinite);
546 // FIXME: Add color profile support for animated webp images. 543 // FIXME: Add color profile support for animated webp images.
547 testByteByByteSizeAvailable( 544 testByteByByteSizeAvailable(
548 &createDecoder, 545 &createDecoder,
549 "/LayoutTests/fast/images/resources/webp-animated-icc-xmp.webp", 1404u, 546 "/LayoutTests/images/resources/webp-animated-icc-xmp.webp", 1404u, false,
550 false, 32000); 547 32000);
551 } 548 }
552 549
553 TEST(StaticWebPTests, truncatedImage) { 550 TEST(StaticWebPTests, truncatedImage) {
554 // VP8 data is truncated. 551 // VP8 data is truncated.
555 testInvalidImage("/LayoutTests/fast/images/resources/truncated.webp", false); 552 testInvalidImage("/LayoutTests/images/resources/truncated.webp", false);
556 // Chunk size in RIFF header doesn't match the file size. 553 // Chunk size in RIFF header doesn't match the file size.
557 testInvalidImage("/LayoutTests/fast/images/resources/truncated2.webp", true); 554 testInvalidImage("/LayoutTests/images/resources/truncated2.webp", true);
558 } 555 }
559 556
560 // Regression test for a bug where some valid images were failing to decode 557 // Regression test for a bug where some valid images were failing to decode
561 // incrementally. 558 // incrementally.
562 TEST(StaticWebPTests, incrementalDecode) { 559 TEST(StaticWebPTests, incrementalDecode) {
563 testByteByByteDecode(&createDecoder, 560 testByteByByteDecode(&createDecoder,
564 "/LayoutTests/fast/images/resources/crbug.364830.webp", 561 "/LayoutTests/images/resources/crbug.364830.webp", 1u,
565 1u, cAnimationNone); 562 cAnimationNone);
566 } 563 }
567 564
568 TEST(StaticWebPTests, isSizeAvailable) { 565 TEST(StaticWebPTests, isSizeAvailable) {
569 testByteByByteSizeAvailable( 566 testByteByByteSizeAvailable(
570 &createDecoder, 567 &createDecoder,
571 "/LayoutTests/fast/images/resources/webp-color-profile-lossy.webp", 520u, 568 "/LayoutTests/images/resources/webp-color-profile-lossy.webp", 520u, true,
572 true, cAnimationNone); 569 cAnimationNone);
573 testByteByByteSizeAvailable(&createDecoder, 570 testByteByByteSizeAvailable(&createDecoder,
574 "/LayoutTests/fast/images/resources/test.webp", 571 "/LayoutTests/images/resources/test.webp", 30u,
575 30u, false, cAnimationNone); 572 false, cAnimationNone);
576 } 573 }
577 574
578 TEST(StaticWebPTests, notAnimated) { 575 TEST(StaticWebPTests, notAnimated) {
579 std::unique_ptr<ImageDecoder> decoder = createDecoder(); 576 std::unique_ptr<ImageDecoder> decoder = createDecoder();
580 RefPtr<SharedBuffer> data = readFile( 577 RefPtr<SharedBuffer> data =
581 "/LayoutTests/fast/images/resources/webp-color-profile-lossy.webp"); 578 readFile("/LayoutTests/images/resources/webp-color-profile-lossy.webp");
582 ASSERT_TRUE(data.get()); 579 ASSERT_TRUE(data.get());
583 decoder->setData(data.get(), true); 580 decoder->setData(data.get(), true);
584 EXPECT_EQ(1u, decoder->frameCount()); 581 EXPECT_EQ(1u, decoder->frameCount());
585 EXPECT_EQ(cAnimationNone, decoder->repetitionCount()); 582 EXPECT_EQ(cAnimationNone, decoder->repetitionCount());
586 } 583 }
587 584
588 } // namespace blink 585 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698