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

Side by Side Diff: gin/test/file_runner.cc

Issue 76353002: Introduce a Gin class instead of using global functions to control gin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates 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
« no previous file with comments | « gin/shell/gin_main.cc ('k') | gin/test/run_all_unittests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gin/test/file_runner.h" 5 #include "gin/test/file_runner.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "gin/converter.h" 10 #include "gin/converter.h"
11 #include "gin/gin.h"
11 #include "gin/modules/module_registry.h" 12 #include "gin/modules/module_registry.h"
12 #include "gin/test/gtest.h" 13 #include "gin/test/gtest.h"
13 #include "gin/try_catch.h" 14 #include "gin/try_catch.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace gin { 17 namespace gin {
17 18
18 namespace { 19 namespace {
19 20
20 base::FilePath GetModuleBase() { 21 base::FilePath GetModuleBase() {
(...skipping 18 matching lines...) Expand all
39 EXPECT_FALSE(try_catch.HasCaught()) << try_catch.GetPrettyMessage(); 40 EXPECT_FALSE(try_catch.HasCaught()) << try_catch.GetPrettyMessage();
40 } 41 }
41 42
42 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate) { 43 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate) {
43 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName(); 44 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName();
44 std::string source; 45 std::string source;
45 ASSERT_TRUE(ReadFileToString(path, &source)); 46 ASSERT_TRUE(ReadFileToString(path, &source));
46 47
47 base::MessageLoop message_loop; 48 base::MessageLoop message_loop;
48 49
49 gin::Runner runner(delegate, v8::Isolate::GetCurrent()); 50 gin::Gin instance;
50 gin::Runner::Scope scope(&runner); 51 gin::Runner runner(delegate, instance.isolate());
51 runner.Run(source); 52 {
53 gin::Runner::Scope scope(&runner);
54 runner.Run(source);
52 55
53 message_loop.RunUntilIdle(); 56 message_loop.RunUntilIdle();
54 57
55 v8::Handle<v8::Value> result = runner.context()->Global()->Get( 58 v8::Handle<v8::Value> result = runner.context()->Global()->Get(
56 StringToSymbol(runner.isolate(), "result")); 59 StringToSymbol(runner.isolate(), "result"));
57 std::string result_string; 60 std::string result_string;
58 ASSERT_TRUE(ConvertFromV8(result, &result_string)); 61 ASSERT_TRUE(ConvertFromV8(result, &result_string));
59 EXPECT_EQ("PASS", result_string); 62 EXPECT_EQ("PASS", result_string);
63 }
60 } 64 }
61 65
62 } // namespace gin 66 } // namespace gin
OLDNEW
« no previous file with comments | « gin/shell/gin_main.cc ('k') | gin/test/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698