summaryrefslogtreecommitdiff
path: root/testing/test_support.h
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-19 16:04:22 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-19 16:04:22 -0700
commitd831dc7147e9895185740f551fed7abe246e2adf (patch)
tree07e43e97c1c5534285ec81e670987aa8d3bdbd73 /testing/test_support.h
parent81d44cd970875542a0abb29b1838e88994c88299 (diff)
downloadpdfium-d831dc7147e9895185740f551fed7abe246e2adf.tar.xz
Merge to XFA: Consolidate test support code.
Original Review URL: https://codereview.chromium.org/1416713002 . (cherry picked from commit 6d34d056a7188b7ae9800fe3ceb68645e0442879) Conflicts: BUILD.gn samples/BUILD.gn samples/pdfium_test.cc samples/samples.gyp R=thestig@chromium.org Review URL: https://codereview.chromium.org/1413593003 .
Diffstat (limited to 'testing/test_support.h')
-rw-r--r--testing/test_support.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/testing/test_support.h b/testing/test_support.h
new file mode 100644
index 0000000000..1018421ba7
--- /dev/null
+++ b/testing/test_support.h
@@ -0,0 +1,44 @@
+// Copyright 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.
+
+#ifndef TESTING_EMBEDDER_TEST_SUPPORT_H_
+#define TESTING_EMBEDDER_TEST_SUPPORT_H_
+
+#include <stdlib.h>
+#include <string>
+
+#ifdef PDF_ENABLE_V8
+#include "v8/include/libplatform/libplatform.h"
+#include "v8/include/v8.h"
+#endif
+
+// Reads the entire contents of a file into a newly malloc'd buffer.
+char* GetFileContents(const char* filename, size_t* retlen);
+
+#ifdef PDF_ENABLE_V8
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+bool InitializeV8ForPDFium(const std::string& exe_path,
+ const std::string& bin_dir,
+ v8::StartupData* natives_blob,
+ v8::StartupData* snapshot_blob,
+ v8::Platform** platform);
+#else // V8_USE_EXTERNAL_STARTUP_DATA
+bool InitializeV8ForPDFium(v8::Platform** platform);
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
+#endif // PDF_ENABLE_V8
+
+class TestLoader {
+ public:
+ TestLoader(const char* pBuf, size_t len);
+ static int GetBlock(void* param,
+ unsigned long pos,
+ unsigned char* pBuf,
+ unsigned long size);
+
+ private:
+ const char* const m_pBuf;
+ const size_t m_Len;
+};
+
+#endif // TESTING_EMBEDDER_TEST_SUPPORT_H_