| 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 SkImageInfo imageInfo() | 44 SkImageInfo imageInfo() |
| 45 { | 45 { |
| 46 return SkImageInfo::Make(100, 100, kBGRA_8888_SkColorType, kOpaque_SkAlphaTy
pe); | 46 return SkImageInfo::Make(100, 100, kBGRA_8888_SkColorType, kOpaque_SkAlphaTy
pe); |
| 47 } | 47 } |
| 48 | 48 |
| 49 } // namespace | 49 } // namespace |
| 50 | 50 |
| 51 class ImageFrameGeneratorTest : public ::testing::Test, public MockImageDecoderC
lient { | 51 class ImageFrameGeneratorTest : public ::testing::Test, public MockImageDecoderC
lient { |
| 52 public: | 52 public: |
| 53 virtual void SetUp() OVERRIDE | 53 virtual void SetUp() override |
| 54 { | 54 { |
| 55 ImageDecodingStore::instance()->setCacheLimitInBytes(1024 * 1024); | 55 ImageDecodingStore::instance()->setCacheLimitInBytes(1024 * 1024); |
| 56 m_data = SharedBuffer::create(); | 56 m_data = SharedBuffer::create(); |
| 57 m_generator = ImageFrameGenerator::create(fullSize(), m_data, false); | 57 m_generator = ImageFrameGenerator::create(fullSize(), m_data, false); |
| 58 useMockImageDecoderFactory(); | 58 useMockImageDecoderFactory(); |
| 59 m_decodersDestroyed = 0; | 59 m_decodersDestroyed = 0; |
| 60 m_frameBufferRequestCount = 0; | 60 m_frameBufferRequestCount = 0; |
| 61 m_status = ImageFrame::FrameEmpty; | 61 m_status = ImageFrame::FrameEmpty; |
| 62 } | 62 } |
| 63 | 63 |
| 64 virtual void TearDown() OVERRIDE | 64 virtual void TearDown() override |
| 65 { | 65 { |
| 66 ImageDecodingStore::instance()->clear(); | 66 ImageDecodingStore::instance()->clear(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 virtual void decoderBeingDestroyed() OVERRIDE | 69 virtual void decoderBeingDestroyed() override |
| 70 { | 70 { |
| 71 ++m_decodersDestroyed; | 71 ++m_decodersDestroyed; |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual void frameBufferRequested() OVERRIDE | 74 virtual void frameBufferRequested() override |
| 75 { | 75 { |
| 76 ++m_frameBufferRequestCount; | 76 ++m_frameBufferRequestCount; |
| 77 } | 77 } |
| 78 | 78 |
| 79 virtual ImageFrame::Status status() OVERRIDE | 79 virtual ImageFrame::Status status() override |
| 80 { | 80 { |
| 81 ImageFrame::Status currentStatus = m_status; | 81 ImageFrame::Status currentStatus = m_status; |
| 82 m_status = m_nextFrameStatus; | 82 m_status = m_nextFrameStatus; |
| 83 return currentStatus; | 83 return currentStatus; |
| 84 } | 84 } |
| 85 | 85 |
| 86 virtual size_t frameCount() OVERRIDE { return 1; } | 86 virtual size_t frameCount() override { return 1; } |
| 87 virtual int repetitionCount() const OVERRIDE { return cAnimationNone; } | 87 virtual int repetitionCount() const override { return cAnimationNone; } |
| 88 virtual float frameDuration() const OVERRIDE { return 0; } | 88 virtual float frameDuration() const override { return 0; } |
| 89 | 89 |
| 90 protected: | 90 protected: |
| 91 void useMockImageDecoderFactory() | 91 void useMockImageDecoderFactory() |
| 92 { | 92 { |
| 93 m_generator->setImageDecoderFactory(MockImageDecoderFactory::create(this
, fullSize())); | 93 m_generator->setImageDecoderFactory(MockImageDecoderFactory::create(this
, fullSize())); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void addNewData() | 96 void addNewData() |
| 97 { | 97 { |
| 98 m_data->append("g", 1); | 98 m_data->append("g", 1); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 static_cast<MockImageDecoder*>(tempDecoder)->setFrameHasAlpha(false); | 189 static_cast<MockImageDecoder*>(tempDecoder)->setFrameHasAlpha(false); |
| 190 ImageDecodingStore::instance()->unlockDecoder(m_generator.get(), tempDecoder
); | 190 ImageDecodingStore::instance()->unlockDecoder(m_generator.get(), tempDecoder
); |
| 191 | 191 |
| 192 setFrameStatus(ImageFrame::FrameComplete); | 192 setFrameStatus(ImageFrame::FrameComplete); |
| 193 m_generator->decodeAndScale(imageInfo(), 1, buffer, 100 * 4); | 193 m_generator->decodeAndScale(imageInfo(), 1, buffer, 100 * 4); |
| 194 EXPECT_EQ(2, m_frameBufferRequestCount); | 194 EXPECT_EQ(2, m_frameBufferRequestCount); |
| 195 EXPECT_FALSE(m_generator->hasAlpha(1)); | 195 EXPECT_FALSE(m_generator->hasAlpha(1)); |
| 196 } | 196 } |
| 197 | 197 |
| 198 } // namespace blink | 198 } // namespace blink |
| OLD | NEW |