Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / v8 / test / unittests / run-all-unittests.cc
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 #include "include/libplatform/libplatform.h"
6 #include "include/v8.h"
7 #include "src/base/compiler-specific.h"
8 #include "testing/gmock/include/gmock/gmock.h"
9
10 namespace {
11
12 class DefaultPlatformEnvironment FINAL : public ::testing::Environment {
13  public:
14   DefaultPlatformEnvironment() : platform_(NULL) {}
15   ~DefaultPlatformEnvironment() {}
16
17   virtual void SetUp() OVERRIDE {
18     EXPECT_EQ(NULL, platform_);
19     platform_ = v8::platform::CreateDefaultPlatform();
20     ASSERT_TRUE(platform_ != NULL);
21     v8::V8::InitializePlatform(platform_);
22     ASSERT_TRUE(v8::V8::Initialize());
23   }
24
25   virtual void TearDown() OVERRIDE {
26     ASSERT_TRUE(platform_ != NULL);
27     v8::V8::Dispose();
28     v8::V8::ShutdownPlatform();
29     delete platform_;
30     platform_ = NULL;
31   }
32
33  private:
34   v8::Platform* platform_;
35 };
36
37 }  // namespace
38
39
40 int main(int argc, char** argv) {
41   testing::InitGoogleMock(&argc, argv);
42   testing::AddGlobalTestEnvironment(new DefaultPlatformEnvironment);
43   v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
44   return RUN_ALL_TESTS();
45 }