Skip to content
Snippets Groups Projects
Commit 64e5cc08 authored by hansl@google.com's avatar hansl@google.com
Browse files

Fix the testing::LogDisabler for the change r64883. See http://codereview.chromium.org/4262001/show

The r64883 broke most unit tests in CEEE that relied on disabling logs while testing error paths.

BUG=None
TEST=None

Review URL: http://codereview.chromium.org/4390001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64948 0039d316-1c4b-4281-b951-d872f2087c98
parent 2bf2c3c8
No related branches found
No related tags found
No related merge requests found
...@@ -420,6 +420,10 @@ void SetLogMessageHandler(LogMessageHandlerFunction handler) { ...@@ -420,6 +420,10 @@ void SetLogMessageHandler(LogMessageHandlerFunction handler) {
log_message_handler = handler; log_message_handler = handler;
} }
LogMessageHandlerFunction GetLogMessageHandler() {
return log_message_handler;
}
// MSVC doesn't like complex extern templates and DLLs. // MSVC doesn't like complex extern templates and DLLs.
#if !defined(COMPILER_MSVC) #if !defined(COMPILER_MSVC)
// Explicit instantiations for commonly used comparisons. // Explicit instantiations for commonly used comparisons.
......
...@@ -245,6 +245,7 @@ void SetShowErrorDialogs(bool enable_dialogs); ...@@ -245,6 +245,7 @@ void SetShowErrorDialogs(bool enable_dialogs);
// (e.g. a silent one for Unit Tests) // (e.g. a silent one for Unit Tests)
typedef void (*LogAssertHandlerFunction)(const std::string& str); typedef void (*LogAssertHandlerFunction)(const std::string& str);
void SetLogAssertHandler(LogAssertHandlerFunction handler); void SetLogAssertHandler(LogAssertHandlerFunction handler);
// Sets the Log Report Handler that will be used to notify of check failures // Sets the Log Report Handler that will be used to notify of check failures
// in non-debug mode. The default handler shows a dialog box and continues // in non-debug mode. The default handler shows a dialog box and continues
// the execution, however clients can use this function to override with their // the execution, however clients can use this function to override with their
...@@ -258,6 +259,7 @@ void SetLogReportHandler(LogReportHandlerFunction handler); ...@@ -258,6 +259,7 @@ void SetLogReportHandler(LogReportHandlerFunction handler);
// should not be sent to other log destinations. // should not be sent to other log destinations.
typedef bool (*LogMessageHandlerFunction)(int severity, const std::string& str); typedef bool (*LogMessageHandlerFunction)(int severity, const std::string& str);
void SetLogMessageHandler(LogMessageHandlerFunction handler); void SetLogMessageHandler(LogMessageHandlerFunction handler);
LogMessageHandlerFunction GetLogMessageHandler();
typedef int LogSeverity; typedef int LogSeverity;
const LogSeverity LOG_INFO = 0; const LogSeverity LOG_INFO = 0;
......
...@@ -58,13 +58,17 @@ HRESULT GetConnectionCount(IUnknown* container, ...@@ -58,13 +58,17 @@ HRESULT GetConnectionCount(IUnknown* container,
} }
bool LogDisabler::DropMessageHandler(int severity, const std::string& str) {
return true;
}
LogDisabler::LogDisabler() { LogDisabler::LogDisabler() {
initial_log_level_ = logging::GetMinLogLevel(); old_handler_ = logging::GetLogMessageHandler();
logging::SetMinLogLevel(logging::LOG_FATAL + 1); logging::SetLogMessageHandler(DropMessageHandler);
} }
LogDisabler::~LogDisabler() { LogDisabler::~LogDisabler() {
logging::SetMinLogLevel(initial_log_level_); logging::SetLogMessageHandler(old_handler_);
} }
PathServiceOverrider::PathServiceOverrider(int key, const FilePath& path) { PathServiceOverrider::PathServiceOverrider(int key, const FilePath& path) {
......
...@@ -67,7 +67,8 @@ class LogDisabler { ...@@ -67,7 +67,8 @@ class LogDisabler {
~LogDisabler(); ~LogDisabler();
private: private:
int initial_log_level_; logging::LogMessageHandlerFunction old_handler_;
static bool DropMessageHandler(int severity, const std::string& str);
}; };
// Overrides a path in the PathService singleton, replacing the // Overrides a path in the PathService singleton, replacing the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment