1 // Copyright 2017 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/fxge/dib/cstretchengine.h"
6
7 #include <memory>
8 #include <utility>
9
10 #include "core/fpdfapi/page/cpdf_dib.h"
11 #include "core/fpdfapi/parser/cpdf_dictionary.h"
12 #include "core/fpdfapi/parser/cpdf_number.h"
13 #include "core/fpdfapi/parser/cpdf_stream.h"
14 #include "core/fxge/fx_dib.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/base/ptr_util.h"
17
TEST(CStretchEngine,OverflowInCtor)18 TEST(CStretchEngine, OverflowInCtor) {
19 FX_RECT clip_rect;
20 RetainPtr<CPDF_Dictionary> dict_obj = pdfium::MakeRetain<CPDF_Dictionary>();
21 dict_obj->SetNewFor<CPDF_Number>("Width", 71000);
22 dict_obj->SetNewFor<CPDF_Number>("Height", 12500);
23 RetainPtr<CPDF_Stream> stream =
24 pdfium::MakeRetain<CPDF_Stream>(nullptr, 0, std::move(dict_obj));
25 auto dib_source = pdfium::MakeRetain<CPDF_DIB>();
26 dib_source->Load(nullptr, stream.Get());
27 CStretchEngine engine(nullptr, FXDIB_8bppRgb, 500, 500, clip_rect, dib_source,
28 FXDIB_ResampleOptions());
29 EXPECT_TRUE(engine.m_ResampleOptions.bInterpolateBilinear);
30 EXPECT_FALSE(engine.m_ResampleOptions.bInterpolateBicubic);
31 EXPECT_FALSE(engine.m_ResampleOptions.bHalftone);
32 EXPECT_FALSE(engine.m_ResampleOptions.bNoSmoothing);
33 EXPECT_FALSE(engine.m_ResampleOptions.bLossy);
34 }
35