| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 } // namespace | 44 } // namespace |
| 45 | 45 |
| 46 class ImageFrameGeneratorTest : public ::testing::Test, public MockImageDecoderC
lient { | 46 class ImageFrameGeneratorTest : public ::testing::Test, public MockImageDecoderC
lient { |
| 47 public: | 47 public: |
| 48 virtual void SetUp() OVERRIDE | 48 virtual void SetUp() OVERRIDE |
| 49 { | 49 { |
| 50 ImageDecodingStore::initializeOnce(); | 50 ImageDecodingStore::initializeOnce(); |
| 51 ImageDecodingStore::instance()->setImageCachingEnabled(true); | 51 ImageDecodingStore::instance()->setImageCachingEnabled(true); |
| 52 m_data = SharedBuffer::create(); | 52 m_data = SharedBuffer::create(); |
| 53 m_generator = ImageFrameGenerator::create(fullSize(), m_data, true); | 53 m_generator = ImageFrameGenerator::create(fullSize(), m_data, false); |
| 54 useMockImageDecoderFactory(); | 54 useMockImageDecoderFactory(); |
| 55 m_decodersDestroyed = 0; | 55 m_decodersDestroyed = 0; |
| 56 m_frameBufferRequestCount = 0; | 56 m_frameBufferRequestCount = 0; |
| 57 m_status = ImageFrame::FrameEmpty; | 57 m_status = ImageFrame::FrameEmpty; |
| 58 } | 58 } |
| 59 | 59 |
| 60 virtual void TearDown() OVERRIDE | 60 virtual void TearDown() OVERRIDE |
| 61 { | 61 { |
| 62 ImageDecodingStore::shutdown(); | 62 ImageDecodingStore::shutdown(); |
| 63 } | 63 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 EXPECT_EQ(fullSize(), tempImage->scaledSize()); | 138 EXPECT_EQ(fullSize(), tempImage->scaledSize()); |
| 139 EXPECT_TRUE(m_generator->hasAlpha(0)); | 139 EXPECT_TRUE(m_generator->hasAlpha(0)); |
| 140 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); | 140 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); |
| 141 EXPECT_EQ(0, m_frameBufferRequestCount); | 141 EXPECT_EQ(0, m_frameBufferRequestCount); |
| 142 } | 142 } |
| 143 | 143 |
| 144 TEST_F(ImageFrameGeneratorTest, cacheMissWithIncompleteDecode) | 144 TEST_F(ImageFrameGeneratorTest, cacheMissWithIncompleteDecode) |
| 145 { | 145 { |
| 146 setFrameStatus(ImageFrame::FramePartial); | 146 setFrameStatus(ImageFrame::FramePartial); |
| 147 | 147 |
| 148 const ScaledImageFragment* tempImage= m_generator->decodeAndScale(fullSize()
); | 148 const ScaledImageFragment* tempImage = m_generator->decodeAndScale(fullSize(
)); |
| 149 EXPECT_FALSE(tempImage->isComplete()); | 149 EXPECT_FALSE(tempImage->isComplete()); |
| 150 EXPECT_EQ(1, m_frameBufferRequestCount); | 150 EXPECT_EQ(1, m_frameBufferRequestCount); |
| 151 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); | 151 ImageDecodingStore::instance()->unlockCache(m_generator.get(), tempImage); |
| 152 EXPECT_EQ(2, ImageDecodingStore::instance()->cacheEntries()); | 152 EXPECT_EQ(2, ImageDecodingStore::instance()->cacheEntries()); |
| 153 EXPECT_EQ(1, ImageDecodingStore::instance()->imageCacheEntries()); | 153 EXPECT_EQ(1, ImageDecodingStore::instance()->imageCacheEntries()); |
| 154 EXPECT_EQ(1, ImageDecodingStore::instance()->decoderCacheEntries()); | 154 EXPECT_EQ(1, ImageDecodingStore::instance()->decoderCacheEntries()); |
| 155 | 155 |
| 156 addNewData(); | 156 addNewData(); |
| 157 tempImage = m_generator->decodeAndScale(fullSize()); | 157 tempImage = m_generator->decodeAndScale(fullSize()); |
| 158 EXPECT_FALSE(tempImage->isComplete()); | 158 EXPECT_FALSE(tempImage->isComplete()); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 // We have tested failures of all stages. This time all allocations | 322 // We have tested failures of all stages. This time all allocations |
| 323 // were successful. | 323 // were successful. |
| 324 EXPECT_TRUE(image); | 324 EXPECT_TRUE(image); |
| 325 break; | 325 break; |
| 326 } | 326 } |
| 327 EXPECT_FALSE(image); | 327 EXPECT_FALSE(image); |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 | 330 |
| 331 } // namespace WebCore | 331 } // namespace WebCore |
| OLD | NEW |