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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 void SetUp() override | 97 void SetUp() override |
98 { | 98 { |
99 ImageDecodingStore::instance().setCacheLimitInBytes(1024 * 1024); | 99 ImageDecodingStore::instance().setCacheLimitInBytes(1024 * 1024); |
100 DeferredImageDecoder::setEnabled(true); | 100 DeferredImageDecoder::setEnabled(true); |
101 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG)); | 101 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG)); |
102 m_frameCount = 1; | 102 m_frameCount = 1; |
103 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this); | 103 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this); |
104 m_actualDecoder = decoder.get(); | 104 m_actualDecoder = decoder.get(); |
105 m_actualDecoder->setSize(1, 1); | 105 m_actualDecoder->setSize(1, 1); |
106 m_lazyDecoder = DeferredImageDecoder::createForTesting(decoder.release()
); | 106 m_lazyDecoder = DeferredImageDecoder::createForTesting(decoder.release()
); |
107 m_surface.reset(SkSurface::NewRasterN32Premul(100, 100)); | 107 m_surface = SkSurface::MakeRasterN32Premul(100, 100); |
108 ASSERT_TRUE(m_surface.get()); | 108 ASSERT_TRUE(m_surface.get()); |
109 m_decodeRequestCount = 0; | 109 m_decodeRequestCount = 0; |
110 m_repetitionCount = cAnimationNone; | 110 m_repetitionCount = cAnimationNone; |
111 m_status = ImageFrame::FrameComplete; | 111 m_status = ImageFrame::FrameComplete; |
112 m_frameDuration = 0; | 112 m_frameDuration = 0; |
113 m_decodedSize = m_actualDecoder->size(); | 113 m_decodedSize = m_actualDecoder->size(); |
114 } | 114 } |
115 | 115 |
116 void TearDown() override | 116 void TearDown() override |
117 { | 117 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 155 |
156 protected: | 156 protected: |
157 void useMockImageDecoderFactory() | 157 void useMockImageDecoderFactory() |
158 { | 158 { |
159 m_lazyDecoder->frameGenerator()->setImageDecoderFactory(MockImageDecoder
Factory::create(this, m_decodedSize)); | 159 m_lazyDecoder->frameGenerator()->setImageDecoderFactory(MockImageDecoder
Factory::create(this, m_decodedSize)); |
160 } | 160 } |
161 | 161 |
162 // Don't own this but saves the pointer to query states. | 162 // Don't own this but saves the pointer to query states. |
163 MockImageDecoder* m_actualDecoder; | 163 MockImageDecoder* m_actualDecoder; |
164 OwnPtr<DeferredImageDecoder> m_lazyDecoder; | 164 OwnPtr<DeferredImageDecoder> m_lazyDecoder; |
165 SkAutoTUnref<SkSurface> m_surface; | 165 sk_sp<SkSurface> m_surface; |
166 int m_decodeRequestCount; | 166 int m_decodeRequestCount; |
167 RefPtr<SharedBuffer> m_data; | 167 RefPtr<SharedBuffer> m_data; |
168 size_t m_frameCount; | 168 size_t m_frameCount; |
169 int m_repetitionCount; | 169 int m_repetitionCount; |
170 ImageFrame::Status m_status; | 170 ImageFrame::Status m_status; |
171 float m_frameDuration; | 171 float m_frameDuration; |
172 IntSize m_decodedSize; | 172 IntSize m_decodedSize; |
173 }; | 173 }; |
174 | 174 |
175 TEST_F(DeferredImageDecoderTest, drawIntoSkPicture) | 175 TEST_F(DeferredImageDecoderTest, drawIntoSkPicture) |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 m_lazyDecoder->createFrameAtIndex(0); | 402 m_lazyDecoder->createFrameAtIndex(0); |
403 m_lazyDecoder->createFrameAtIndex(1); | 403 m_lazyDecoder->createFrameAtIndex(1); |
404 m_lazyDecoder->setData(*m_data, true); | 404 m_lazyDecoder->setData(*m_data, true); |
405 // Clears only the first frame (0 bytes). If DeferredImageDecoder doesn't | 405 // Clears only the first frame (0 bytes). If DeferredImageDecoder doesn't |
406 // check with the actual decoder it reports 4 bytes instead. | 406 // check with the actual decoder it reports 4 bytes instead. |
407 size_t frameBytesCleared = m_lazyDecoder->clearCacheExceptFrame(1); | 407 size_t frameBytesCleared = m_lazyDecoder->clearCacheExceptFrame(1); |
408 EXPECT_EQ(static_cast<size_t>(0), frameBytesCleared); | 408 EXPECT_EQ(static_cast<size_t>(0), frameBytesCleared); |
409 } | 409 } |
410 | 410 |
411 } // namespace blink | 411 } // namespace blink |
OLD | NEW |