summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-04-10 10:29:21 -0700
committerTom Sepez <tsepez@chromium.org>2015-04-10 10:29:21 -0700
commite45a2e4ff91a672d555951963e329cf224d486d6 (patch)
tree353b4c06efb5b34c929486cab81f7709be5a4123
parentea18d0b4bdb7e993f3c78b83493e3dac9acc4a44 (diff)
downloadpdfium-e45a2e4ff91a672d555951963e329cf224d486d6.tar.xz
Don't call FPDF_InitLibrary() in individual unit_tests.
The initialization sequence becomes more complicated as v8 evolves and when we move to XFA (where pdfium_unittests are currently broken). Centralize this initialization in a few places, like the embedder_test framework and the pdfium_test binary, and convert tests that require it into embedder_tests rather than unit_tests. Change on master first before moving to XFA. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1071343002
-rw-r--r--BUILD.gn2
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp (renamed from core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_unittest.cpp)14
-rw-r--r--pdfium.gyp2
3 files changed, 9 insertions, 9 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 0dcd459fb6..240401acf9 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -844,7 +844,6 @@ static_library("formfiller") {
test("pdfium_unittests") {
sources = [
- "core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_unittest.cpp",
"core/src/fxcodec/codec/fx_codec_jpx_unittest.cpp",
"core/src/fxcrt/fx_basic_bstring_unittest.cpp",
"core/src/fxcrt/fx_basic_wstring_unittest.cpp",
@@ -866,6 +865,7 @@ test("pdfium_unittests") {
test("pdfium_embeddertests") {
sources = [
+ "core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp",
"core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_embeddertest.cpp",
"fpdfsdk/src/fpdf_dataavail_embeddertest.cpp",
"fpdfsdk/src/fpdfdoc_embeddertest.cpp",
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_unittest.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp
index 18196a19a0..2769f3c14f 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_unittest.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp
@@ -7,10 +7,14 @@
#include "../../../../fpdfsdk/include/fpdfview.h"
#include "../../../../testing/fx_string_testhelpers.h"
-#include "../../../include/fxcrt/fx_basic.h"
#include "../../../include/fpdfapi/fpdf_parser.h"
+#include "../../../include/fxcrt/fx_basic.h"
+#include "../../../testing/embedder_test.h"
#include "testing/gtest/include/gtest/gtest.h"
+class FPDFParserDecodeEmbeddertest : public EmbedderTest {
+};
+
// NOTE: python's zlib.compress() and zlib.decompress() may be useful for
// external validation of the FlateEncode/FlateDecode test cases.
@@ -18,7 +22,7 @@
{ (const unsigned char*)input_literal, sizeof(input_literal) - 1, \
(const unsigned char*)expected_literal, sizeof(expected_literal) - 1 }
-TEST(ParserDecode, FlateEncode) {
+TEST_F(FPDFParserDecodeEmbeddertest, FlateEncode) {
struct FlateEncodeCase {
const unsigned char* input;
unsigned int input_size;
@@ -42,7 +46,6 @@ TEST(ParserDecode, FlateEncode) {
),
};
- FPDF_InitLibrary();
for (size_t i = 0; i < FX_ArraySize(flate_encode_cases); ++i) {
FlateEncodeCase* ptr = &flate_encode_cases[i];
unsigned char* result;
@@ -52,10 +55,9 @@ TEST(ParserDecode, FlateEncode) {
std::string((const char*)result, result_size))
<< " for case " << i;
}
- FPDF_DestroyLibrary();
}
-TEST(ParserDecode, FlateDecode) {
+TEST_F(FPDFParserDecodeEmbeddertest, FlateDecode) {
struct FlateDecodeCase {
const unsigned char* input;
unsigned int input_size;
@@ -81,7 +83,6 @@ TEST(ParserDecode, FlateDecode) {
),
};
- FPDF_InitLibrary();
for (size_t i = 0; i < FX_ArraySize(flate_decode_cases); ++i) {
FlateDecodeCase* ptr = &flate_decode_cases[i];
unsigned char* result;
@@ -91,7 +92,6 @@ TEST(ParserDecode, FlateDecode) {
std::string((const char*)result, result_size))
<< " for case " << i;
}
- FPDF_DestroyLibrary();
}
diff --git a/pdfium.gyp b/pdfium.gyp
index 264b6e8e45..f258e15729 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -835,7 +835,6 @@
'<(DEPTH)'
],
'sources': [
- 'core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_unittest.cpp',
'core/src/fxcodec/codec/fx_codec_jpx_unittest.cpp',
'core/src/fxcrt/fx_basic_bstring_unittest.cpp',
'core/src/fxcrt/fx_basic_wstring_unittest.cpp',
@@ -855,6 +854,7 @@
'<(DEPTH)'
],
'sources': [
+ 'core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp',
'core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_embeddertest.cpp',
'fpdfsdk/src/fpdf_dataavail_embeddertest.cpp',
'fpdfsdk/src/fpdfdoc_embeddertest.cpp',