test_launcher.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
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 3// found in the LICENSE file. 4 5#ifndef CONTENT_PUBLIC_TEST_TEST_LAUNCHER_H_ 6#define CONTENT_PUBLIC_TEST_TEST_LAUNCHER_H_ 7 8#include <string> 9 10#include "base/basictypes.h" 11#include "base/compiler_specific.h" 12 13namespace base { 14class CommandLine; 15class FilePath; 16class RunLoop; 17} 18 19namespace content { 20class ContentMainDelegate; 21 22extern const char kEmptyTestName[]; 23extern const char kHelpFlag[]; 24extern const char kLaunchAsBrowser[]; 25extern const char kRunManualTestsFlag[]; 26extern const char kSingleProcessTestsFlag[]; 27 28// Flag that causes only the kEmptyTestName test to be run. 29extern const char kWarmupFlag[]; 30 31class TestLauncherDelegate { 32 public: 33 virtual int RunTestSuite(int argc, char** argv) = 0; 34 virtual bool AdjustChildProcessCommandLine( 35 base::CommandLine* command_line, 36 const base::FilePath& temp_data_dir) = 0; 37 virtual void PreRunMessageLoop(base::RunLoop* run_loop) {} 38 virtual void PostRunMessageLoop() {} 39 virtual ContentMainDelegate* CreateContentMainDelegate() = 0; 40 41 // Allows a TestLauncherDelegate to adjust the number of |default_jobs| used 42 // when --test-launcher-jobs isn't specified on the command-line. 43 virtual void AdjustDefaultParallelJobs(int* default_jobs) {} 44 45 protected: 46 virtual ~TestLauncherDelegate(); 47}; 48 49// Launches tests using |launcher_delegate|. |default_jobs| is number 50// of test jobs to be run in parallel, unless overridden from the command line. 51// Returns exit code. 52int LaunchTests(TestLauncherDelegate* launcher_delegate, 53 int default_jobs, 54 int argc, 55 char** argv) WARN_UNUSED_RESULT; 56 57TestLauncherDelegate* GetCurrentTestLauncherDelegate(); 58 59} // namespace content 60 61#endif // CONTENT_PUBLIC_TEST_TEST_LAUNCHER_H_ 62