summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-01-16 08:55:17 -0800
committerTom Sepez <tsepez@chromium.org>2015-01-16 08:55:17 -0800
commit74b91b279d0dee175c2e461ffa4fcc7fe5002a6e (patch)
tree7291f9199291a54fe4649627ccb5b7ad44a65b30 /testing
parent624b166d4f50874f93c6d0824e91cd5b955c0487 (diff)
downloadpdfium-74b91b279d0dee175c2e461ffa4fcc7fe5002a6e.tar.xz
Follow-on to pdfium_embeddertests.
This includes: - Fix TestLoader lifetime. - Rename test file to match the equivalent .cpp under test - Re-organize a few tests to avoid duplicate loading - add tests for a few additional functions. R=jam@chromium.org Review URL: https://codereview.chromium.org/857483005
Diffstat (limited to 'testing')
-rw-r--r--testing/basic_embeddertest.cpp19
-rw-r--r--testing/embedder_test.cpp8
-rw-r--r--testing/embedder_test.h4
3 files changed, 9 insertions, 22 deletions
diff --git a/testing/basic_embeddertest.cpp b/testing/basic_embeddertest.cpp
deleted file mode 100644
index 210fabd71a..0000000000
--- a/testing/basic_embeddertest.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) 2015 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 "embedder_test.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-class BasicEmbeddertest : public EmbedderTest {
-};
-
-TEST_F(BasicEmbeddertest, GetPageCount) {
- EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf"));
- EXPECT_EQ(1, GetPageCount());
-}
-
-TEST_F(BasicEmbeddertest, GetFirstPageNum) {
- EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf"));
- EXPECT_EQ(0, GetFirstPageNum());
-}
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index 7b8498345a..e823347ef1 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -195,6 +195,9 @@ void EmbedderTest::SetUp() {
void EmbedderTest::TearDown() {
FPDF_CloseDocument(document_);
FPDFAvail_Destroy(avail_);
+ if (loader_) {
+ delete loader_;
+ }
if (file_contents_) {
free(file_contents_);
}
@@ -206,11 +209,10 @@ bool EmbedderTest::OpenDocument(const std::string& filename) {
return false;
}
- TestLoader loader(file_contents_, file_length_);
-
+ loader_ = new TestLoader(file_contents_, file_length_);
file_access_.m_FileLen = static_cast<unsigned long>(file_length_);
file_access_.m_GetBlock = Get_Block;
- file_access_.m_Param = &loader;
+ file_access_.m_Param = loader_;
file_avail_.version = 1;
file_avail_.IsDataAvail = Is_Data_Avail;
diff --git a/testing/embedder_test.h b/testing/embedder_test.h
index b127eadbde..48ea415e19 100644
--- a/testing/embedder_test.h
+++ b/testing/embedder_test.h
@@ -14,6 +14,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "v8/include/v8.h"
+class TestLoader;
+
// This class is used to load a PDF document, and then run programatic
// API tests against it.
class EmbedderTest : public ::testing::Test {
@@ -21,6 +23,7 @@ class EmbedderTest : public ::testing::Test {
EmbedderTest() :
document_(nullptr),
avail_(nullptr),
+ loader_(nullptr),
file_length_(0),
file_contents_(nullptr) {
memset(&hints_, 0, sizeof(hints_));
@@ -70,6 +73,7 @@ class EmbedderTest : public ::testing::Test {
FX_FILEAVAIL file_avail_;
v8::StartupData natives_;
v8::StartupData snapshot_;
+ TestLoader* loader_;
size_t file_length_;
char* file_contents_;
};