| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 bool match = true; | 234 bool match = true; |
| 235 for (size_t i = 0; i < truncatedHashes.size(); ++i) { | 235 for (size_t i = 0; i < truncatedHashes.size(); ++i) { |
| 236 if (truncatedHashes[i] != progressiveHashes[i]) { | 236 if (truncatedHashes[i] != progressiveHashes[i]) { |
| 237 match = false; | 237 match = false; |
| 238 break; | 238 break; |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 EXPECT_TRUE(match); | 241 EXPECT_TRUE(match); |
| 242 } | 242 } |
| 243 | 243 |
| 244 TEST(GIFImageDecoderTest, allDataReceivedTruncation) |
| 245 { |
| 246 OwnPtr<GIFImageDecoder> decoder(createDecoder()); |
| 247 |
| 248 RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/ani
mated.gif"); |
| 249 ASSERT_TRUE(data.get()); |
| 250 |
| 251 ASSERT_GE(data->size(), 10u); |
| 252 RefPtr<SharedBuffer> tempData = SharedBuffer::create(data->data(), data->siz
e() - 10); |
| 253 decoder->setData(tempData.get(), true); |
| 254 |
| 255 EXPECT_EQ(2u, decoder->frameCount()); |
| 256 EXPECT_FALSE(decoder->failed()); |
| 257 |
| 258 decoder->frameBufferAtIndex(0); |
| 259 EXPECT_FALSE(decoder->failed()); |
| 260 decoder->frameBufferAtIndex(1); |
| 261 EXPECT_TRUE(decoder->failed()); |
| 262 } |
| 263 |
| 264 TEST(GIFImageDecoderTest, frameIsComplete) |
| 265 { |
| 266 OwnPtr<GIFImageDecoder> decoder(createDecoder()); |
| 267 |
| 268 RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/ani
mated.gif"); |
| 269 ASSERT_TRUE(data.get()); |
| 270 decoder->setData(data.get(), true); |
| 271 |
| 272 EXPECT_EQ(2u, decoder->frameCount()); |
| 273 EXPECT_FALSE(decoder->failed()); |
| 274 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0)); |
| 275 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(1)); |
| 276 } |
| 277 |
| 278 TEST(GIFImageDecoderTest, frameIsCompleteLoading) |
| 279 { |
| 280 OwnPtr<GIFImageDecoder> decoder(createDecoder()); |
| 281 |
| 282 RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/ani
mated.gif"); |
| 283 ASSERT_TRUE(data.get()); |
| 284 |
| 285 ASSERT_GE(data->size(), 10u); |
| 286 RefPtr<SharedBuffer> tempData = SharedBuffer::create(data->data(), data->siz
e() - 10); |
| 287 decoder->setData(tempData.get(), false); |
| 288 |
| 289 EXPECT_EQ(2u, decoder->frameCount()); |
| 290 EXPECT_FALSE(decoder->failed()); |
| 291 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0)); |
| 292 EXPECT_FALSE(decoder->frameIsCompleteAtIndex(1)); |
| 293 |
| 294 decoder->setData(data.get(), true); |
| 295 EXPECT_EQ(2u, decoder->frameCount()); |
| 296 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0)); |
| 297 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(1)); |
| 298 } |
| 299 |
| 244 #endif | 300 #endif |
| 245 | 301 |
| 246 } // namespace | 302 } // namespace |
| OLD | NEW |