Fix building NaCl in Linux component GN builds.
[chromium-blink-merge.git] / gin / shell_runner_unittest.cc
blob4e4b9c2fa9cff54374c6bfbd6b7a0a317fb3ea5e
1 // Copyright 2014 The Chromium 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.
5 #include "gin/shell_runner.h"
7 #include "base/compiler_specific.h"
8 #include "base/message_loop/message_loop.h"
9 #include "gin/array_buffer.h"
10 #include "gin/converter.h"
11 #include "gin/public/isolate_holder.h"
12 #include "gin/v8_initializer.h"
13 #include "testing/gtest/include/gtest/gtest.h"
15 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
16 #include "gin/public/isolate_holder.h"
17 #endif
19 using v8::Isolate;
20 using v8::Object;
21 using v8::Script;
22 using v8::String;
24 namespace gin {
26 TEST(RunnerTest, Run) {
27 base::MessageLoop message_loop;
28 std::string source = "this.result = 'PASS';\n";
30 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
31 gin::V8Initializer::LoadV8Snapshot();
32 #endif
34 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
35 gin::ArrayBufferAllocator::SharedInstance());
36 gin::IsolateHolder instance;
38 ShellRunnerDelegate delegate;
39 Isolate* isolate = instance.isolate();
40 ShellRunner runner(&delegate, isolate);
41 Runner::Scope scope(&runner);
42 runner.Run(source, "test_data.js");
44 std::string result;
45 EXPECT_TRUE(Converter<std::string>::FromV8(isolate,
46 runner.global()->Get(StringToV8(isolate, "result")),
47 &result));
48 EXPECT_EQ("PASS", result);
51 } // namespace gin