summaryrefslogtreecommitdiffstats
path: root/chrome/test/test_launcher/test_runner.h
blob: 07524b1d3fd2f623b3974759961c744599811b5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_TEST_TEST_LAUNCHER_TEST_RUNNER_H_
#define CHROME_TEST_TEST_LAUNCHER_TEST_RUNNER_H_
#pragma once

#include <string>
#include <vector>

#include "base/basictypes.h"

namespace tests {

class TestRunnerFactory;

// Runs the tests specified by the --gtest_filter flag specified in the command
// line that started this process.
// Returns true if all tests succeeded, false if there were no tests to run, or
// one or more tests failed, or if initialization failed.
// Results are printed to stdout.
bool RunTests(const TestRunnerFactory& test_runner_factory);

// This class defines a way to run tests in an isolated environment (each test
// having its static variables uninitialized).
// There are 2 implementations, in-process and out-of-process.
class TestRunner {
 public:
  TestRunner();
  virtual ~TestRunner();

  // Called once before the TestRunner is used.  Gives it an opportunity to
  // perform any requried initialization.  Should return true if the
  // initialization was successful.
  virtual bool Init() = 0;

  // Runs the test named |test_name| and returns true if the test succeeded,
  // false if it failed.
  virtual bool RunTest(const std::string& test_name) = 0;

 private:
  DISALLOW_COPY_AND_ASSIGN(TestRunner);
};

class TestRunnerFactory {
 public:
  virtual TestRunner* CreateTestRunner() const = 0;
};

}  // namespace

#endif  // CHROME_TEST_TEST_LAUNCHER_TEST_RUNNER_H_