5#include "fxbarcode/cfx_barcode.h"
11#include "core/fxcrt/fx_coordinates.h"
12#include "core/fxcrt/fx_string.h"
13#include "core/fxge/cfx_defaultrenderdevice.h"
14#include "core/fxge/cfx_renderdevice.h"
15#include "core/fxge/dib/cfx_dibitmap.h"
16#include "testing/gtest/include/gtest/gtest.h"
17#include "testing/utils/bitmap_saver.h"
18#include "testing/utils/hash.h"
25 auto device =
std::make_unique<CFX_DefaultRenderDevice>();
26 auto bitmap = pdfium::MakeRetain<CFX_DIBitmap>();
27 if (bitmap->Create(640, 480, FXDIB_Format::kRgb32))
30 ASSERT_TRUE(device->Attach(bitmap_));
31 device_ = std::move(device);
44 barcode_ = CFX_Barcode::Create(type);
45 barcode_->SetHeight(298);
46 barcode_->SetWidth(418);
49 bool RenderDevice() {
return barcode_->RenderDevice(device_.get(), matrix_); }
52 return GenerateMD5Base16(bitmap_->GetBuffer());
57 BitmapSaver::WriteBitmapToPng(bitmap_.Get(), filename);
68#if defined(PDF_USE_SKIA)
69#define MAYBE_Code39 DISABLED_Code39
71#define MAYBE_Code39 Code39
75 EXPECT_TRUE(barcode()->Encode(L"CLAMS"));
77 EXPECT_EQ(
"cd4cd3f36da38ff58d9f621827018903", BitmapChecksum());
81#if defined(PDF_USE_SKIA)
82#define MAYBE_CodaBar DISABLED_CodaBar
84#define MAYBE_CodaBar CodaBar
88 EXPECT_TRUE(barcode()->Encode(L"$123-456"));
90 EXPECT_EQ(
"5fad4fc19f099001a0fe83c89430c977", BitmapChecksum());
95 EXPECT_FALSE(barcode()->Encode(L"clams"));
99#if defined(PDF_USE_SKIA)
100#define MAYBE_Code128 DISABLED_Code128
102#define MAYBE_Code128 Code128
106 EXPECT_TRUE(barcode()->Encode(L"Clams"));
108 EXPECT_EQ(
"6351f0f6e997050e4658bbb4777aef74", BitmapChecksum());
112#if defined(PDF_USE_SKIA)
113#define MAYBE_Code128B DISABLED_Code128B
115#define MAYBE_Code128B Code128B
119 EXPECT_TRUE(barcode()->Encode(L"Clams"));
121 EXPECT_EQ(
"6351f0f6e997050e4658bbb4777aef74", BitmapChecksum());
125#if defined(PDF_USE_SKIA)
126#define MAYBE_Code128C DISABLED_Code128C
128#define MAYBE_Code128C Code128C
132 EXPECT_TRUE(barcode()->Encode(L"123456"));
134 EXPECT_EQ(
"fba730a807ba6363f9bd2bc7f8c56d1f", BitmapChecksum());
138#if defined(PDF_USE_SKIA)
139#define MAYBE_Code128CLetters DISABLED_Code128CLetters
141#define MAYBE_Code128CLetters Code128CLetters
145 EXPECT_TRUE(barcode()->Encode(L"clams"));
147 EXPECT_EQ(
"6284ec8503d5a948c9518108da33cdd3", BitmapChecksum());
151#if defined(PDF_USE_SKIA)
152#define MAYBE_Ean8 DISABLED_Ean8
154#define MAYBE_Ean8 Ean8
158 EXPECT_TRUE(barcode()->Encode(L"123456"));
160 EXPECT_EQ(
"aff88491ac46ca6217d780d185300cde", BitmapChecksum());
165 EXPECT_FALSE(barcode()->Encode(L"clams"));
169#if defined(PDF_USE_SKIA)
170#define MAYBE_UPCA DISABLED_UPCA
172#define MAYBE_UPCA UPCA
176 EXPECT_TRUE(barcode()->Encode(L"123456"));
178 EXPECT_EQ(
"fe26a5714cff7ffe3f9b02183efc435b", BitmapChecksum());
183 EXPECT_FALSE(barcode()->Encode(L"clams"));
187#if defined(PDF_USE_SKIA)
188#define MAYBE_Ean13 DISABLED_Ean13
190#define MAYBE_Ean13 Ean13
194 EXPECT_TRUE(barcode()->Encode(L"123456"));
196 EXPECT_EQ(
"72d2190b98d635c32834bf67552e561e", BitmapChecksum());
201 EXPECT_FALSE(barcode()->Encode(L"clams"));
205#if defined(PDF_USE_SKIA)
206#define MAYBE_Pdf417 DISABLED_Pdf417
208#define MAYBE_Pdf417 Pdf417
212 EXPECT_TRUE(barcode()->Encode(L"clams"));
214 EXPECT_EQ(
"191e35d11613901b7d5d51033689aa89", BitmapChecksum());
218#if defined(PDF_USE_SKIA)
219#define MAYBE_DataMatrix DISABLED_DataMatrix
221#define MAYBE_DataMatrix DataMatrix
225 EXPECT_TRUE(barcode()->Encode(L"clams"));
227 EXPECT_EQ(
"5e5cd9a680b86fcd4ffd53ed36e3c980", BitmapChecksum());
231#if defined(PDF_USE_SKIA)
232#define MAYBE_QrCode DISABLED_QrCode
234#define MAYBE_QrCode QrCode
238 EXPECT_TRUE(barcode()->Encode(L"clams"));
240 EXPECT_EQ(
"4751c6e0f67749fabe24f787128decee", BitmapChecksum());
void BC_Library_Destroy()
#define MAYBE_Code128CLetters
TEST_F(BarcodeTest, MAYBE_Code39)
std::string BitmapChecksum()
std::unique_ptr< CFX_Barcode > barcode_
CFX_Barcode * barcode() const
void SaveBitmap(const std::string &filename)
void Create(BC_TYPE type)
std::unique_ptr< CFX_RenderDevice > device_
RetainPtr< CFX_DIBitmap > bitmap_