1 // Copyright (c) 2013 Intel Corporation. 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.
5 #include "base/command_line.h"
6 #include "base/file_util.h"
7 #include "base/files/file_path.h"
8 #include "base/logging.h"
9 #include "base/memory/linked_ptr.h"
10 #include "base/process/launch.h"
11 #include "base/run_loop.h"
12 #include "base/strings/string_util.h"
13 #include "base/sys_info.h"
14 #include "base/test/test_file_util.h"
15 #include "content/public/app/content_main.h"
16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/common/content_switches.h"
18 #include "content/public/test/test_launcher.h"
19 #include "xwalk/runtime/app/xwalk_main_delegate.h"
20 #include "xwalk/test/base/xwalk_test_suite.h"
22 class XWalkTestLauncherDelegate : public content::TestLauncherDelegate {
24 XWalkTestLauncherDelegate() {}
25 virtual ~XWalkTestLauncherDelegate() {}
27 virtual int RunTestSuite(int argc, char** argv) OVERRIDE {
28 return XWalkTestSuite(argc, argv).Run();
31 virtual bool AdjustChildProcessCommandLine(
32 CommandLine* command_line, const base::FilePath& temp_data_dir) OVERRIDE {
33 CommandLine new_command_line(command_line->GetProgram());
34 CommandLine::SwitchMap switches = command_line->GetSwitches();
36 for (CommandLine::SwitchMap::const_iterator iter = switches.begin();
37 iter != switches.end(); ++iter) {
38 new_command_line.AppendSwitchNative((*iter).first, (*iter).second);
41 // Expose the garbage collector interface, so we can test the object
42 // lifecycle tracker interface.
43 new_command_line.AppendSwitchASCII(
44 switches::kJavaScriptFlags, "--expose-gc");
46 *command_line = new_command_line;
51 virtual content::ContentMainDelegate* CreateContentMainDelegate() OVERRIDE {
52 #if defined(OS_WIN) || defined (OS_LINUX)
53 return new xwalk::XWalkMainDelegate();
55 // This delegate is only guaranteed to link on linux and windows, so just
56 // bail out if we are on any other platform.
63 DISALLOW_COPY_AND_ASSIGN(XWalkTestLauncherDelegate);
66 int main(int argc, char** argv) {
67 int default_jobs = std::max(1, base::SysInfo::NumberOfProcessors() / 2);
68 XWalkTestLauncherDelegate launcher_delegate;
69 return content::LaunchTests(&launcher_delegate, default_jobs, argc, argv);