summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test/reliability/run_all_unittests.cc
blob: 3b2604d5bcc8e2e3cc44e25ce2587900909c0412 (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
// Copyright (c) 2006-2010 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.

#include "chrome_frame/test/reliability/reliability_test_suite.h"

#include "base/command_line.h"
#include "chrome/common/chrome_paths.h"
#include "chrome_frame/test/chrome_frame_test_utils.h"
#include "chrome_frame/test_utils.h"
#include "chrome_frame/utils.h"

const wchar_t kRegisterDllFlag[] = L"register";

int main(int argc, char **argv) {

  // If --register is passed, then we need to ensure that Chrome Frame is
  // registered before starting up the reliability tests.
  CommandLine::Init(argc, argv);
  CommandLine* cmd_line = CommandLine::ForCurrentProcess();
  DCHECK(cmd_line);

  // We create this slightly early as it is the one who instantiates THE
  // AtExitManager which some of the other stuff below relies on.
  ReliabilityTestSuite test_suite(argc, argv);

  SetConfigBool(kChromeFrameHeadlessMode, true);
  base::ProcessHandle crash_service = chrome_frame_test::StartCrashService();

  int result = -1;
  if (cmd_line->HasSwitch(kRegisterDllFlag)) {
    std::wstring dll_path = cmd_line->GetSwitchValue(kRegisterDllFlag);

    // Run() must be called within the scope of the ScopedChromeFrameRegistrar
    // to ensure that the correct DLL remains registered during the tests.
    ScopedChromeFrameRegistrar scoped_chrome_frame_registrar(dll_path);
    result = test_suite.Run();
  } else {
    result = test_suite.Run();
  }

  DeleteConfigValue(kChromeFrameHeadlessMode);
  if (crash_service)
    base::KillProcess(crash_service, 0, false);

  return result;
}