summaryrefslogtreecommitdiffstats
path: root/chrome/test/ui/ui_test_suite.h
blob: 07f6c7674b5df0e0477b88f22037a3d5782f37c6 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) 2006-2008 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_UI_UI_TEST_SUITE_H_
#define CHROME_TEST_UI_UI_TEST_SUITE_H_

#include "chrome/test/ui/ui_test.h"
#include "chrome/test/unit/chrome_test_suite.h"

class UITestSuite : public ChromeTestSuite {
 public:
  UITestSuite(int argc, char** argv) : ChromeTestSuite(argc, argv) {
  }

 protected:

  virtual void Initialize() {
    ChromeTestSuite::Initialize();

    const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
    UITest::set_in_process_renderer(
        parsed_command_line.HasSwitch(switches::kSingleProcess));
    UITest::set_in_process_plugins(
        parsed_command_line.HasSwitch(switches::kInProcessPlugins));
    UITest::set_no_sandbox(
        parsed_command_line.HasSwitch(switches::kNoSandbox));
    UITest::set_full_memory_dump(
        parsed_command_line.HasSwitch(switches::kFullMemoryCrashReport));
    UITest::set_safe_plugins(
        parsed_command_line.HasSwitch(switches::kSafePlugins));
    UITest::set_use_existing_browser(
        parsed_command_line.HasSwitch(UITestSuite::kUseExistingBrowser));
    UITest::set_dump_histograms_on_exit(
        parsed_command_line.HasSwitch(switches::kDumpHistogramsOnExit));
    UITest::set_enable_dcheck(
        parsed_command_line.HasSwitch(switches::kEnableDCHECK));
    UITest::set_silent_dump_on_dcheck(
        parsed_command_line.HasSwitch(switches::kSilentDumpOnDCHECK));
    UITest::set_disable_breakpad(
        parsed_command_line.HasSwitch(switches::kDisableBreakpad));
    std::wstring test_timeout =
        parsed_command_line.GetSwitchValue(UITestSuite::kTestTimeout);
    if (!test_timeout.empty()) {
      UITest::set_test_timeout_ms(StringToInt(test_timeout));
    }
    std::wstring js_flags =
      parsed_command_line.GetSwitchValue(switches::kJavaScriptFlags);
    if (!js_flags.empty()) {
      UITest::set_js_flags(js_flags);
    }
  }

  virtual void SuppressErrorDialogs() {
#if defined(OS_WIN)
    TestSuite::SuppressErrorDialogs();
#endif
    UITest::set_show_error_dialogs(false);
  }

 private:
  static const wchar_t kUseExistingBrowser[];
  static const wchar_t kTestTimeout[];
};

#endif  // CHROME_TEST_UI_UI_TEST_SUITE_H_