blob: 055ed25ebffa3c776ad545188d3bb29828788b8a [file] [log] [blame]
// Copyright 2017 PDFium 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 "core/fxge/dib/cstretchengine.h"
#include <memory>
#include <utility>
#include "core/fpdfapi/page/cpdf_dib.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_number.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fxge/dib/fx_dib.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(CStretchEngine, OverflowInCtor) {
FX_RECT clip_rect;
RetainPtr<CPDF_Dictionary> dict_obj = pdfium::MakeRetain<CPDF_Dictionary>();
dict_obj->SetNewFor<CPDF_Number>("Width", 71000);
dict_obj->SetNewFor<CPDF_Number>("Height", 12500);
RetainPtr<CPDF_Stream> stream =
pdfium::MakeRetain<CPDF_Stream>(nullptr, 0, std::move(dict_obj));
auto dib_source = pdfium::MakeRetain<CPDF_DIB>();
dib_source->Load(nullptr, stream.Get());
CStretchEngine engine(nullptr, FXDIB_Format::k8bppRgb, 500, 500, clip_rect,
dib_source, FXDIB_ResampleOptions());
EXPECT_TRUE(engine.m_ResampleOptions.bInterpolateBilinear);
EXPECT_FALSE(engine.m_ResampleOptions.bHalftone);
EXPECT_FALSE(engine.m_ResampleOptions.bNoSmoothing);
EXPECT_FALSE(engine.m_ResampleOptions.bLossy);
}