OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "platform/graphics/BitmapImage.h" | 31 #include "platform/graphics/BitmapImage.h" |
32 | 32 |
33 #include "platform/SharedBuffer.h" | 33 #include "platform/SharedBuffer.h" |
34 #include "platform/graphics/DeferredImageDecoder.h" | 34 #include "platform/graphics/DeferredImageDecoder.h" |
35 #include "platform/graphics/ImageObserver.h" | 35 #include "platform/graphics/ImageObserver.h" |
36 #include "platform/testing/UnitTestHelpers.h" | 36 #include "platform/testing/UnitTestHelpers.h" |
37 #include "public/platform/Platform.h" | |
38 #include "public/platform/WebUnitTestSupport.h" | |
39 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
40 | 38 |
41 namespace blink { | 39 namespace blink { |
42 | 40 |
43 class BitmapImageTest : public ::testing::Test { | 41 class BitmapImageTest : public ::testing::Test { |
44 public: | 42 public: |
45 class FakeImageObserver : public ImageObserver { | 43 class FakeImageObserver : public ImageObserver { |
46 public: | 44 public: |
47 FakeImageObserver() : m_lastDecodedSizeChangedDelta(0) { } | 45 FakeImageObserver() : m_lastDecodedSizeChangedDelta(0) { } |
48 | 46 |
(...skipping 10 matching lines...) Expand all Loading... |
59 int m_lastDecodedSizeChangedDelta; | 57 int m_lastDecodedSizeChangedDelta; |
60 }; | 58 }; |
61 | 59 |
62 BitmapImageTest() : BitmapImageTest(false) { } | 60 BitmapImageTest() : BitmapImageTest(false) { } |
63 BitmapImageTest(bool enableDeferredDecoding) : m_enableDeferredDecoding(enab
leDeferredDecoding) { } | 61 BitmapImageTest(bool enableDeferredDecoding) : m_enableDeferredDecoding(enab
leDeferredDecoding) { } |
64 | 62 |
65 static PassRefPtr<SharedBuffer> readFile(const char* fileName) | 63 static PassRefPtr<SharedBuffer> readFile(const char* fileName) |
66 { | 64 { |
67 String filePath = testing::blinkRootDir(); | 65 String filePath = testing::blinkRootDir(); |
68 filePath.append(fileName); | 66 filePath.append(fileName); |
69 return Platform::current()->unitTestSupport()->readFromFile(filePath); | 67 return testing::readFromFile(filePath); |
70 } | 68 } |
71 | 69 |
72 // Accessors to BitmapImage's protected methods. | 70 // Accessors to BitmapImage's protected methods. |
73 void destroyDecodedData(bool destroyAll) { m_image->destroyDecodedData(destr
oyAll); } | 71 void destroyDecodedData(bool destroyAll) { m_image->destroyDecodedData(destr
oyAll); } |
74 size_t frameCount() { return m_image->frameCount(); } | 72 size_t frameCount() { return m_image->frameCount(); } |
75 void frameAtIndex(size_t index) | 73 void frameAtIndex(size_t index) |
76 { | 74 { |
77 m_image->frameAtIndex(index); | 75 m_image->frameAtIndex(index); |
78 } | 76 } |
79 void setCurrentFrame(size_t frame) { m_image->m_currentFrame = frame; } | 77 void setCurrentFrame(size_t frame) { m_image->m_currentFrame = frame; } |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 frameAtIndex(0); | 261 frameAtIndex(0); |
264 | 262 |
265 // Trying to destroy all data except an undecoded frame should go ahead and | 263 // Trying to destroy all data except an undecoded frame should go ahead and |
266 // destroy all other frames. | 264 // destroy all other frames. |
267 setCurrentFrame(2); | 265 setCurrentFrame(2); |
268 destroyDecodedData(false); | 266 destroyDecodedData(false); |
269 EXPECT_EQ(-frameSize * 2, m_imageObserver.m_lastDecodedSizeChangedDelta); | 267 EXPECT_EQ(-frameSize * 2, m_imageObserver.m_lastDecodedSizeChangedDelta); |
270 } | 268 } |
271 | 269 |
272 } // namespace blink | 270 } // namespace blink |
OLD | NEW |