Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 1 | // Copyright 2017 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef TESTING_XFA_JS_EMBEDDER_TEST_H_ |
| 6 | #define TESTING_XFA_JS_EMBEDDER_TEST_H_ |
| 7 | |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 | |
| 11 | #include "fxjs/cfxjse_value.h" |
| 12 | #include "fxjs/fxjs_v8.h" |
| 13 | #include "testing/embedder_test.h" |
Dan Sinclair | 129b013 | 2017-05-24 09:33:20 -0400 | [diff] [blame] | 14 | #include "xfa/fxfa/parser/cxfa_document.h" |
| 15 | #include "xfa/fxfa/parser/cxfa_node.h" |
| 16 | #include "xfa/fxfa/parser/cxfa_object.h" |
Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 17 | |
| 18 | class CXFA_ScriptContext; |
| 19 | |
| 20 | class XFAJSEmbedderTest : public EmbedderTest { |
| 21 | public: |
| 22 | XFAJSEmbedderTest(); |
| 23 | ~XFAJSEmbedderTest() override; |
| 24 | |
| 25 | void SetUp() override; |
| 26 | void TearDown() override; |
| 27 | |
| 28 | bool OpenDocument(const std::string& filename, |
| 29 | const char* password = nullptr, |
| 30 | bool must_linearize = false) override; |
| 31 | |
| 32 | v8::Isolate* GetIsolate() const { return isolate_; } |
Dan Sinclair | 129b013 | 2017-05-24 09:33:20 -0400 | [diff] [blame] | 33 | CXFA_Document* GetXFADocument(); |
Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 34 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 35 | bool Execute(const ByteStringView& input); |
| 36 | bool ExecuteSilenceFailure(const ByteStringView& input); |
Ryan Harrison | 580c159 | 2017-06-29 10:43:53 -0400 | [diff] [blame] | 37 | |
Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 38 | CFXJSE_Value* GetValue() const { return value_.get(); } |
| 39 | |
| 40 | private: |
| 41 | std::unique_ptr<FXJS_ArrayBufferAllocator> array_buffer_allocator_; |
| 42 | std::unique_ptr<CFXJSE_Value> value_; |
| 43 | v8::Isolate* isolate_; |
| 44 | CXFA_ScriptContext* script_context_; |
Ryan Harrison | 580c159 | 2017-06-29 10:43:53 -0400 | [diff] [blame] | 45 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 46 | bool ExecuteHelper(const ByteStringView& input); |
Dan Sinclair | 14aacd5 | 2017-05-18 14:11:29 -0400 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | #endif // TESTING_XFA_JS_EMBEDDER_TEST_H_ |