64 lines
2.0 KiB
C++
64 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <gtest/gtest.h>
|
|
#include <pdfengine/pdf_document.hpp>
|
|
#include <pdfengine/pdf_engine.hpp>
|
|
#include "parser/pdfium_document.hpp"
|
|
#include "fonts/pdf_fonts/encoding/cjk_collection_db.hpp"
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <thread>
|
|
#include <atomic>
|
|
#include <chrono>
|
|
#include "fonts/cache/glyph_cache.hpp"
|
|
#include "fonts/pdf_fonts/font.hpp"
|
|
#ifndef TEST_CORPUS_DIR
|
|
#define TEST_CORPUS_DIR "../../corpus"
|
|
#endif
|
|
|
|
namespace {
|
|
|
|
#define SKIP_IF_NO_PDFIUM() \
|
|
if (!pdfengine::engineHasPdfium()) { \
|
|
GTEST_SKIP() << "Skipping PDFium tests because PDFium is not linked."; \
|
|
}
|
|
|
|
std::filesystem::path getCorpusPath(const std::string& subfolder, const std::string& filename) {
|
|
return std::filesystem::path(TEST_CORPUS_DIR) / subfolder / filename;
|
|
}
|
|
|
|
std::vector<uint8_t> readFile(const std::filesystem::path& path) {
|
|
std::ifstream file(path, std::ios::binary | std::ios::ate);
|
|
if (!file.is_open()) {
|
|
return {};
|
|
}
|
|
std::streamsize size = file.tellg();
|
|
file.seekg(0, std::ios::beg);
|
|
std::vector<uint8_t> buffer(size);
|
|
if (file.read(reinterpret_cast<char*>(buffer.data()), size)) {
|
|
return buffer;
|
|
}
|
|
return {};
|
|
}
|
|
|
|
const std::vector<std::string> corpus_basic = {
|
|
"about_blank.pdf", "black.pdf", "clip_path.pdf", "dashed_lines.pdf",
|
|
"hello_world.pdf", "hello_world_2_pages.pdf", "many_rectangles.pdf",
|
|
"rectangles.pdf", "rectangles_multi_pages.pdf", "whitespace.pdf"
|
|
};
|
|
|
|
const std::vector<std::string> corpus_fonts = {
|
|
"latin_extended.pdf", "rotated_text.pdf", "rotated_text_90.pdf",
|
|
"text_font.pdf", "utf-8.pdf", "vertical_text.pdf", "hebrew_mirrored.pdf"
|
|
};
|
|
|
|
const std::vector<std::string> corpus_edge = {
|
|
"annots.pdf", "bookmarks.pdf", "combobox_form.pdf", "embedded_attachments.pdf",
|
|
"empty_xref.pdf", "encrypted.pdf", "linearized.pdf", "listbox_form.pdf",
|
|
"no_page_count.pdf", "page_labels.pdf", "text_form.pdf", "unsupported_feature.pdf",
|
|
"zero_length_stream.pdf"
|
|
};
|
|
|
|
} |