blob: 9c3c30ec73f12d1f766df81704c400e56595304f [file] [log] [blame]
[email protected]a22998a2013-11-10 05:00:501// Copyright 2013 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.
4
5#include "gin/runner.h"
6
7#include "base/compiler_specific.h"
8#include "gin/converter.h"
[email protected]f04b0e92013-11-22 14:20:559#include "gin/public/isolate_holder.h"
[email protected]a22998a2013-11-10 05:00:5010#include "testing/gtest/include/gtest/gtest.h"
11
[email protected]a22998a2013-11-10 05:00:5012using v8::Isolate;
13using v8::Object;
14using v8::Script;
15using v8::String;
16
17namespace gin {
[email protected]a22998a2013-11-10 05:00:5018
19TEST(RunnerTest, Run) {
[email protected]97f21ca2013-11-17 17:46:0720 std::string source = "this.result = 'PASS';\n";
[email protected]a22998a2013-11-10 05:00:5021
[email protected]f04b0e92013-11-22 14:20:5522 gin::IsolateHolder instance;
[email protected]1b93c232013-11-19 19:25:1223
[email protected]97f21ca2013-11-17 17:46:0724 RunnerDelegate delegate;
[email protected]1b93c232013-11-19 19:25:1225 Isolate* isolate = instance.isolate();
[email protected]a22998a2013-11-10 05:00:5026 Runner runner(&delegate, isolate);
27 Runner::Scope scope(&runner);
[email protected]97f21ca2013-11-17 17:46:0728 runner.Run(source);
[email protected]a22998a2013-11-10 05:00:5029
30 std::string result;
31 EXPECT_TRUE(Converter<std::string>::FromV8(
32 runner.global()->Get(StringToV8(isolate, "result")),
33 &result));
34 EXPECT_EQ("PASS", result);
35}
36
37} // namespace gin