Home | History | Annotate | Download | only in testing
      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"
     14 #include "xfa/fxfa/parser/cxfa_document.h"
     15 #include "xfa/fxfa/parser/cxfa_node.h"
     16 #include "xfa/fxfa/parser/cxfa_object.h"
     17 
     18 class CFXJSE_Engine;
     19 
     20 class XFAJSEmbedderTest : public EmbedderTest {
     21  public:
     22   XFAJSEmbedderTest();
     23   ~XFAJSEmbedderTest() override;
     24 
     25   // EmbedderTest:
     26   void SetUp() override;
     27   void TearDown() override;
     28   bool OpenDocumentWithOptions(const std::string& filename,
     29                                const char* password,
     30                                bool must_linearize) override;
     31 
     32   v8::Isolate* GetIsolate() const { return isolate_; }
     33   CXFA_Document* GetXFADocument();
     34 
     35   bool Execute(const ByteStringView& input);
     36   bool ExecuteSilenceFailure(const ByteStringView& input);
     37 
     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_ = nullptr;
     44   CFXJSE_Engine* script_context_ = nullptr;
     45 
     46   bool ExecuteHelper(const ByteStringView& input);
     47 };
     48 
     49 #endif  // TESTING_XFA_JS_EMBEDDER_TEST_H_
     50