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

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: 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
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 scoped_ptr<gin::Gin> instance(new gin::Gin);
51 gin::Runner runner(delegate, instance->isolate());
50 gin::Runner::Scope scope(&runner); 52 gin::Runner::Scope scope(&runner);
51 runner.Run(source); 53 runner.Run(source);
52 54
53 message_loop.RunUntilIdle(); 55 message_loop.RunUntilIdle();
54 56
55 v8::Handle<v8::Value> result = runner.context()->Global()->Get( 57 {
56 StringToSymbol(runner.isolate(), "result")); 58 v8::Isolate::Scope isolate_scope(instance->isolate());
57 std::string result_string; 59 v8::HandleScope handle_scope(instance->isolate());
abarth-chromium 2013/11/19 15:49:21 We're still in the Runner's scope. I'm not sure t
jochen (gone - plz use gerrit) 2013/11/19 15:57:24 Right, I added this before I fixed Runner::Scope t
58 ASSERT_TRUE(ConvertFromV8(result, &result_string)); 60 v8::Handle<v8::Value> result = runner.context()->Global()->Get(
59 EXPECT_EQ("PASS", result_string); 61 StringToSymbol(runner.isolate(), "result"));
62 std::string result_string;
63 ASSERT_TRUE(ConvertFromV8(result, &result_string));
64 EXPECT_EQ("PASS", result_string);
65 }
60 } 66 }
61 67
62 } // namespace gin 68 } // namespace gin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698