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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 SkPicture* picture; | 90 SkPicture* picture; |
91 }; | 91 }; |
92 | 92 |
93 } // namespace | 93 } // namespace |
94 | 94 |
95 class DeferredImageDecoderTest : public ::testing::Test, public MockImageDecoder
Client { | 95 class DeferredImageDecoderTest : public ::testing::Test, public MockImageDecoder
Client { |
96 public: | 96 public: |
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); | |
101 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG)); | 100 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG)); |
102 m_frameCount = 1; | 101 m_frameCount = 1; |
103 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this); | 102 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this); |
104 m_actualDecoder = decoder.get(); | 103 m_actualDecoder = decoder.get(); |
105 m_actualDecoder->setSize(1, 1); | 104 m_actualDecoder->setSize(1, 1); |
106 m_lazyDecoder = DeferredImageDecoder::createForTesting(std::move(decoder
)); | 105 m_lazyDecoder = DeferredImageDecoder::createForTesting(std::move(decoder
)); |
107 m_surface = SkSurface::MakeRasterN32Premul(100, 100); | 106 m_surface = SkSurface::MakeRasterN32Premul(100, 100); |
108 ASSERT_TRUE(m_surface.get()); | 107 ASSERT_TRUE(m_surface.get()); |
109 m_decodeRequestCount = 0; | 108 m_decodeRequestCount = 0; |
110 m_repetitionCount = cAnimationNone; | 109 m_repetitionCount = cAnimationNone; |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 m_lazyDecoder->createFrameAtIndex(0); | 401 m_lazyDecoder->createFrameAtIndex(0); |
403 m_lazyDecoder->createFrameAtIndex(1); | 402 m_lazyDecoder->createFrameAtIndex(1); |
404 m_lazyDecoder->setData(*m_data, true); | 403 m_lazyDecoder->setData(*m_data, true); |
405 // Clears only the first frame (0 bytes). If DeferredImageDecoder doesn't | 404 // Clears only the first frame (0 bytes). If DeferredImageDecoder doesn't |
406 // check with the actual decoder it reports 4 bytes instead. | 405 // check with the actual decoder it reports 4 bytes instead. |
407 size_t frameBytesCleared = m_lazyDecoder->clearCacheExceptFrame(1); | 406 size_t frameBytesCleared = m_lazyDecoder->clearCacheExceptFrame(1); |
408 EXPECT_EQ(static_cast<size_t>(0), frameBytesCleared); | 407 EXPECT_EQ(static_cast<size_t>(0), frameBytesCleared); |
409 } | 408 } |
410 | 409 |
411 } // namespace blink | 410 } // namespace blink |
OLD | NEW |