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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 for (size_t i = 0; i < decodedFramesCount(); ++i) | 108 for (size_t i = 0; i < decodedFramesCount(); ++i) |
109 size += frameDecodedSize(i); | 109 size += frameDecodedSize(i); |
110 return size; | 110 return size; |
111 } | 111 } |
112 | 112 |
113 void advanceAnimation() | 113 void advanceAnimation() |
114 { | 114 { |
115 m_image->advanceAnimation(0); | 115 m_image->advanceAnimation(0); |
116 } | 116 } |
117 | 117 |
| 118 int repetitionCount() |
| 119 { |
| 120 return m_image->repetitionCount(true); |
| 121 } |
| 122 |
| 123 int animationFinished() |
| 124 { |
| 125 return m_image->m_animationFinished; |
| 126 } |
| 127 |
118 PassRefPtr<Image> imageForDefaultFrame() | 128 PassRefPtr<Image> imageForDefaultFrame() |
119 { | 129 { |
120 return m_image->imageForDefaultFrame(); | 130 return m_image->imageForDefaultFrame(); |
121 } | 131 } |
122 | 132 |
123 protected: | 133 protected: |
124 void SetUp() override | 134 void SetUp() override |
125 { | 135 { |
126 DeferredImageDecoder::setEnabled(m_enableDeferredDecoding); | 136 DeferredImageDecoder::setEnabled(m_enableDeferredDecoding); |
127 m_imageObserver = adoptPtrWillBeNoop(new FakeImageObserver); | 137 m_imageObserver = adoptPtrWillBeNoop(new FakeImageObserver); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 TEST_F(BitmapImageTest, maybeAnimated) | 170 TEST_F(BitmapImageTest, maybeAnimated) |
161 { | 171 { |
162 loadImage("/LayoutTests/fast/images/resources/gif-loop-count.gif"); | 172 loadImage("/LayoutTests/fast/images/resources/gif-loop-count.gif"); |
163 for (size_t i = 0; i < frameCount(); ++i) { | 173 for (size_t i = 0; i < frameCount(); ++i) { |
164 EXPECT_TRUE(m_image->maybeAnimated()); | 174 EXPECT_TRUE(m_image->maybeAnimated()); |
165 advanceAnimation(); | 175 advanceAnimation(); |
166 } | 176 } |
167 EXPECT_FALSE(m_image->maybeAnimated()); | 177 EXPECT_FALSE(m_image->maybeAnimated()); |
168 } | 178 } |
169 | 179 |
| 180 TEST_F(BitmapImageTest, animationRepetitions) |
| 181 { |
| 182 loadImage("/LayoutTests/fast/images/resources/full2loop.gif"); |
| 183 int expectedRepetitionCount = 2; |
| 184 EXPECT_EQ(expectedRepetitionCount, repetitionCount()); |
| 185 |
| 186 // We actually loop once more than stored repetition count. |
| 187 for (int repeat = 0; repeat < expectedRepetitionCount + 1; ++repeat) { |
| 188 for (size_t i = 0; i < frameCount(); ++i) { |
| 189 EXPECT_FALSE(animationFinished()); |
| 190 advanceAnimation(); |
| 191 } |
| 192 } |
| 193 EXPECT_TRUE(animationFinished()); |
| 194 } |
| 195 |
170 TEST_F(BitmapImageTest, isAllDataReceived) | 196 TEST_F(BitmapImageTest, isAllDataReceived) |
171 { | 197 { |
172 RefPtr<SharedBuffer> imageData = readFile("/LayoutTests/fast/images/resource
s/green.jpg"); | 198 RefPtr<SharedBuffer> imageData = readFile("/LayoutTests/fast/images/resource
s/green.jpg"); |
173 ASSERT_TRUE(imageData.get()); | 199 ASSERT_TRUE(imageData.get()); |
174 | 200 |
175 RefPtr<BitmapImage> image = BitmapImage::create(); | 201 RefPtr<BitmapImage> image = BitmapImage::create(); |
176 EXPECT_FALSE(image->isAllDataReceived()); | 202 EXPECT_FALSE(image->isAllDataReceived()); |
177 | 203 |
178 image->setData(imageData, false); | 204 image->setData(imageData, false); |
179 EXPECT_FALSE(image->isAllDataReceived()); | 205 EXPECT_FALSE(image->isAllDataReceived()); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 frameAtIndex(0); | 307 frameAtIndex(0); |
282 | 308 |
283 // Trying to destroy all data except an undecoded frame should go ahead and | 309 // Trying to destroy all data except an undecoded frame should go ahead and |
284 // destroy all other frames. | 310 // destroy all other frames. |
285 setCurrentFrame(2); | 311 setCurrentFrame(2); |
286 destroyDecodedData(false); | 312 destroyDecodedData(false); |
287 EXPECT_EQ(-frameSize * 2, m_imageObserver->m_lastDecodedSizeChangedDelta); | 313 EXPECT_EQ(-frameSize * 2, m_imageObserver->m_lastDecodedSizeChangedDelta); |
288 } | 314 } |
289 | 315 |
290 } // namespace blink | 316 } // namespace blink |
OLD | NEW |