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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 struct Rasterizer { | 65 struct Rasterizer { |
66 SkCanvas* canvas; | 66 SkCanvas* canvas; |
67 SkPicture* picture; | 67 SkPicture* picture; |
68 }; | 68 }; |
69 | 69 |
70 } // namespace | 70 } // namespace |
71 | 71 |
72 class DeferredImageDecoderTest : public ::testing::Test, public MockImageDecoder
Client { | 72 class DeferredImageDecoderTest : public ::testing::Test, public MockImageDecoder
Client { |
73 public: | 73 public: |
74 virtual void SetUp() override | 74 void SetUp() override |
75 { | 75 { |
76 ImageDecodingStore::instance().setCacheLimitInBytes(1024 * 1024); | 76 ImageDecodingStore::instance().setCacheLimitInBytes(1024 * 1024); |
77 DeferredImageDecoder::setEnabled(true); | 77 DeferredImageDecoder::setEnabled(true); |
78 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG)); | 78 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG)); |
79 m_frameCount = 1; | 79 m_frameCount = 1; |
80 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this); | 80 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this); |
81 m_actualDecoder = decoder.get(); | 81 m_actualDecoder = decoder.get(); |
82 m_actualDecoder->setSize(1, 1); | 82 m_actualDecoder->setSize(1, 1); |
83 m_lazyDecoder = DeferredImageDecoder::createForTesting(decoder.release()
); | 83 m_lazyDecoder = DeferredImageDecoder::createForTesting(decoder.release()
); |
84 m_surface.reset(SkSurface::NewRasterN32Premul(100, 100)); | 84 m_surface.reset(SkSurface::NewRasterN32Premul(100, 100)); |
85 ASSERT_TRUE(m_surface.get()); | 85 ASSERT_TRUE(m_surface.get()); |
86 m_decodeRequestCount = 0; | 86 m_decodeRequestCount = 0; |
87 m_repetitionCount = cAnimationNone; | 87 m_repetitionCount = cAnimationNone; |
88 m_status = ImageFrame::FrameComplete; | 88 m_status = ImageFrame::FrameComplete; |
89 m_frameDuration = 0; | 89 m_frameDuration = 0; |
90 m_decodedSize = m_actualDecoder->size(); | 90 m_decodedSize = m_actualDecoder->size(); |
91 } | 91 } |
92 | 92 |
93 virtual void TearDown() override | 93 void TearDown() override |
94 { | 94 { |
95 ImageDecodingStore::instance().clear(); | 95 ImageDecodingStore::instance().clear(); |
96 } | 96 } |
97 | 97 |
98 virtual void decoderBeingDestroyed() override | 98 void decoderBeingDestroyed() override |
99 { | 99 { |
100 m_actualDecoder = 0; | 100 m_actualDecoder = 0; |
101 } | 101 } |
102 | 102 |
103 virtual void decodeRequested() override | 103 void decodeRequested() override |
104 { | 104 { |
105 ++m_decodeRequestCount; | 105 ++m_decodeRequestCount; |
106 } | 106 } |
107 | 107 |
108 virtual size_t frameCount() override | 108 size_t frameCount() override |
109 { | 109 { |
110 return m_frameCount; | 110 return m_frameCount; |
111 } | 111 } |
112 | 112 |
113 virtual int repetitionCount() const override | 113 int repetitionCount() const override |
114 { | 114 { |
115 return m_repetitionCount; | 115 return m_repetitionCount; |
116 } | 116 } |
117 | 117 |
118 virtual ImageFrame::Status status() override | 118 ImageFrame::Status status() override |
119 { | 119 { |
120 return m_status; | 120 return m_status; |
121 } | 121 } |
122 | 122 |
123 virtual float frameDuration() const override | 123 float frameDuration() const override |
124 { | 124 { |
125 return m_frameDuration; | 125 return m_frameDuration; |
126 } | 126 } |
127 | 127 |
128 virtual IntSize decodedSize() const override | 128 IntSize decodedSize() const override |
129 { | 129 { |
130 return m_decodedSize; | 130 return m_decodedSize; |
131 } | 131 } |
132 | 132 |
133 protected: | 133 protected: |
134 void useMockImageDecoderFactory() | 134 void useMockImageDecoderFactory() |
135 { | 135 { |
136 m_lazyDecoder->frameGenerator()->setImageDecoderFactory(MockImageDecoder
Factory::create(this, m_decodedSize)); | 136 m_lazyDecoder->frameGenerator()->setImageDecoderFactory(MockImageDecoder
Factory::create(this, m_decodedSize)); |
137 } | 137 } |
138 | 138 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); | 330 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); |
331 m_frameCount = 2; | 331 m_frameCount = 2; |
332 m_lazyDecoder->setData(*m_data, false); | 332 m_lazyDecoder->setData(*m_data, false); |
333 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); | 333 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); |
334 m_frameCount = 0; | 334 m_frameCount = 0; |
335 m_lazyDecoder->setData(*m_data, true); | 335 m_lazyDecoder->setData(*m_data, true); |
336 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); | 336 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); |
337 } | 337 } |
338 | 338 |
339 } // namespace blink | 339 } // namespace blink |
OLD | NEW |