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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); | 399 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); |
400 | 400 |
401 setFrameStatus(ImageFrame::FrameEmpty); | 401 setFrameStatus(ImageFrame::FrameEmpty); |
402 setNextFrameStatus(ImageFrame::FrameComplete); | 402 setNextFrameStatus(ImageFrame::FrameComplete); |
403 EXPECT_FALSE(m_generator->decodeAndScale(fullSize(), 1)); | 403 EXPECT_FALSE(m_generator->decodeAndScale(fullSize(), 1)); |
404 } | 404 } |
405 | 405 |
406 TEST_F(ImageFrameGeneratorTest, frameHasAlpha) | 406 TEST_F(ImageFrameGeneratorTest, frameHasAlpha) |
407 { | 407 { |
408 setFrameStatus(ImageFrame::FramePartial); | 408 setFrameStatus(ImageFrame::FramePartial); |
409 ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator->
decodeAndScale(fullSize(), 0)); | 409 ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator->
decodeAndScale(fullSize(), 1)); |
410 EXPECT_TRUE(m_generator->hasAlpha(0)); | 410 EXPECT_TRUE(m_generator->hasAlpha(1)); |
411 | 411 |
412 ImageDecoder* tempDecoder = 0; | 412 ImageDecoder* tempDecoder = 0; |
413 EXPECT_TRUE(ImageDecodingStore::instance()->lockDecoder(m_generator.get(), f
ullSize(), &tempDecoder)); | 413 EXPECT_TRUE(ImageDecodingStore::instance()->lockDecoder(m_generator.get(), f
ullSize(), &tempDecoder)); |
414 ASSERT_TRUE(tempDecoder); | 414 ASSERT_TRUE(tempDecoder); |
415 static_cast<MockImageDecoder*>(tempDecoder)->setFrameHasAlpha(false); | 415 static_cast<MockImageDecoder*>(tempDecoder)->setFrameHasAlpha(false); |
416 ImageDecodingStore::instance()->unlockDecoder(m_generator.get(), tempDecoder
); | 416 ImageDecodingStore::instance()->unlockDecoder(m_generator.get(), tempDecoder
); |
417 | 417 |
418 setFrameStatus(ImageFrame::FrameComplete); | 418 setFrameStatus(ImageFrame::FrameComplete); |
419 ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator->
decodeAndScale(fullSize(), 0)); | 419 ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator->
decodeAndScale(fullSize(), 1)); |
420 EXPECT_FALSE(m_generator->hasAlpha(0)); | 420 EXPECT_FALSE(m_generator->hasAlpha(1)); |
421 } | 421 } |
422 | 422 |
423 namespace { | 423 namespace { |
424 | 424 |
425 class MockAllocator : public SkBitmap::Allocator { | 425 class MockAllocator : public SkBitmap::Allocator { |
426 public: | 426 public: |
427 // N starts from 0. | 427 // N starts from 0. |
428 MockAllocator(int failAtNthCall) | 428 MockAllocator(int failAtNthCall) |
429 : m_callCount(0) | 429 : m_callCount(0) |
430 , m_failAtNthCall(failAtNthCall) | 430 , m_failAtNthCall(failAtNthCall) |
(...skipping 30 matching lines...) Expand all Loading... |
461 // We have tested failures of all stages. This time all allocations | 461 // We have tested failures of all stages. This time all allocations |
462 // were successful. | 462 // were successful. |
463 EXPECT_TRUE(image); | 463 EXPECT_TRUE(image); |
464 break; | 464 break; |
465 } | 465 } |
466 EXPECT_FALSE(image); | 466 EXPECT_FALSE(image); |
467 } | 467 } |
468 } | 468 } |
469 | 469 |
470 } // namespace WebCore | 470 } // namespace WebCore |
OLD | NEW |