Make parallelized run_corpus_tests.py handle ctrl-c.
[pdfium.git] / testing / embedder_test.h
index f490f82..fb3ea42 100644 (file)
 #include "../public/fpdf_ext.h"
 #include "../public/fpdf_formfill.h"
 #include "../public/fpdfview.h"
+#include "../third_party/base/nonstd_unique_ptr.h"
 #include "testing/gtest/include/gtest/gtest.h"
+
+#ifdef PDF_ENABLE_V8
 #include "v8/include/v8.h"
+#endif  // PDF_ENABLE_v8
 
 class TestLoader;
 
@@ -60,8 +64,15 @@ class EmbedderTest : public ::testing::Test,
   void SetUp() override;
   void TearDown() override;
 
+#ifdef PDF_ENABLE_V8
+  // Call before SetUp to pass shared isolate, otherwise PDFium creates one.
+  void SetExternalIsolate(void* isolate) {
+    external_isolate_ = static_cast<v8::Isolate*>(isolate);
+  }
+#endif  // PDF_ENABLE_V8
+
   void SetDelegate(Delegate* delegate) {
-    delegate_ = delegate ? delegate : default_delegate_;
+    delegate_ = delegate ? delegate : default_delegate_.get();
   }
 
   FPDF_DOCUMENT document() { return document_; }
@@ -94,16 +105,19 @@ class EmbedderTest : public ::testing::Test,
 
  protected:
   Delegate* delegate_;
-  Delegate* default_delegate_;
+  nonstd::unique_ptr<Delegate> default_delegate_;
   FPDF_DOCUMENT document_;
   FPDF_FORMHANDLE form_handle_;
   FPDF_AVAIL avail_;
   FX_DOWNLOADHINTS hints_;
   FPDF_FILEACCESS file_access_;
   FX_FILEAVAIL file_avail_;
+#ifdef PDF_ENABLE_V8
   v8::Platform* platform_;
   v8::StartupData natives_;
   v8::StartupData snapshot_;
+#endif  // PDF_ENABLE_V8
+  void* external_isolate_;
   TestLoader* loader_;
   size_t file_length_;
   char* file_contents_;