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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp

Issue 1962563002: Fix ImageDecoder::frameIsCompleteAtIndex - fully received instead of decoded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 canvasBitmap.allocN32Pixels(100, 100); 252 canvasBitmap.allocN32Pixels(100, 100);
253 ASSERT_TRUE(m_surface->getCanvas()->readPixels(&canvasBitmap, 0, 0)); 253 ASSERT_TRUE(m_surface->getCanvas()->readPixels(&canvasBitmap, 0, 0));
254 SkAutoLockPixels autoLock(canvasBitmap); 254 SkAutoLockPixels autoLock(canvasBitmap);
255 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0)); 255 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0));
256 } 256 }
257 257
258 TEST_F(DeferredImageDecoderTest, singleFrameImageLoading) 258 TEST_F(DeferredImageDecoderTest, singleFrameImageLoading)
259 { 259 {
260 m_status = ImageFrame::FramePartial; 260 m_status = ImageFrame::FramePartial;
261 m_lazyDecoder->setData(*m_data, false); 261 m_lazyDecoder->setData(*m_data, false);
262 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0)); 262 EXPECT_FALSE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0));
263 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0); 263 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0);
264 ASSERT_TRUE(image); 264 ASSERT_TRUE(image);
265 unsigned firstId = image->uniqueID(); 265 unsigned firstId = image->uniqueID();
266 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0)); 266 EXPECT_FALSE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0));
267 EXPECT_TRUE(m_actualDecoder); 267 EXPECT_TRUE(m_actualDecoder);
268 268
269 m_status = ImageFrame::FrameComplete; 269 m_status = ImageFrame::FrameComplete;
270 m_data->append(" ", 1u); 270 m_data->append(" ", 1u);
271 m_lazyDecoder->setData(*m_data, true); 271 m_lazyDecoder->setData(*m_data, true);
272 EXPECT_FALSE(m_actualDecoder); 272 EXPECT_FALSE(m_actualDecoder);
273 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0)); 273 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0));
274 274
275 image = m_lazyDecoder->createFrameAtIndex(0); 275 image = m_lazyDecoder->createFrameAtIndex(0);
276 ASSERT_TRUE(image); 276 ASSERT_TRUE(image);
277 unsigned secondId = image->uniqueID(); 277 unsigned secondId = image->uniqueID();
278 EXPECT_FALSE(m_decodeRequestCount); 278 EXPECT_FALSE(m_decodeRequestCount);
279 EXPECT_NE(firstId, secondId); 279 EXPECT_NE(firstId, secondId);
280 } 280 }
281 281
282 TEST_F(DeferredImageDecoderTest, multiFrameImageLoading) 282 TEST_F(DeferredImageDecoderTest, multiFrameImageLoading)
283 { 283 {
284 m_repetitionCount = 10; 284 m_repetitionCount = 10;
285 m_frameCount = 1; 285 m_frameCount = 1;
286 m_frameDuration = 10; 286 m_frameDuration = 10;
287 m_status = ImageFrame::FramePartial; 287 m_status = ImageFrame::FramePartial;
288 m_lazyDecoder->setData(*m_data, false); 288 m_lazyDecoder->setData(*m_data, false);
289 289
290 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0); 290 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0);
291 ASSERT_TRUE(image); 291 ASSERT_TRUE(image);
292 unsigned firstId = image->uniqueID(); 292 unsigned firstId = image->uniqueID();
293 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0)); 293 EXPECT_FALSE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0));
294 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0)); 294 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0));
295 295
296 m_frameCount = 2; 296 m_frameCount = 2;
297 m_frameDuration = 20; 297 m_frameDuration = 20;
298 m_status = ImageFrame::FrameComplete; 298 m_status = ImageFrame::FrameComplete;
299 m_data->append(" ", 1u); 299 m_data->append(" ", 1u);
300 m_lazyDecoder->setData(*m_data, false); 300 m_lazyDecoder->setData(*m_data, false);
301 301
302 image = m_lazyDecoder->createFrameAtIndex(0); 302 image = m_lazyDecoder->createFrameAtIndex(0);
303 ASSERT_TRUE(image); 303 ASSERT_TRUE(image);
304 unsigned secondId = image->uniqueID(); 304 unsigned secondId = image->uniqueID();
305 EXPECT_NE(firstId, secondId); 305 EXPECT_NE(firstId, secondId);
306 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0)); 306 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0));
307 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(1)); 307 EXPECT_FALSE(m_lazyDecoder->frameIsFullyReceivedAtIndex(1));
308 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1)); 308 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1));
309 EXPECT_TRUE(m_actualDecoder); 309 EXPECT_TRUE(m_actualDecoder);
310 310
311 m_frameCount = 3; 311 m_frameCount = 3;
312 m_frameDuration = 30; 312 m_frameDuration = 30;
313 m_status = ImageFrame::FrameComplete; 313 m_status = ImageFrame::FrameComplete;
314 m_lazyDecoder->setData(*m_data, true); 314 m_lazyDecoder->setData(*m_data, true);
315 EXPECT_FALSE(m_actualDecoder); 315 EXPECT_FALSE(m_actualDecoder);
316 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0)); 316 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0));
317 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(1)); 317 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(1));
318 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(2)); 318 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(2));
319 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0)); 319 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0));
320 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1)); 320 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1));
321 EXPECT_EQ(30.0f, m_lazyDecoder->frameDurationAtIndex(2)); 321 EXPECT_EQ(30.0f, m_lazyDecoder->frameDurationAtIndex(2));
322 EXPECT_EQ(10, m_lazyDecoder->repetitionCount()); 322 EXPECT_EQ(10, m_lazyDecoder->repetitionCount());
323 } 323 }
324 324
325 TEST_F(DeferredImageDecoderTest, decodedSize) 325 TEST_F(DeferredImageDecoderTest, decodedSize)
326 { 326 {
327 m_decodedSize = IntSize(22, 33); 327 m_decodedSize = IntSize(22, 33);
328 m_lazyDecoder->setData(*m_data, true); 328 m_lazyDecoder->setData(*m_data, true);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 m_lazyDecoder->createFrameAtIndex(0); 401 m_lazyDecoder->createFrameAtIndex(0);
402 m_lazyDecoder->createFrameAtIndex(1); 402 m_lazyDecoder->createFrameAtIndex(1);
403 m_lazyDecoder->setData(*m_data, true); 403 m_lazyDecoder->setData(*m_data, true);
404 // Clears only the first frame (0 bytes). If DeferredImageDecoder doesn't 404 // Clears only the first frame (0 bytes). If DeferredImageDecoder doesn't
405 // check with the actual decoder it reports 4 bytes instead. 405 // check with the actual decoder it reports 4 bytes instead.
406 size_t frameBytesCleared = m_lazyDecoder->clearCacheExceptFrame(1); 406 size_t frameBytesCleared = m_lazyDecoder->clearCacheExceptFrame(1);
407 EXPECT_EQ(static_cast<size_t>(0), frameBytesCleared); 407 EXPECT_EQ(static_cast<size_t>(0), frameBytesCleared);
408 } 408 }
409 409
410 } // namespace blink 410 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698