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

Side by Side Diff: gin/shell_runner_unittest.cc

Issue 2610473002: Use TaskScheduler instead of WorkerPool in v8_platform.cc. (Closed)
Patch Set: rebase Created 3 years, 10 months 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
« no previous file with comments | « gin/shell/gin_main.cc ('k') | gin/test/file_runner.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 2014 The Chromium Authors. All rights reserved. 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 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/shell_runner.h" 5 #include "gin/shell_runner.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/test/scoped_async_task_scheduler.h"
9 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
10 #include "gin/array_buffer.h" 11 #include "gin/array_buffer.h"
11 #include "gin/converter.h" 12 #include "gin/converter.h"
12 #include "gin/public/isolate_holder.h" 13 #include "gin/public/isolate_holder.h"
13 #include "gin/v8_initializer.h" 14 #include "gin/v8_initializer.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 17 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
17 #include "gin/public/isolate_holder.h" 18 #include "gin/public/isolate_holder.h"
18 #endif 19 #endif
19 20
20 using v8::Isolate; 21 using v8::Isolate;
21 using v8::Object; 22 using v8::Object;
22 using v8::Script; 23 using v8::Script;
23 using v8::String; 24 using v8::String;
24 25
25 namespace gin { 26 namespace gin {
26 27
27 TEST(RunnerTest, Run) { 28 TEST(RunnerTest, Run) {
28 base::MessageLoop message_loop; 29 base::MessageLoop message_loop;
30 base::test::ScopedAsyncTaskScheduler scoped_async_task_scheduler;
29 std::string source = "this.result = 'PASS';\n"; 31 std::string source = "this.result = 'PASS';\n";
30 32
31 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 33 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
32 gin::V8Initializer::LoadV8Snapshot(); 34 gin::V8Initializer::LoadV8Snapshot();
33 gin::V8Initializer::LoadV8Natives(); 35 gin::V8Initializer::LoadV8Natives();
34 #endif 36 #endif
35 37
36 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, 38 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
37 gin::IsolateHolder::kStableV8Extras, 39 gin::IsolateHolder::kStableV8Extras,
38 gin::ArrayBufferAllocator::SharedInstance()); 40 gin::ArrayBufferAllocator::SharedInstance());
39 gin::IsolateHolder instance(base::ThreadTaskRunnerHandle::Get()); 41 gin::IsolateHolder instance(base::ThreadTaskRunnerHandle::Get());
40 42
41 ShellRunnerDelegate delegate; 43 ShellRunnerDelegate delegate;
42 Isolate* isolate = instance.isolate(); 44 Isolate* isolate = instance.isolate();
43 ShellRunner runner(&delegate, isolate); 45 ShellRunner runner(&delegate, isolate);
44 Runner::Scope scope(&runner); 46 Runner::Scope scope(&runner);
45 runner.Run(source, "test_data.js"); 47 runner.Run(source, "test_data.js");
46 48
47 std::string result; 49 std::string result;
48 EXPECT_TRUE(Converter<std::string>::FromV8(isolate, 50 EXPECT_TRUE(Converter<std::string>::FromV8(isolate,
49 runner.global()->Get(StringToV8(isolate, "result")), 51 runner.global()->Get(StringToV8(isolate, "result")),
50 &result)); 52 &result));
51 EXPECT_EQ("PASS", result); 53 EXPECT_EQ("PASS", result);
52 } 54 }
53 55
54 } // namespace gin 56 } // namespace gin
OLDNEW
« no previous file with comments | « gin/shell/gin_main.cc ('k') | gin/test/file_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698