summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-06 22:59:42 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-06 22:59:42 +0000
commite61018fb232d2e6d9e2a4a11e94e8e3072806373 (patch)
treea207469bae98cf5dfce7dfcfc81798a298bad639
parentc79024bd6c78662be90bce5c8846ac9ad1f2eade (diff)
downloadchromium_src-e61018fb232d2e6d9e2a4a11e94e8e3072806373.zip
chromium_src-e61018fb232d2e6d9e2a4a11e94e8e3072806373.tar.gz
chromium_src-e61018fb232d2e6d9e2a4a11e94e8e3072806373.tar.bz2
Start the crash_service on windows when running ui tests, if it's not running already. Otherwise there's no point in running ui_tests!
Review URL: http://codereview.chromium.org/39282 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11172 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/process_util_win.cc2
-rw-r--r--chrome/test/ui/ui_test_suite.cc97
-rw-r--r--chrome/test/ui/ui_test_suite.h53
3 files changed, 107 insertions, 45 deletions
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 9829a41..0ced788 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -178,7 +178,7 @@ bool KillProcess(ProcessHandle process, int exit_code, bool wait) {
// The process may not end immediately due to pending I/O
if (WAIT_OBJECT_0 != WaitForSingleObject(process, 60 * 1000))
DLOG(ERROR) << "Error waiting for process exit: " << GetLastError();
- } else {
+ } else if (!result) {
DLOG(ERROR) << "Unable to terminate process: " << GetLastError();
}
return result;
diff --git a/chrome/test/ui/ui_test_suite.cc b/chrome/test/ui/ui_test_suite.cc
index d8d24fb..3ff0fef 100644
--- a/chrome/test/ui/ui_test_suite.cc
+++ b/chrome/test/ui/ui_test_suite.cc
@@ -4,9 +4,106 @@
#include "chrome/test/ui/ui_test_suite.h"
+#include "base/path_service.h"
+#include "base/process_util.h"
+#include "base/sys_info.h"
+#include "chrome/common/env_vars.h"
+
// Force a test to use an already running browser instance. UI tests only.
const wchar_t UITestSuite::kUseExistingBrowser[] = L"use-existing-browser";
// Timeout for the test in milliseconds. UI tests only.
const wchar_t UITestSuite::kTestTimeout[] = L"test-timeout";
+
+UITestSuite::UITestSuite(int argc, char** argv)
+ : ChromeTestSuite(argc, argv) {
+#if defined(OS_WIN)
+ crash_service_ = NULL;
+#endif
+}
+
+void UITestSuite::Initialize() {
+ ChromeTestSuite::Initialize();
+
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
+ UITest::set_in_process_renderer(
+ parsed_command_line.HasSwitch(switches::kSingleProcess));
+ 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(WideToUTF16Hack(test_timeout)));
+ }
+ std::wstring js_flags =
+ parsed_command_line.GetSwitchValue(switches::kJavaScriptFlags);
+ if (!js_flags.empty()) {
+ UITest::set_js_flags(js_flags);
+ }
+ std::wstring log_level =
+ parsed_command_line.GetSwitchValue(switches::kLoggingLevel);
+ if (!log_level.empty()) {
+ UITest::set_log_level(log_level);
+ }
+
+#if defined(OS_WIN)
+ LoadCrashService();
+#endif
+}
+
+void UITestSuite::Shutdown() {
+#if defined(OS_WIN)
+ if (crash_service_)
+ base::KillProcess(crash_service_, 0, false);
+#endif
+
+ ChromeTestSuite::Shutdown();
+}
+
+void UITestSuite::SuppressErrorDialogs() {
+#if defined(OS_WIN)
+ TestSuite::SuppressErrorDialogs();
+#endif
+ UITest::set_show_error_dialogs(false);
+}
+
+#if defined(OS_WIN)
+void UITestSuite::LoadCrashService() {
+ if (base::SysInfo::HasEnvVar(env_vars::kHeadless))
+ return;
+
+ if (base::GetProcessCount(L"crash_service.exe", NULL))
+ return;
+
+ FilePath exe_dir;
+ if (!PathService::Get(base::DIR_EXE, &exe_dir)) {
+ DCHECK(false);
+ return;
+ }
+
+ FilePath crash_service = exe_dir.Append(L"crash_service.exe");
+ if (!base::LaunchApp(crash_service.ToWStringHack(), false, false,
+ &crash_service_)) {
+ printf("Couldn't start crash_service.exe, so this ui_test run won't tell " \
+ "you if any test crashes!\n");
+ return;
+ }
+
+ printf("Started crash_service.exe so you know if a test crashes!\n");
+}
+#endif
diff --git a/chrome/test/ui/ui_test_suite.h b/chrome/test/ui/ui_test_suite.h
index 4961b3f..7da80fa 100644
--- a/chrome/test/ui/ui_test_suite.h
+++ b/chrome/test/ui/ui_test_suite.h
@@ -5,63 +5,28 @@
#ifndef CHROME_TEST_UI_UI_TEST_SUITE_H_
#define CHROME_TEST_UI_UI_TEST_SUITE_H_
+#include "base/process.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) {
- }
+ UITestSuite(int argc, char** argv);
protected:
+ virtual void Initialize();
- virtual void Initialize() {
- ChromeTestSuite::Initialize();
+ virtual void Shutdown();
- const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
- UITest::set_in_process_renderer(
- parsed_command_line.HasSwitch(switches::kSingleProcess));
- 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(WideToUTF16Hack(test_timeout)));
- }
- std::wstring js_flags =
- parsed_command_line.GetSwitchValue(switches::kJavaScriptFlags);
- if (!js_flags.empty()) {
- UITest::set_js_flags(js_flags);
- }
- std::wstring log_level =
- parsed_command_line.GetSwitchValue(switches::kLoggingLevel);
- if (!log_level.empty()) {
- UITest::set_log_level(log_level);
- }
- }
+ virtual void SuppressErrorDialogs();
- virtual void SuppressErrorDialogs() {
+ private:
#if defined(OS_WIN)
- TestSuite::SuppressErrorDialogs();
+ void LoadCrashService();
+
+ base::ProcessHandle crash_service_;
#endif
- UITest::set_show_error_dialogs(false);
- }
- private:
static const wchar_t kUseExistingBrowser[];
static const wchar_t kTestTimeout[];
};