OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CONTENT_PUBLIC_TEST_TEST_LAUNCHER_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_TEST_LAUNCHER_H_ |
6 #define CONTENT_PUBLIC_TEST_TEST_LAUNCHER_H_ | 6 #define CONTENT_PUBLIC_TEST_TEST_LAUNCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/test/launcher/test_launcher.h" |
11 | 12 |
12 namespace base { | 13 namespace base { |
13 class CommandLine; | 14 class CommandLine; |
14 class FilePath; | 15 class FilePath; |
15 class RunLoop; | 16 class RunLoop; |
16 } | 17 } |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 class ContentMainDelegate; | 20 class ContentMainDelegate; |
20 struct ContentMainParams; | 21 struct ContentMainParams; |
21 | 22 |
22 extern const char kEmptyTestName[]; | 23 extern const char kEmptyTestName[]; |
23 extern const char kHelpFlag[]; | 24 extern const char kHelpFlag[]; |
24 extern const char kLaunchAsBrowser[]; | 25 extern const char kLaunchAsBrowser[]; |
25 extern const char kRunManualTestsFlag[]; | 26 extern const char kRunManualTestsFlag[]; |
26 extern const char kSingleProcessTestsFlag[]; | 27 extern const char kSingleProcessTestsFlag[]; |
27 | 28 |
28 // Flag that causes only the kEmptyTestName test to be run. | 29 // Flag that causes only the kEmptyTestName test to be run. |
29 extern const char kWarmupFlag[]; | 30 extern const char kWarmupFlag[]; |
30 | 31 |
| 32 // See details in PreRunTest(). |
| 33 class TestState { |
| 34 public: |
| 35 virtual ~TestState() {} |
| 36 |
| 37 // Called once test process has launched (and is still running). |
| 38 // NOTE: this is called on a background thread. |
| 39 virtual void ChildProcessLaunched(base::ProcessHandle handle, |
| 40 base::ProcessId pid) = 0; |
| 41 }; |
| 42 |
31 class TestLauncherDelegate { | 43 class TestLauncherDelegate { |
32 public: | 44 public: |
33 virtual int RunTestSuite(int argc, char** argv) = 0; | 45 virtual int RunTestSuite(int argc, char** argv) = 0; |
34 virtual bool AdjustChildProcessCommandLine( | 46 virtual bool AdjustChildProcessCommandLine( |
35 base::CommandLine* command_line, | 47 base::CommandLine* command_line, |
36 const base::FilePath& temp_data_dir) = 0; | 48 const base::FilePath& temp_data_dir) = 0; |
37 virtual void PreRunMessageLoop(base::RunLoop* run_loop) {} | 49 virtual void PreRunMessageLoop(base::RunLoop* run_loop) {} |
38 virtual void PostRunMessageLoop() {} | 50 virtual void PostRunMessageLoop() {} |
39 virtual ContentMainDelegate* CreateContentMainDelegate() = 0; | 51 virtual ContentMainDelegate* CreateContentMainDelegate() = 0; |
40 | 52 |
| 53 // Called prior to running each test. The delegate may alter the CommandLine |
| 54 // and options used to launch the subprocess. Additionally the client may |
| 55 // return a TestState that is destroyed once the test completes as well as |
| 56 // once the test process is launched. |
| 57 // |
| 58 // NOTE: this is not called if --single_process is supplied. |
| 59 virtual scoped_ptr<TestState> PreRunTest( |
| 60 base::CommandLine* command_line, |
| 61 base::TestLauncher::LaunchOptions* test_launch_options); |
| 62 |
41 // Allows a TestLauncherDelegate to adjust the number of |default_jobs| used | 63 // Allows a TestLauncherDelegate to adjust the number of |default_jobs| used |
42 // when --test-launcher-jobs isn't specified on the command-line. | 64 // when --test-launcher-jobs isn't specified on the command-line. |
43 virtual void AdjustDefaultParallelJobs(int* default_jobs) {} | 65 virtual void AdjustDefaultParallelJobs(int* default_jobs) {} |
44 | 66 |
45 protected: | 67 protected: |
46 virtual ~TestLauncherDelegate(); | 68 virtual ~TestLauncherDelegate(); |
47 }; | 69 }; |
48 | 70 |
49 // Launches tests using |launcher_delegate|. |default_jobs| is number | 71 // Launches tests using |launcher_delegate|. |default_jobs| is number |
50 // of test jobs to be run in parallel, unless overridden from the command line. | 72 // of test jobs to be run in parallel, unless overridden from the command line. |
51 // Returns exit code. | 73 // Returns exit code. |
52 int LaunchTests(TestLauncherDelegate* launcher_delegate, | 74 int LaunchTests(TestLauncherDelegate* launcher_delegate, |
53 int default_jobs, | 75 int default_jobs, |
54 int argc, | 76 int argc, |
55 char** argv) WARN_UNUSED_RESULT; | 77 char** argv) WARN_UNUSED_RESULT; |
56 | 78 |
57 TestLauncherDelegate* GetCurrentTestLauncherDelegate(); | 79 TestLauncherDelegate* GetCurrentTestLauncherDelegate(); |
58 ContentMainParams* GetContentMainParams(); | 80 ContentMainParams* GetContentMainParams(); |
59 | 81 |
60 } // namespace content | 82 } // namespace content |
61 | 83 |
62 #endif // CONTENT_PUBLIC_TEST_TEST_LAUNCHER_H_ | 84 #endif // CONTENT_PUBLIC_TEST_TEST_LAUNCHER_H_ |
OLD | NEW |