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

Side by Side Diff: mojo/public/bindings/js/test/harness.cc

Issue 59153005: Begin implementing V8 bindings for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix skipped comment Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« gin/arguments.cc ('K') | « mojo/public/bindings/js/test/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // 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 "base/file_util.h"
6 #include "base/path_service.h"
7 #include "gin/converter.h"
8 #include "gin/runner.h"
9 #include "gin/test/gtest.h"
10 #include "mojo/public/bindings/js/runner_delegate.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 using v8::Isolate;
14 using v8::Object;
15 using v8::Script;
16 using v8::Value;
17
18 namespace mojo {
19 namespace js {
20 namespace {
21
22 class TestRunnerDelegate : public RunnerDelegate {
23 public:
24 virtual ~TestRunnerDelegate() {}
25
26 virtual v8::Handle<Object> CreateRootObject(
27 gin::Runner* runner) MOJO_OVERRIDE {
28 v8::Handle<Object> root = RunnerDelegate::CreateRootObject(runner);
29 root->Set(gin::StringToSymbol(runner->isolate(), "gtest"),
30 gin::GetGTestTemplate(runner->isolate())->NewInstance());
31 return root;
32 }
33 };
34
35 void RunTestFromFile(const base::FilePath& path) {
36 EXPECT_TRUE(base::PathExists(path)) << path.LossyDisplayName();
37 std::string source;
38 EXPECT_TRUE(ReadFileToString(path, &source));
39 Isolate* isolate = Isolate::GetCurrent();
40
41 TestRunnerDelegate delegate;
42 gin::Runner runner(&delegate, isolate);
43 gin::Runner::Scope scope(&runner);
44
45 v8::TryCatch try_catch;
46 runner.Run(Script::New(gin::StringToV8(isolate, source)));
47
48 EXPECT_FALSE(try_catch.HasCaught());
49 }
50
51 void RunTest(std::string test) {
52 base::FilePath path;
53 PathService::Get(base::DIR_SOURCE_ROOT, &path);
54 path = path.AppendASCII("mojo")
55 .AppendASCII("public")
56 .AppendASCII("bindings")
57 .AppendASCII("js")
58 .AppendASCII(test);
59 RunTestFromFile(path);
60 }
61
62 // TODO(abarth): Should we autogenerate these stubs from GYP?
63 TEST(Harness, mojo_unittests_js) {
64 RunTest("mojo_unittests.js");
65 }
66
67 } // namespace
68 } // namespace js
69 } // namespace mojo
OLDNEW
« gin/arguments.cc ('K') | « mojo/public/bindings/js/test/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698