| Index: webkit/support/webkit_support.cc
|
| ===================================================================
|
| --- webkit/support/webkit_support.cc (revision 53614)
|
| +++ webkit/support/webkit_support.cc (working copy)
|
| @@ -51,11 +51,54 @@
|
|
|
| namespace {
|
|
|
| +// All fatal log messages (e.g. DCHECK failures) imply unit test failures
|
| +void UnitTestAssertHandler(const std::string& str) {
|
| + FAIL() << str;
|
| +}
|
| +
|
| +void InitLogging(bool enable_gp_fault_error_box) {
|
| + logging::SetLogAssertHandler(UnitTestAssertHandler);
|
| +
|
| +#if defined(OS_WIN)
|
| + if (!::IsDebuggerPresent()) {
|
| + UINT new_flags = SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX;
|
| + if (!enable_gp_fault_error_box)
|
| + new_flags |= SEM_NOGPFAULTERRORBOX;
|
| +
|
| + // Preserve existing error mode, as discussed at
|
| + // http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx
|
| + UINT existing_flags = SetErrorMode(new_flags);
|
| + SetErrorMode(existing_flags | new_flags);
|
| + }
|
| +#endif
|
| +
|
| + FilePath log_filename;
|
| + PathService::Get(base::DIR_EXE, &log_filename);
|
| + log_filename = log_filename.AppendASCII("DumpRenderTree.log");
|
| + logging::InitLogging(
|
| + log_filename.value().c_str(),
|
| + // Only log to a file. This prevents debugging output from disrupting
|
| + // whether or not we pass.
|
| + logging::LOG_ONLY_TO_FILE,
|
| + // We might have multiple DumpRenderTree processes going at once.
|
| + logging::LOCK_LOG_FILE,
|
| + logging::DELETE_OLD_LOG_FILE);
|
| +
|
| + // We want process and thread IDs because we may have multiple processes.
|
| + const bool kProcessId = true;
|
| + const bool kThreadId = true;
|
| + const bool kTimestamp = true;
|
| + const bool kTickcount = true;
|
| + logging::SetLogItems(kProcessId, kThreadId, !kTimestamp, kTickcount);
|
| +}
|
| +
|
| class TestEnvironment {
|
| public:
|
| explicit TestEnvironment(bool unit_test_mode) {
|
| - if (!unit_test_mode)
|
| + if (!unit_test_mode) {
|
| at_exit_manager_.reset(new base::AtExitManager);
|
| + InitLogging(false);
|
| + }
|
| main_message_loop_.reset(new MessageLoopForUI);
|
| // TestWebKitClient must be instantiated after the MessageLoopForUI.
|
| webkit_client_.reset(new TestWebKitClient(unit_test_mode));
|
| @@ -112,47 +155,6 @@
|
| }
|
| }
|
|
|
| -// All fatal log messages (e.g. DCHECK failures) imply unit test failures
|
| -void UnitTestAssertHandler(const std::string& str) {
|
| - FAIL() << str;
|
| -}
|
| -
|
| -void InitLogging(bool enable_gp_fault_error_box) {
|
| - logging::SetLogAssertHandler(UnitTestAssertHandler);
|
| -
|
| -#if defined(OS_WIN)
|
| - if (!::IsDebuggerPresent()) {
|
| - UINT new_flags = SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX;
|
| - if (!enable_gp_fault_error_box)
|
| - new_flags |= SEM_NOGPFAULTERRORBOX;
|
| -
|
| - // Preserve existing error mode, as discussed at
|
| - // http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx
|
| - UINT existing_flags = SetErrorMode(new_flags);
|
| - SetErrorMode(existing_flags | new_flags);
|
| - }
|
| -#endif
|
| -
|
| - FilePath log_filename;
|
| - PathService::Get(base::DIR_EXE, &log_filename);
|
| - log_filename = log_filename.AppendASCII("DumpRenderTree.log");
|
| - logging::InitLogging(
|
| - log_filename.value().c_str(),
|
| - // Only log to a file. This prevents debugging output from disrupting
|
| - // whether or not we pass.
|
| - logging::LOG_ONLY_TO_FILE,
|
| - // We might have multiple DumpRenderTree processes going at once.
|
| - logging::LOCK_LOG_FILE,
|
| - logging::DELETE_OLD_LOG_FILE);
|
| -
|
| - // We want process and thread IDs because we may have multiple processes.
|
| - const bool kProcessId = true;
|
| - const bool kThreadId = true;
|
| - const bool kTimestamp = true;
|
| - const bool kTickcount = true;
|
| - logging::SetLogItems(kProcessId, kThreadId, !kTimestamp, kTickcount);
|
| -}
|
| -
|
| } // namespace
|
|
|
| namespace webkit_support {
|
| @@ -174,8 +176,6 @@
|
| const char* kFixedArguments[] = {"DumpRenderTree"};
|
| CommandLine::Init(arraysize(kFixedArguments), kFixedArguments);
|
|
|
| - InitLogging(false);
|
| -
|
| webkit_support::BeforeInitialize();
|
| webkit_support::test_environment = new TestEnvironment(unit_test_mode);
|
| webkit_support::AfterInitialize();
|
|
|