| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 canvasBitmap.allocN32Pixels(100, 100); | 233 canvasBitmap.allocN32Pixels(100, 100); |
| 234 ASSERT_TRUE(m_surface->getCanvas()->readPixels(&canvasBitmap, 0, 0)); | 234 ASSERT_TRUE(m_surface->getCanvas()->readPixels(&canvasBitmap, 0, 0)); |
| 235 SkAutoLockPixels autoLock(canvasBitmap); | 235 SkAutoLockPixels autoLock(canvasBitmap); |
| 236 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0)); | 236 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0)); |
| 237 } | 237 } |
| 238 | 238 |
| 239 TEST_F(DeferredImageDecoderTest, singleFrameImageLoading) | 239 TEST_F(DeferredImageDecoderTest, singleFrameImageLoading) |
| 240 { | 240 { |
| 241 m_status = ImageFrame::FramePartial; | 241 m_status = ImageFrame::FramePartial; |
| 242 m_lazyDecoder->setData(*m_data, false); | 242 m_lazyDecoder->setData(*m_data, false); |
| 243 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0)); | 243 EXPECT_FALSE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0)); |
| 244 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0); | 244 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0); |
| 245 ASSERT_TRUE(image); | 245 ASSERT_TRUE(image); |
| 246 unsigned firstId = image->uniqueID(); | 246 unsigned firstId = image->uniqueID(); |
| 247 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0)); | 247 EXPECT_FALSE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0)); |
| 248 EXPECT_TRUE(m_actualDecoder); | 248 EXPECT_TRUE(m_actualDecoder); |
| 249 | 249 |
| 250 m_status = ImageFrame::FrameComplete; | 250 m_status = ImageFrame::FrameComplete; |
| 251 m_data->append(" ", 1u); | 251 m_data->append(" ", 1u); |
| 252 m_lazyDecoder->setData(*m_data, true); | 252 m_lazyDecoder->setData(*m_data, true); |
| 253 EXPECT_FALSE(m_actualDecoder); | 253 EXPECT_FALSE(m_actualDecoder); |
| 254 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0)); | 254 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0)); |
| 255 | 255 |
| 256 image = m_lazyDecoder->createFrameAtIndex(0); | 256 image = m_lazyDecoder->createFrameAtIndex(0); |
| 257 ASSERT_TRUE(image); | 257 ASSERT_TRUE(image); |
| 258 unsigned secondId = image->uniqueID(); | 258 unsigned secondId = image->uniqueID(); |
| 259 EXPECT_FALSE(m_decodeRequestCount); | 259 EXPECT_FALSE(m_decodeRequestCount); |
| 260 EXPECT_NE(firstId, secondId); | 260 EXPECT_NE(firstId, secondId); |
| 261 } | 261 } |
| 262 | 262 |
| 263 TEST_F(DeferredImageDecoderTest, multiFrameImageLoading) | 263 TEST_F(DeferredImageDecoderTest, multiFrameImageLoading) |
| 264 { | 264 { |
| 265 m_repetitionCount = 10; | 265 m_repetitionCount = 10; |
| 266 m_frameCount = 1; | 266 m_frameCount = 1; |
| 267 m_frameDuration = 10; | 267 m_frameDuration = 10; |
| 268 m_status = ImageFrame::FramePartial; | 268 m_status = ImageFrame::FramePartial; |
| 269 m_lazyDecoder->setData(*m_data, false); | 269 m_lazyDecoder->setData(*m_data, false); |
| 270 | 270 |
| 271 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0); | 271 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0); |
| 272 ASSERT_TRUE(image); | 272 ASSERT_TRUE(image); |
| 273 unsigned firstId = image->uniqueID(); | 273 unsigned firstId = image->uniqueID(); |
| 274 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0)); | 274 EXPECT_FALSE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0)); |
| 275 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0)); | 275 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0)); |
| 276 | 276 |
| 277 m_frameCount = 2; | 277 m_frameCount = 2; |
| 278 m_frameDuration = 20; | 278 m_frameDuration = 20; |
| 279 m_status = ImageFrame::FrameComplete; | 279 m_status = ImageFrame::FrameComplete; |
| 280 m_data->append(" ", 1u); | 280 m_data->append(" ", 1u); |
| 281 m_lazyDecoder->setData(*m_data, false); | 281 m_lazyDecoder->setData(*m_data, false); |
| 282 | 282 |
| 283 image = m_lazyDecoder->createFrameAtIndex(0); | 283 image = m_lazyDecoder->createFrameAtIndex(0); |
| 284 ASSERT_TRUE(image); | 284 ASSERT_TRUE(image); |
| 285 unsigned secondId = image->uniqueID(); | 285 unsigned secondId = image->uniqueID(); |
| 286 EXPECT_NE(firstId, secondId); | 286 EXPECT_NE(firstId, secondId); |
| 287 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0)); | 287 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0)); |
| 288 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(1)); | 288 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(1)); |
| 289 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1)); | 289 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1)); |
| 290 EXPECT_TRUE(m_actualDecoder); | 290 EXPECT_TRUE(m_actualDecoder); |
| 291 | 291 |
| 292 m_frameCount = 3; | 292 m_frameCount = 3; |
| 293 m_frameDuration = 30; | 293 m_frameDuration = 30; |
| 294 m_status = ImageFrame::FrameComplete; | 294 m_status = ImageFrame::FrameComplete; |
| 295 m_lazyDecoder->setData(*m_data, true); | 295 m_lazyDecoder->setData(*m_data, true); |
| 296 EXPECT_FALSE(m_actualDecoder); | 296 EXPECT_FALSE(m_actualDecoder); |
| 297 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0)); | 297 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(0)); |
| 298 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(1)); | 298 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(1)); |
| 299 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(2)); | 299 EXPECT_TRUE(m_lazyDecoder->frameIsFullyReceivedAtIndex(2)); |
| 300 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0)); | 300 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0)); |
| 301 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1)); | 301 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1)); |
| 302 EXPECT_EQ(30.0f, m_lazyDecoder->frameDurationAtIndex(2)); | 302 EXPECT_EQ(30.0f, m_lazyDecoder->frameDurationAtIndex(2)); |
| 303 EXPECT_EQ(10, m_lazyDecoder->repetitionCount()); | 303 EXPECT_EQ(10, m_lazyDecoder->repetitionCount()); |
| 304 } | 304 } |
| 305 | 305 |
| 306 TEST_F(DeferredImageDecoderTest, decodedSize) | 306 TEST_F(DeferredImageDecoderTest, decodedSize) |
| 307 { | 307 { |
| 308 m_decodedSize = IntSize(22, 33); | 308 m_decodedSize = IntSize(22, 33); |
| 309 m_lazyDecoder->setData(*m_data, true); | 309 m_lazyDecoder->setData(*m_data, true); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 // After decoding, the frame is known to be opaque. | 363 // After decoding, the frame is known to be opaque. |
| 364 frame = decoder->createFrameAtIndex(0); | 364 frame = decoder->createFrameAtIndex(0); |
| 365 ASSERT_TRUE(frame); | 365 ASSERT_TRUE(frame); |
| 366 EXPECT_TRUE(frame->isOpaque()); | 366 EXPECT_TRUE(frame->isOpaque()); |
| 367 | 367 |
| 368 // Re-generating the opaque-marked frame should not fail. | 368 // Re-generating the opaque-marked frame should not fail. |
| 369 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); | 369 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); |
| 370 } | 370 } |
| 371 | 371 |
| 372 } // namespace blink | 372 } // namespace blink |
| OLD | NEW |