summaryrefslogtreecommitdiff
path: root/core/fxge/dib/fx_dib_engine_unittest.cpp
blob: 105c342a0fe3ed0037a1a101727da9eb8f4a8735 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2016 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 <memory>

#include "core/fpdfapi/fpdf_parser/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/cpdf_number.h"
#include "core/fpdfapi/fpdf_parser/cpdf_stream.h"
#include "core/fpdfapi/fpdf_render/render_int.h"
#include "core/fxcrt/fx_memory.h"
#include "core/fxge/dib/dib_int.h"
#include "core/fxge/fx_dib.h"
#include "testing/gtest/include/gtest/gtest.h"

TEST(CStretchEngine, OverflowInCtor) {
  FX_RECT clip_rect;
  std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> dict_obj(
      new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()));
  dict_obj->SetFor("Width", new CPDF_Number(71000));
  dict_obj->SetFor("Height", new CPDF_Number(12500));
  std::unique_ptr<CPDF_Stream, ReleaseDeleter<CPDF_Stream>> stream(
      new CPDF_Stream(nullptr, 0, dict_obj.release()));
  CPDF_DIBSource dib_source;
  dib_source.Load(nullptr, stream.get(), nullptr, nullptr, nullptr, nullptr,
                  false, 0, false);
  CStretchEngine engine(nullptr, FXDIB_8bppRgb, 500, 500, clip_rect,
                        &dib_source, 0);
  EXPECT_EQ(FXDIB_INTERPOL, engine.m_Flags);
}