Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Unified Diff: src/test/test-utils.h

Issue 540823002: Refactor common unit test code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixes Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/test/test.gyp ('k') | src/test/test-utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/test/test-utils.h
diff --git a/src/test/test-utils.h b/src/test/test-utils.h
new file mode 100644
index 0000000000000000000000000000000000000000..05d1ea641de8093847e024b8c42408a0b0fbda9e
--- /dev/null
+++ b/src/test/test-utils.h
@@ -0,0 +1,86 @@
+// Copyright 2014 the V8 project 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 V8_TEST_TEST_UTILS_H_
+#define V8_TEST_TEST_UTILS_H_
+
+#include "include/v8.h"
+#include "src/base/macros.h"
+#include "src/zone.h"
+#include "testing/gtest-support.h"
+
+namespace v8 {
+
+class TestWithIsolate : public ::testing::Test {
+ public:
+ TestWithIsolate();
+ virtual ~TestWithIsolate();
+
+ Isolate* isolate() const { return isolate_; }
+
+ static void SetUpTestCase();
+ static void TearDownTestCase();
+
+ private:
+ static Isolate* isolate_;
+ Isolate::Scope isolate_scope_;
+ HandleScope handle_scope_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestWithIsolate);
+};
+
+
+class TestWithContext : public virtual TestWithIsolate {
+ public:
+ TestWithContext();
+ virtual ~TestWithContext();
+
+ const Local<Context>& context() const { return context_; }
+
+ private:
+ Local<Context> context_;
+ Context::Scope context_scope_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestWithContext);
+};
+
+
+namespace internal {
+
+// Forward declarations.
+class Factory;
+
+
+class TestWithIsolate : public virtual ::v8::TestWithIsolate {
+ public:
+ TestWithIsolate() {}
+ virtual ~TestWithIsolate();
+
+ Factory* factory() const;
+ Isolate* isolate() const {
+ return reinterpret_cast<Isolate*>(::v8::TestWithIsolate::isolate());
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestWithIsolate);
+};
+
+
+class TestWithZone : public TestWithIsolate {
+ public:
+ TestWithZone() : zone_(isolate()) {}
+ virtual ~TestWithZone();
+
+ Zone* zone() { return &zone_; }
+
+ private:
+ Zone zone_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestWithZone);
+};
+
+} // namespace internal
+} // namespace v8
+
+#endif // V8_TEST_TEST_UTILS_H_
« no previous file with comments | « src/test/test.gyp ('k') | src/test/test-utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698