From 14aacd5825bcbeca10326f52612bbc2fdb298485 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 18 May 2017 14:11:29 -0400 Subject: Adding fm2js embedder tests This Cl adds the basis of the test framework to execute the javascript produced by CXFA_FM2JSContext and verify the results are correct. Change-Id: Ie46625b7e27ca0808e9cc41fdc00b7c0a212837d Reviewed-on: https://pdfium-review.googlesource.com/5651 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- testing/xfa_js_embedder_test.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 testing/xfa_js_embedder_test.h (limited to 'testing/xfa_js_embedder_test.h') diff --git a/testing/xfa_js_embedder_test.h b/testing/xfa_js_embedder_test.h new file mode 100644 index 0000000000..62c3597b07 --- /dev/null +++ b/testing/xfa_js_embedder_test.h @@ -0,0 +1,41 @@ +// Copyright 2017 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_XFA_JS_EMBEDDER_TEST_H_ +#define TESTING_XFA_JS_EMBEDDER_TEST_H_ + +#include +#include + +#include "fxjs/cfxjse_value.h" +#include "fxjs/fxjs_v8.h" +#include "testing/embedder_test.h" + +class CXFA_ScriptContext; + +class XFAJSEmbedderTest : public EmbedderTest { + public: + XFAJSEmbedderTest(); + ~XFAJSEmbedderTest() override; + + void SetUp() override; + void TearDown() override; + + bool OpenDocument(const std::string& filename, + const char* password = nullptr, + bool must_linearize = false) override; + + v8::Isolate* GetIsolate() const { return isolate_; } + + bool Execute(const CFX_ByteStringC& input); + CFXJSE_Value* GetValue() const { return value_.get(); } + + private: + std::unique_ptr array_buffer_allocator_; + std::unique_ptr value_; + v8::Isolate* isolate_; + CXFA_ScriptContext* script_context_; +}; + +#endif // TESTING_XFA_JS_EMBEDDER_TEST_H_ -- cgit v1.2.3