Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/test/ui/ui_test_suite.cc

Issue 39282: Start the crash_service on windows when running ui tests, if it's not running... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/ui/ui_test_suite.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "chrome/test/ui/ui_test_suite.h" 5 #include "chrome/test/ui/ui_test_suite.h"
6 6
7 #include "base/path_service.h"
8 #include "base/process_util.h"
9 #include "base/sys_info.h"
10 #include "chrome/common/env_vars.h"
11
7 // Force a test to use an already running browser instance. UI tests only. 12 // Force a test to use an already running browser instance. UI tests only.
8 const wchar_t UITestSuite::kUseExistingBrowser[] = L"use-existing-browser"; 13 const wchar_t UITestSuite::kUseExistingBrowser[] = L"use-existing-browser";
9 14
10 // Timeout for the test in milliseconds. UI tests only. 15 // Timeout for the test in milliseconds. UI tests only.
11 const wchar_t UITestSuite::kTestTimeout[] = L"test-timeout"; 16 const wchar_t UITestSuite::kTestTimeout[] = L"test-timeout";
12 17
18
19 UITestSuite::UITestSuite(int argc, char** argv)
20 : ChromeTestSuite(argc, argv) {
21 #if defined(OS_WIN)
22 crash_service_ = NULL;
23 #endif
24 }
25
26 void UITestSuite::Initialize() {
27 ChromeTestSuite::Initialize();
28
29 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
30 UITest::set_in_process_renderer(
31 parsed_command_line.HasSwitch(switches::kSingleProcess));
32 UITest::set_no_sandbox(
33 parsed_command_line.HasSwitch(switches::kNoSandbox));
34 UITest::set_full_memory_dump(
35 parsed_command_line.HasSwitch(switches::kFullMemoryCrashReport));
36 UITest::set_safe_plugins(
37 parsed_command_line.HasSwitch(switches::kSafePlugins));
38 UITest::set_use_existing_browser(
39 parsed_command_line.HasSwitch(UITestSuite::kUseExistingBrowser));
40 UITest::set_dump_histograms_on_exit(
41 parsed_command_line.HasSwitch(switches::kDumpHistogramsOnExit));
42 UITest::set_enable_dcheck(
43 parsed_command_line.HasSwitch(switches::kEnableDCHECK));
44 UITest::set_silent_dump_on_dcheck(
45 parsed_command_line.HasSwitch(switches::kSilentDumpOnDCHECK));
46 UITest::set_disable_breakpad(
47 parsed_command_line.HasSwitch(switches::kDisableBreakpad));
48 std::wstring test_timeout =
49 parsed_command_line.GetSwitchValue(UITestSuite::kTestTimeout);
50 if (!test_timeout.empty()) {
51 UITest::set_test_timeout_ms(StringToInt(WideToUTF16Hack(test_timeout)));
52 }
53 std::wstring js_flags =
54 parsed_command_line.GetSwitchValue(switches::kJavaScriptFlags);
55 if (!js_flags.empty()) {
56 UITest::set_js_flags(js_flags);
57 }
58 std::wstring log_level =
59 parsed_command_line.GetSwitchValue(switches::kLoggingLevel);
60 if (!log_level.empty()) {
61 UITest::set_log_level(log_level);
62 }
63
64 #if defined(OS_WIN)
65 LoadCrashService();
66 #endif
67 }
68
69 void UITestSuite::Shutdown() {
70 #if defined(OS_WIN)
71 if (crash_service_)
72 base::KillProcess(crash_service_, 0, false);
73 #endif
74
75 ChromeTestSuite::Shutdown();
76 }
77
78 void UITestSuite::SuppressErrorDialogs() {
79 #if defined(OS_WIN)
80 TestSuite::SuppressErrorDialogs();
81 #endif
82 UITest::set_show_error_dialogs(false);
83 }
84
85 #if defined(OS_WIN)
86 void UITestSuite::LoadCrashService() {
87 if (base::SysInfo::HasEnvVar(env_vars::kHeadless))
88 return;
89
90 if (base::GetProcessCount(L"crash_service.exe", NULL))
91 return;
92
93 FilePath exe_dir;
94 if (!PathService::Get(base::DIR_EXE, &exe_dir)) {
95 DCHECK(false);
96 return;
97 }
98
99 FilePath crash_service = exe_dir.Append(L"crash_service.exe");
100 if (!base::LaunchApp(crash_service.ToWStringHack(), false, false,
101 &crash_service_)) {
102 printf("Couldn't start crash_service.exe, so this ui_test run won't tell " \
103 "you if any test crashes!\n");
104 return;
105 }
106
107 printf("Started crash_service.exe so you know if a test crashes!\n");
108 }
109 #endif
OLDNEW
« no previous file with comments | « chrome/test/ui/ui_test_suite.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698