V8 Project
test-utils.h
Go to the documentation of this file.
1 // Copyright 2014 the V8 project 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 V8_TEST_TEST_UTILS_H_
6 #define V8_TEST_TEST_UTILS_H_
7 
8 #include "include/v8.h"
9 #include "src/base/macros.h"
10 #include "src/zone.h"
11 #include "testing/gtest-support.h"
12 
13 namespace v8 {
14 
15 class TestWithIsolate : public ::testing::Test {
16  public:
18  virtual ~TestWithIsolate();
19 
20  Isolate* isolate() const { return isolate_; }
21 
22  static void SetUpTestCase();
23  static void TearDownTestCase();
24 
25  private:
26  static Isolate* isolate_;
29 
31 };
32 
33 
34 class TestWithContext : public virtual TestWithIsolate {
35  public:
37  virtual ~TestWithContext();
38 
39  const Local<Context>& context() const { return context_; }
40 
41  private:
44 
46 };
47 
48 
49 namespace internal {
50 
51 // Forward declarations.
52 class Factory;
53 
54 
55 class TestWithIsolate : public virtual ::v8::TestWithIsolate {
56  public:
58  virtual ~TestWithIsolate();
59 
60  Factory* factory() const;
61  Isolate* isolate() const {
62  return reinterpret_cast<Isolate*>(::v8::TestWithIsolate::isolate());
63  }
64 
65  private:
67 };
68 
69 
70 class TestWithZone : public TestWithIsolate {
71  public:
73  virtual ~TestWithZone();
74 
75  Zone* zone() { return &zone_; }
76 
77  private:
79 
81 };
82 
83 } // namespace internal
84 } // namespace v8
85 
86 #endif // V8_TEST_TEST_UTILS_H_
Stack-allocated class which sets the execution context for all operations executed within a local sco...
Definition: v8.h:5579
A stack-allocated class that governs a number of local handles.
Definition: v8.h:802
Stack-allocated class which sets the isolate for all operations executed within a local scope.
Definition: v8.h:4398
Isolate represents an isolated instance of the V8 engine.
Definition: v8.h:4356
A light-weight stack-allocated object handle.
Definition: v8.h:334
virtual ~TestWithContext()
Definition: test-utils.cc:44
Context::Scope context_scope_
Definition: test-utils.h:43
Local< Context > context_
Definition: test-utils.h:42
DISALLOW_COPY_AND_ASSIGN(TestWithContext)
const Local< Context > & context() const
Definition: test-utils.h:39
virtual ~TestWithIsolate()
Definition: test-utils.cc:19
Isolate::Scope isolate_scope_
Definition: test-utils.h:27
static void SetUpTestCase()
Definition: test-utils.cc:23
DISALLOW_COPY_AND_ASSIGN(TestWithIsolate)
static void TearDownTestCase()
Definition: test-utils.cc:32
static Isolate * isolate_
Definition: test-utils.h:26
HandleScope handle_scope_
Definition: test-utils.h:28
Isolate * isolate() const
Definition: test-utils.h:20
Isolate * isolate() const
Definition: test-utils.h:61
Factory * factory() const
Definition: test-utils.cc:52
DISALLOW_COPY_AND_ASSIGN(TestWithIsolate)
DISALLOW_COPY_AND_ASSIGN(TestWithZone)
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20