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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoderTest.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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/image-decoders/png/PNGImageDecoder.h" 5 #include "platform/image-decoders/png/PNGImageDecoder.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "platform/image-decoders/ImageDecoderTestHelpers.h" 8 #include "platform/image-decoders/ImageDecoderTestHelpers.h"
9 #include "png.h" 9 #include "png.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 for (const auto& rec : g_recs) { 1000 for (const auto& rec : g_recs) {
1001 auto full_data = ReadFile(rec.name); 1001 auto full_data = ReadFile(rec.name);
1002 ASSERT_TRUE(full_data.Get()); 1002 ASSERT_TRUE(full_data.Get());
1003 1003
1004 // Create with enough data for part of the first frame. 1004 // Create with enough data for part of the first frame.
1005 auto decoder = CreateDecoder(); 1005 auto decoder = CreateDecoder();
1006 auto data = 1006 auto data =
1007 SharedBuffer::Create(full_data->Data(), rec.offset_in_first_frame); 1007 SharedBuffer::Create(full_data->Data(), rec.offset_in_first_frame);
1008 decoder->SetData(data.Get(), false); 1008 decoder->SetData(data.Get(), false);
1009 1009
1010 EXPECT_FALSE(decoder->FrameIsCompleteAtIndex(0)); 1010 EXPECT_FALSE(decoder->FrameIsReceivedAtIndex(0));
1011 1011
1012 // Parsing the size is not enough to mark the frame as complete. 1012 // Parsing the size is not enough to mark the frame as complete.
1013 EXPECT_TRUE(decoder->IsSizeAvailable()); 1013 EXPECT_TRUE(decoder->IsSizeAvailable());
1014 EXPECT_FALSE(decoder->FrameIsCompleteAtIndex(0)); 1014 EXPECT_FALSE(decoder->FrameIsReceivedAtIndex(0));
1015 1015
1016 const auto partial_frame_count = decoder->FrameCount(); 1016 const auto partial_frame_count = decoder->FrameCount();
1017 EXPECT_EQ(1u, partial_frame_count); 1017 EXPECT_EQ(1u, partial_frame_count);
1018 1018
1019 // Frame is not complete, even after decoding partially. 1019 // Frame is not complete, even after decoding partially.
1020 EXPECT_FALSE(decoder->FrameIsCompleteAtIndex(0)); 1020 EXPECT_FALSE(decoder->FrameIsReceivedAtIndex(0));
1021 auto* frame = decoder->FrameBufferAtIndex(0); 1021 auto* frame = decoder->FrameBufferAtIndex(0);
1022 ASSERT_TRUE(frame); 1022 ASSERT_TRUE(frame);
1023 EXPECT_NE(ImageFrame::kFrameComplete, frame->GetStatus()); 1023 EXPECT_NE(ImageFrame::kFrameComplete, frame->GetStatus());
1024 EXPECT_FALSE(decoder->FrameIsCompleteAtIndex(0)); 1024 EXPECT_FALSE(decoder->FrameIsReceivedAtIndex(0));
1025 1025
1026 decoder->SetData(full_data.Get(), true); 1026 decoder->SetData(full_data.Get(), true);
1027 1027
1028 // With full data, parsing the size still does not mark a frame as 1028 // With full data, parsing the size still does not mark a frame as
1029 // complete for animated images. 1029 // complete for animated images.
1030 EXPECT_TRUE(decoder->IsSizeAvailable()); 1030 EXPECT_TRUE(decoder->IsSizeAvailable());
1031 if (rec.expected_frame_count > 1) 1031 if (rec.expected_frame_count > 1)
1032 EXPECT_FALSE(decoder->FrameIsCompleteAtIndex(0)); 1032 EXPECT_FALSE(decoder->FrameIsReceivedAtIndex(0));
1033 else 1033 else
1034 EXPECT_TRUE(decoder->FrameIsCompleteAtIndex(0)); 1034 EXPECT_TRUE(decoder->FrameIsReceivedAtIndex(0));
1035 1035
1036 const auto frame_count = decoder->FrameCount(); 1036 const auto frame_count = decoder->FrameCount();
1037 ASSERT_EQ(rec.expected_frame_count, frame_count); 1037 ASSERT_EQ(rec.expected_frame_count, frame_count);
1038 1038
1039 // After parsing (the full file), all frames are complete. 1039 // After parsing (the full file), all frames are complete.
1040 for (size_t i = 0; i < frame_count; ++i) 1040 for (size_t i = 0; i < frame_count; ++i)
1041 EXPECT_TRUE(decoder->FrameIsCompleteAtIndex(i)); 1041 EXPECT_TRUE(decoder->FrameIsReceivedAtIndex(i));
1042 1042
1043 frame = decoder->FrameBufferAtIndex(0); 1043 frame = decoder->FrameBufferAtIndex(0);
1044 ASSERT_TRUE(frame); 1044 ASSERT_TRUE(frame);
1045 EXPECT_EQ(ImageFrame::kFrameComplete, frame->GetStatus()); 1045 EXPECT_EQ(ImageFrame::kFrameComplete, frame->GetStatus());
1046 EXPECT_TRUE(decoder->FrameIsCompleteAtIndex(0)); 1046 EXPECT_TRUE(decoder->FrameIsReceivedAtIndex(0));
1047 } 1047 }
1048 } 1048 }
1049 1049
1050 TEST(PNGTests, sizeMayOverflow) { 1050 TEST(PNGTests, sizeMayOverflow) {
1051 auto decoder = 1051 auto decoder =
1052 CreateDecoderWithPngData("/LayoutTests/images/resources/crbug702934.png"); 1052 CreateDecoderWithPngData("/LayoutTests/images/resources/crbug702934.png");
1053 EXPECT_FALSE(decoder->IsSizeAvailable()); 1053 EXPECT_FALSE(decoder->IsSizeAvailable());
1054 EXPECT_TRUE(decoder->Failed()); 1054 EXPECT_TRUE(decoder->Failed());
1055 } 1055 }
1056 1056
1057 }; // namespace blink 1057 }; // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698