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/parser/cpdf_dictionary.h"
11 #include "core/fpdfapi/parser/cpdf_number.h"
12 #include "core/fpdfapi/parser/cpdf_stream.h"
13 #include "core/fpdfapi/render/cpdf_dibsource.h"
14 #include "core/fxcrt/fx_memory.h"
15 #include "core/fxge/fx_dib.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/base/ptr_util.h"
18
TEST(CStretchEngine,OverflowInCtor)19 TEST(CStretchEngine, OverflowInCtor) {
20 FX_RECT clip_rect;
21 std::unique_ptr<CPDF_Dictionary> dict_obj =
22 pdfium::MakeUnique<CPDF_Dictionary>();
23 dict_obj->SetNewFor<CPDF_Number>("Width", 71000);
24 dict_obj->SetNewFor<CPDF_Number>("Height", 12500);
25 std::unique_ptr<CPDF_Stream> stream =
26 pdfium::MakeUnique<CPDF_Stream>(nullptr, 0, std::move(dict_obj));
27 auto dib_source = pdfium::MakeRetain<CPDF_DIBSource>();
28 dib_source->Load(nullptr, stream.get());
29 CStretchEngine engine(nullptr, FXDIB_8bppRgb, 500, 500, clip_rect, dib_source,
30 0);
31 EXPECT_EQ(FXDIB_INTERPOL, engine.m_Flags);
32 }
33