OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <iostream> | 5 #include <iostream> |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/i18n/icu_util.h" | 11 #include "base/i18n/icu_util.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "sky/engine/public/web/WebRuntimeFeatures.h" |
14 #include "sky/shell/platform_view.h" | 15 #include "sky/shell/platform_view.h" |
15 #include "sky/shell/service_provider.h" | 16 #include "sky/shell/service_provider.h" |
16 #include "sky/shell/shell.h" | 17 #include "sky/shell/shell.h" |
17 #include "sky/shell/shell_view.h" | 18 #include "sky/shell/shell_view.h" |
18 #include "sky/shell/switches.h" | 19 #include "sky/shell/switches.h" |
19 #include "sky/shell/testing/test_runner.h" | 20 #include "sky/shell/testing/test_runner.h" |
20 | 21 |
21 namespace sky { | 22 namespace sky { |
22 namespace shell { | 23 namespace shell { |
23 namespace { | 24 namespace { |
24 | 25 |
25 void Usage() { | 26 void Usage() { |
26 std::cerr << "Usage: sky_shell" | 27 std::cerr << "Usage: sky_shell" |
| 28 << " --" << switches::kNonInteractive |
27 << " --" << switches::kPackageRoot << "=PACKAGE_ROOT" | 29 << " --" << switches::kPackageRoot << "=PACKAGE_ROOT" |
28 << " [ MAIN_DART ]" << std::endl; | 30 << " [ MAIN_DART ]" << std::endl; |
29 } | 31 } |
30 | 32 |
31 void Init() { | 33 void Init() { |
| 34 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); |
| 35 blink::WebRuntimeFeatures::enableObservatory( |
| 36 !command_line.HasSwitch(switches::kNonInteractive)); |
| 37 |
32 Shell::Init(make_scoped_ptr(new ServiceProviderContext( | 38 Shell::Init(make_scoped_ptr(new ServiceProviderContext( |
33 base::MessageLoop::current()->task_runner()))); | 39 base::MessageLoop::current()->task_runner()))); |
34 | 40 // Explicitly boot the shared test runner. |
35 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); | 41 TestRunner& runner = TestRunner::Shared(); |
36 | 42 |
37 std::string package_root = | 43 std::string package_root = |
38 command_line.GetSwitchValueASCII(switches::kPackageRoot); | 44 command_line.GetSwitchValueASCII(switches::kPackageRoot); |
39 | 45 |
40 std::string main; | 46 std::string main; |
41 auto args = command_line.GetArgs(); | 47 auto args = command_line.GetArgs(); |
42 if (!args.empty()) | 48 if (!args.empty()) |
43 main = args[0]; | 49 main = args[0]; |
44 | 50 |
45 TestRunner::Shared().set_package_root(package_root); | 51 runner.set_package_root(package_root); |
46 TestRunner::Shared().Start(main); | 52 runner.Start(main); |
47 } | 53 } |
48 | 54 |
49 } // namespace | 55 } // namespace |
50 } // namespace shell | 56 } // namespace shell |
51 } // namespace sky | 57 } // namespace sky |
52 | 58 |
53 int main(int argc, const char* argv[]) { | 59 int main(int argc, const char* argv[]) { |
54 base::AtExitManager exit_manager; | 60 base::AtExitManager exit_manager; |
55 base::CommandLine::Init(argc, argv); | 61 base::CommandLine::Init(argc, argv); |
56 | 62 |
57 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); | 63 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); |
58 | 64 |
59 if (command_line.HasSwitch(sky::shell::switches::kHelp) || | 65 if (command_line.HasSwitch(sky::shell::switches::kHelp) || |
60 !command_line.HasSwitch(sky::shell::switches::kPackageRoot)) { | 66 !command_line.HasSwitch(sky::shell::switches::kPackageRoot)) { |
61 sky::shell::Usage(); | 67 sky::shell::Usage(); |
62 return 0; | 68 return 0; |
63 } | 69 } |
64 | 70 |
65 base::MessageLoop message_loop; | 71 base::MessageLoop message_loop; |
66 | 72 |
67 base::i18n::InitializeICU(); | 73 base::i18n::InitializeICU(); |
68 | 74 |
69 message_loop.PostTask(FROM_HERE, base::Bind(&sky::shell::Init)); | 75 message_loop.PostTask(FROM_HERE, base::Bind(&sky::shell::Init)); |
70 message_loop.Run(); | 76 message_loop.Run(); |
71 | 77 |
72 return 0; | 78 return 0; |
73 } | 79 } |
OLD | NEW |