OLD | NEW |
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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 canvasBitmap.allocN32Pixels(100, 100); | 253 canvasBitmap.allocN32Pixels(100, 100); |
254 ASSERT_TRUE(m_surface->getCanvas()->readPixels(&canvasBitmap, 0, 0)); | 254 ASSERT_TRUE(m_surface->getCanvas()->readPixels(&canvasBitmap, 0, 0)); |
255 SkAutoLockPixels autoLock(canvasBitmap); | 255 SkAutoLockPixels autoLock(canvasBitmap); |
256 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0)); | 256 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0)); |
257 } | 257 } |
258 | 258 |
259 TEST_F(DeferredImageDecoderTest, singleFrameImageLoading) | 259 TEST_F(DeferredImageDecoderTest, singleFrameImageLoading) |
260 { | 260 { |
261 m_status = ImageFrame::FramePartial; | 261 m_status = ImageFrame::FramePartial; |
262 m_lazyDecoder->setData(*m_data, false); | 262 m_lazyDecoder->setData(*m_data, false); |
263 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0)); | 263 EXPECT_FALSE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0)); |
264 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0); | 264 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0); |
265 ASSERT_TRUE(image); | 265 ASSERT_TRUE(image); |
266 unsigned firstId = image->uniqueID(); | 266 unsigned firstId = image->uniqueID(); |
267 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0)); | 267 EXPECT_FALSE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0)); |
268 EXPECT_TRUE(m_actualDecoder); | 268 EXPECT_TRUE(m_actualDecoder); |
269 | 269 |
270 m_status = ImageFrame::FrameComplete; | 270 m_status = ImageFrame::FrameComplete; |
271 m_data->append(" ", 1u); | 271 m_data->append(" ", 1u); |
272 m_lazyDecoder->setData(*m_data, true); | 272 m_lazyDecoder->setData(*m_data, true); |
273 EXPECT_FALSE(m_actualDecoder); | 273 EXPECT_FALSE(m_actualDecoder); |
274 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0)); | 274 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0)); |
275 | 275 |
276 image = m_lazyDecoder->createFrameAtIndex(0); | 276 image = m_lazyDecoder->createFrameAtIndex(0); |
277 ASSERT_TRUE(image); | 277 ASSERT_TRUE(image); |
278 unsigned secondId = image->uniqueID(); | 278 unsigned secondId = image->uniqueID(); |
279 EXPECT_FALSE(m_decodeRequestCount); | 279 EXPECT_FALSE(m_decodeRequestCount); |
280 EXPECT_NE(firstId, secondId); | 280 EXPECT_NE(firstId, secondId); |
281 } | 281 } |
282 | 282 |
283 TEST_F(DeferredImageDecoderTest, multiFrameImageLoading) | 283 TEST_F(DeferredImageDecoderTest, multiFrameImageLoading) |
284 { | 284 { |
285 m_repetitionCount = 10; | 285 m_repetitionCount = 10; |
286 m_frameCount = 1; | 286 m_frameCount = 1; |
287 m_frameDuration = 10; | 287 m_frameDuration = 10; |
288 m_status = ImageFrame::FramePartial; | 288 m_status = ImageFrame::FramePartial; |
289 m_lazyDecoder->setData(*m_data, false); | 289 m_lazyDecoder->setData(*m_data, false); |
290 | 290 |
291 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0); | 291 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0); |
292 ASSERT_TRUE(image); | 292 ASSERT_TRUE(image); |
293 unsigned firstId = image->uniqueID(); | 293 unsigned firstId = image->uniqueID(); |
294 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0)); | 294 EXPECT_FALSE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0)); |
295 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0)); | 295 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0)); |
296 | 296 |
297 m_frameCount = 2; | 297 m_frameCount = 2; |
298 m_frameDuration = 20; | 298 m_frameDuration = 20; |
299 m_status = ImageFrame::FrameComplete; | 299 m_status = ImageFrame::FrameComplete; |
300 m_data->append(" ", 1u); | 300 m_data->append(" ", 1u); |
301 m_lazyDecoder->setData(*m_data, false); | 301 m_lazyDecoder->setData(*m_data, false); |
302 | 302 |
303 image = m_lazyDecoder->createFrameAtIndex(0); | 303 image = m_lazyDecoder->createFrameAtIndex(0); |
304 ASSERT_TRUE(image); | 304 ASSERT_TRUE(image); |
305 unsigned secondId = image->uniqueID(); | 305 unsigned secondId = image->uniqueID(); |
306 EXPECT_NE(firstId, secondId); | 306 EXPECT_NE(firstId, secondId); |
307 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0)); | 307 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0)); |
308 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(1)); | 308 EXPECT_FALSE(m_lazyDecoder->frameIsFullyReceivedAtIndex(1)); |
309 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1)); | 309 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1)); |
310 EXPECT_TRUE(m_actualDecoder); | 310 EXPECT_TRUE(m_actualDecoder); |
311 | 311 |
312 m_frameCount = 3; | 312 m_frameCount = 3; |
313 m_frameDuration = 30; | 313 m_frameDuration = 30; |
314 m_status = ImageFrame::FrameComplete; | 314 m_status = ImageFrame::FrameComplete; |
315 m_lazyDecoder->setData(*m_data, true); | 315 m_lazyDecoder->setData(*m_data, true); |
316 EXPECT_FALSE(m_actualDecoder); | 316 EXPECT_FALSE(m_actualDecoder); |
317 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0)); | 317 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0)); |
318 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(1)); | 318 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(1)); |
319 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(2)); | 319 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(2)); |
320 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0)); | 320 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0)); |
321 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1)); | 321 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1)); |
322 EXPECT_EQ(30.0f, m_lazyDecoder->frameDurationAtIndex(2)); | 322 EXPECT_EQ(30.0f, m_lazyDecoder->frameDurationAtIndex(2)); |
323 EXPECT_EQ(10, m_lazyDecoder->repetitionCount()); | 323 EXPECT_EQ(10, m_lazyDecoder->repetitionCount()); |
324 } | 324 } |
325 | 325 |
326 TEST_F(DeferredImageDecoderTest, decodedSize) | 326 TEST_F(DeferredImageDecoderTest, decodedSize) |
327 { | 327 { |
328 m_decodedSize = IntSize(22, 33); | 328 m_decodedSize = IntSize(22, 33); |
329 m_lazyDecoder->setData(*m_data, true); | 329 m_lazyDecoder->setData(*m_data, true); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 m_lazyDecoder->createFrameAtIndex(0); | 402 m_lazyDecoder->createFrameAtIndex(0); |
403 m_lazyDecoder->createFrameAtIndex(1); | 403 m_lazyDecoder->createFrameAtIndex(1); |
404 m_lazyDecoder->setData(*m_data, true); | 404 m_lazyDecoder->setData(*m_data, true); |
405 // Clears only the first frame (0 bytes). If DeferredImageDecoder doesn't | 405 // Clears only the first frame (0 bytes). If DeferredImageDecoder doesn't |
406 // check with the actual decoder it reports 4 bytes instead. | 406 // check with the actual decoder it reports 4 bytes instead. |
407 size_t frameBytesCleared = m_lazyDecoder->clearCacheExceptFrame(1); | 407 size_t frameBytesCleared = m_lazyDecoder->clearCacheExceptFrame(1); |
408 EXPECT_EQ(static_cast<size_t>(0), frameBytesCleared); | 408 EXPECT_EQ(static_cast<size_t>(0), frameBytesCleared); |
409 } | 409 } |
410 | 410 |
411 } // namespace blink | 411 } // namespace blink |
OLD | NEW |