Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(945)

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp

Issue 2982083002: FrameIsCompleteAtIndex to FrameIsReceivedAtIndex (Closed)
Patch Set: Update upstack from ImageDecoder Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 TEST(GIFImageDecoderTest, frameIsComplete) { 191 TEST(GIFImageDecoderTest, frameIsComplete) {
192 std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); 192 std::unique_ptr<ImageDecoder> decoder = CreateDecoder();
193 193
194 RefPtr<SharedBuffer> data = ReadFile(kLayoutTestResourcesDir, "animated.gif"); 194 RefPtr<SharedBuffer> data = ReadFile(kLayoutTestResourcesDir, "animated.gif");
195 ASSERT_TRUE(data.Get()); 195 ASSERT_TRUE(data.Get());
196 decoder->SetData(data.Get(), true); 196 decoder->SetData(data.Get(), true);
197 197
198 EXPECT_EQ(2u, decoder->FrameCount()); 198 EXPECT_EQ(2u, decoder->FrameCount());
199 EXPECT_FALSE(decoder->Failed()); 199 EXPECT_FALSE(decoder->Failed());
200 EXPECT_TRUE(decoder->FrameIsCompleteAtIndex(0)); 200 EXPECT_TRUE(decoder->FrameIsReceivedAtIndex(0));
201 EXPECT_TRUE(decoder->FrameIsCompleteAtIndex(1)); 201 EXPECT_TRUE(decoder->FrameIsReceivedAtIndex(1));
202 EXPECT_EQ(kAnimationLoopInfinite, decoder->RepetitionCount()); 202 EXPECT_EQ(kAnimationLoopInfinite, decoder->RepetitionCount());
203 } 203 }
204 204
205 TEST(GIFImageDecoderTest, frameIsCompleteLoading) { 205 TEST(GIFImageDecoderTest, frameIsCompleteLoading) {
206 std::unique_ptr<ImageDecoder> decoder = CreateDecoder(); 206 std::unique_ptr<ImageDecoder> decoder = CreateDecoder();
207 207
208 RefPtr<SharedBuffer> data_buffer = 208 RefPtr<SharedBuffer> data_buffer =
209 ReadFile(kLayoutTestResourcesDir, "animated.gif"); 209 ReadFile(kLayoutTestResourcesDir, "animated.gif");
210 ASSERT_TRUE(data_buffer.Get()); 210 ASSERT_TRUE(data_buffer.Get());
211 const Vector<char> data = data_buffer->Copy(); 211 const Vector<char> data = data_buffer->Copy();
212 212
213 ASSERT_GE(data.size(), 10u); 213 ASSERT_GE(data.size(), 10u);
214 RefPtr<SharedBuffer> temp_data = 214 RefPtr<SharedBuffer> temp_data =
215 SharedBuffer::Create(data.data(), data.size() - 10); 215 SharedBuffer::Create(data.data(), data.size() - 10);
216 decoder->SetData(temp_data.Get(), false); 216 decoder->SetData(temp_data.Get(), false);
217 217
218 EXPECT_EQ(2u, decoder->FrameCount()); 218 EXPECT_EQ(2u, decoder->FrameCount());
219 EXPECT_FALSE(decoder->Failed()); 219 EXPECT_FALSE(decoder->Failed());
220 EXPECT_TRUE(decoder->FrameIsCompleteAtIndex(0)); 220 EXPECT_TRUE(decoder->FrameIsReceivedAtIndex(0));
221 EXPECT_FALSE(decoder->FrameIsCompleteAtIndex(1)); 221 EXPECT_FALSE(decoder->FrameIsReceivedAtIndex(1));
222 222
223 decoder->SetData(data_buffer.Get(), true); 223 decoder->SetData(data_buffer.Get(), true);
224 EXPECT_EQ(2u, decoder->FrameCount()); 224 EXPECT_EQ(2u, decoder->FrameCount());
225 EXPECT_TRUE(decoder->FrameIsCompleteAtIndex(0)); 225 EXPECT_TRUE(decoder->FrameIsReceivedAtIndex(0));
226 EXPECT_TRUE(decoder->FrameIsCompleteAtIndex(1)); 226 EXPECT_TRUE(decoder->FrameIsReceivedAtIndex(1));
227 } 227 }
228 228
229 TEST(GIFImageDecoderTest, badTerminator) { 229 TEST(GIFImageDecoderTest, badTerminator) {
230 RefPtr<SharedBuffer> reference_data = 230 RefPtr<SharedBuffer> reference_data =
231 ReadFile(kDecodersTestingDir, "radient.gif"); 231 ReadFile(kDecodersTestingDir, "radient.gif");
232 RefPtr<SharedBuffer> test_data = 232 RefPtr<SharedBuffer> test_data =
233 ReadFile(kDecodersTestingDir, "radient-bad-terminator.gif"); 233 ReadFile(kDecodersTestingDir, "radient-bad-terminator.gif");
234 ASSERT_TRUE(reference_data.Get()); 234 ASSERT_TRUE(reference_data.Get());
235 ASSERT_TRUE(test_data.Get()); 235 ASSERT_TRUE(test_data.Get());
236 236
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 EXPECT_EQ(1u, decoder->FrameCount()); 436 EXPECT_EQ(1u, decoder->FrameCount());
437 ImageFrame* frame = decoder->FrameBufferAtIndex(0); 437 ImageFrame* frame = decoder->FrameBufferAtIndex(0);
438 decoder->SetMemoryAllocator(nullptr); 438 decoder->SetMemoryAllocator(nullptr);
439 439
440 ASSERT_TRUE(frame); 440 ASSERT_TRUE(frame);
441 EXPECT_EQ(IntRect(IntPoint(), decoder->Size()), frame->OriginalFrameRect()); 441 EXPECT_EQ(IntRect(IntPoint(), decoder->Size()), frame->OriginalFrameRect());
442 EXPECT_FALSE(frame->HasAlpha()); 442 EXPECT_FALSE(frame->HasAlpha());
443 } 443 }
444 444
445 } // namespace blink 445 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698