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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageDecoderTest.cpp

Issue 2930513004: [WIP] Move ImageDecoders to SkCodec
Patch Set: Adding check for decoder creation Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageDecoderTest.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageDecoderTest.cpp b/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageDecoderTest.cpp
deleted file mode 100644
index 54e2148ed2beb6a120fbfe7780c59b4c40a725c0..0000000000000000000000000000000000000000
--- a/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageDecoderTest.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "platform/image-decoders/bmp/BMPImageDecoder.h"
-
-#include <memory>
-#include "platform/SharedBuffer.h"
-#include "platform/image-decoders/ImageDecoderTestHelpers.h"
-#include "platform/wtf/PtrUtil.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace blink {
-
-namespace {
-
-std::unique_ptr<ImageDecoder> CreateDecoder() {
- return WTF::WrapUnique(
- new BMPImageDecoder(ImageDecoder::kAlphaNotPremultiplied,
- ColorBehavior::TransformToTargetForTesting(),
- ImageDecoder::kNoDecodedImageByteLimit));
-}
-
-} // anonymous namespace
-
-TEST(BMPImageDecoderTest, isSizeAvailable) {
- const char* bmp_file = "/LayoutTests/images/resources/lenna.bmp"; // 256x256
- RefPtr<SharedBuffer> data = ReadFile(bmp_file);
- ASSERT_TRUE(data.Get());
-
- std::unique_ptr<ImageDecoder> decoder = CreateDecoder();
- decoder->SetData(data.Get(), true);
- EXPECT_TRUE(decoder->IsSizeAvailable());
- EXPECT_EQ(256, decoder->Size().Width());
- EXPECT_EQ(256, decoder->Size().Height());
-}
-
-TEST(BMPImageDecoderTest, parseAndDecode) {
- const char* bmp_file = "/LayoutTests/images/resources/lenna.bmp"; // 256x256
- RefPtr<SharedBuffer> data = ReadFile(bmp_file);
- ASSERT_TRUE(data.Get());
-
- std::unique_ptr<ImageDecoder> decoder = CreateDecoder();
- decoder->SetData(data.Get(), true);
-
- ImageFrame* frame = decoder->FrameBufferAtIndex(0);
- ASSERT_TRUE(frame);
- EXPECT_EQ(ImageFrame::kFrameComplete, frame->GetStatus());
- EXPECT_EQ(256, frame->Bitmap().width());
- EXPECT_EQ(256, frame->Bitmap().height());
- EXPECT_FALSE(decoder->Failed());
-}
-
-// Test if a BMP decoder returns a proper error while decoding an empty image.
-TEST(BMPImageDecoderTest, emptyImage) {
- const char* bmp_file = "/LayoutTests/images/resources/0x0.bmp"; // 0x0
- RefPtr<SharedBuffer> data = ReadFile(bmp_file);
- ASSERT_TRUE(data.Get());
-
- std::unique_ptr<ImageDecoder> decoder = CreateDecoder();
- decoder->SetData(data.Get(), true);
-
- ImageFrame* frame = decoder->FrameBufferAtIndex(0);
- ASSERT_TRUE(frame);
- EXPECT_EQ(ImageFrame::kFrameEmpty, frame->GetStatus());
- EXPECT_TRUE(decoder->Failed());
-}
-
-TEST(BMPImageDecoderTest, int32MinHeight) {
- const char* bmp_file =
- "/LayoutTests/images/resources/1xint32_min.bmp"; // 0xINT32_MIN
- RefPtr<SharedBuffer> data = ReadFile(bmp_file);
- std::unique_ptr<ImageDecoder> decoder = CreateDecoder();
- // Test when not all data is received.
- decoder->SetData(data.Get(), false);
- EXPECT_FALSE(decoder->IsSizeAvailable());
- EXPECT_TRUE(decoder->Failed());
-}
-
-// This test verifies that calling SharedBuffer::MergeSegmentsIntoBuffer() does
-// not break BMP decoding at a critical point: in between a call to decode the
-// size (when BMPImageDecoder stops while it may still have input data to
-// read) and a call to do a full decode.
-TEST(BMPImageDecoderTest, mergeBuffer) {
- const char* bmp_file = "/LayoutTests/images/resources/lenna.bmp";
- TestMergeBuffer(&CreateDecoder, bmp_file);
-}
-
-} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698