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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 class BitmapImageTest : public ::testing::Test { | 44 class BitmapImageTest : public ::testing::Test { |
45 public: | 45 public: |
46 class FakeImageObserver : public ImageObserver { | 46 class FakeImageObserver : public ImageObserver { |
47 public: | 47 public: |
48 FakeImageObserver() : m_lastDecodedSizeChangedDelta(0) { } | 48 FakeImageObserver() : m_lastDecodedSizeChangedDelta(0) { } |
49 | 49 |
50 virtual void decodedSizeChanged(const Image*, int delta) | 50 virtual void decodedSizeChanged(const Image*, int delta) |
51 { | 51 { |
52 m_lastDecodedSizeChangedDelta = delta; | 52 m_lastDecodedSizeChangedDelta = delta; |
53 } | 53 } |
54 virtual void didDraw(const Image*) override { } | 54 void didDraw(const Image*) override { } |
55 virtual bool shouldPauseAnimation(const Image*) override { return false;
} | 55 bool shouldPauseAnimation(const Image*) override { return false; } |
56 virtual void animationAdvanced(const Image*) override { } | 56 void animationAdvanced(const Image*) override { } |
57 | 57 |
58 virtual void changedInRect(const Image*, const IntRect&) { } | 58 virtual void changedInRect(const Image*, const IntRect&) { } |
59 | 59 |
60 int m_lastDecodedSizeChangedDelta; | 60 int m_lastDecodedSizeChangedDelta; |
61 }; | 61 }; |
62 | 62 |
63 BitmapImageTest() : BitmapImageTest(false) { } | 63 BitmapImageTest() : BitmapImageTest(false) { } |
64 BitmapImageTest(bool enableDeferredDecoding) : m_enableDeferredDecoding(enab
leDeferredDecoding) { } | 64 BitmapImageTest(bool enableDeferredDecoding) : m_enableDeferredDecoding(enab
leDeferredDecoding) { } |
65 | 65 |
66 static PassRefPtr<SharedBuffer> readFile(const char* fileName) | 66 static PassRefPtr<SharedBuffer> readFile(const char* fileName) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 { | 115 { |
116 m_image->advanceAnimation(0); | 116 m_image->advanceAnimation(0); |
117 } | 117 } |
118 | 118 |
119 PassRefPtr<Image> imageForDefaultFrame() | 119 PassRefPtr<Image> imageForDefaultFrame() |
120 { | 120 { |
121 return m_image->imageForDefaultFrame(); | 121 return m_image->imageForDefaultFrame(); |
122 } | 122 } |
123 | 123 |
124 protected: | 124 protected: |
125 virtual void SetUp() override | 125 void SetUp() override |
126 { | 126 { |
127 DeferredImageDecoder::setEnabled(m_enableDeferredDecoding); | 127 DeferredImageDecoder::setEnabled(m_enableDeferredDecoding); |
128 m_image = BitmapImage::create(&m_imageObserver); | 128 m_image = BitmapImage::create(&m_imageObserver); |
129 } | 129 } |
130 | 130 |
131 FakeImageObserver m_imageObserver; | 131 FakeImageObserver m_imageObserver; |
132 RefPtr<BitmapImage> m_image; | 132 RefPtr<BitmapImage> m_image; |
133 | 133 |
134 private: | 134 private: |
135 bool m_enableDeferredDecoding; | 135 bool m_enableDeferredDecoding; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 frameAtIndex(0); | 265 frameAtIndex(0); |
266 | 266 |
267 // Trying to destroy all data except an undecoded frame should go ahead and | 267 // Trying to destroy all data except an undecoded frame should go ahead and |
268 // destroy all other frames. | 268 // destroy all other frames. |
269 setCurrentFrame(2); | 269 setCurrentFrame(2); |
270 destroyDecodedData(false); | 270 destroyDecodedData(false); |
271 EXPECT_EQ(-frameSize * 2, m_imageObserver.m_lastDecodedSizeChangedDelta); | 271 EXPECT_EQ(-frameSize * 2, m_imageObserver.m_lastDecodedSizeChangedDelta); |
272 } | 272 } |
273 | 273 |
274 } // namespace blink | 274 } // namespace blink |
OLD | NEW |