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

Unified Diff: chrome/test/base/web_ui_browser_test.cc

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up, MockLog uses listener Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/base/web_ui_browser_test.cc
diff --git a/chrome/test/base/web_ui_browser_test.cc b/chrome/test/base/web_ui_browser_test.cc
index 4a55e86fc2e041d9b37aca86663e4c6dc6f2a426..f7ec7e1160ebee21dc3eb1508fbcf335cde8b333 100644
--- a/chrome/test/base/web_ui_browser_test.cc
+++ b/chrome/test/base/web_ui_browser_test.cc
@@ -53,17 +53,15 @@ base::LazyInstance<std::vector<std::string> > error_messages_ =
LAZY_INSTANCE_INITIALIZER;
// Intercepts all log messages.
-bool LogHandler(int severity,
- const char* file,
- int line,
- size_t message_start,
- const std::string& str) {
+void LogListener(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str) {
if (severity == logging::LOG_ERROR && file &&
std::string("CONSOLE") == file) {
error_messages_.Get().push_back(str);
}
-
- return false;
}
class WebUIJsInjectionReadyObserver : public content::WebContentsObserver {
@@ -299,7 +297,8 @@ const char WebUIBrowserTest::kDummyURL[] = "chrome://DummyURL";
WebUIBrowserTest::WebUIBrowserTest()
: test_handler_(new WebUITestHandler()),
libraries_preloaded_(false),
- override_selected_web_ui_(NULL) {
+ override_selected_web_ui_(NULL),
+ listener(LogListener) {
}
void WebUIBrowserTest::set_preload_test_fixture(
@@ -372,8 +371,6 @@ base::LazyInstance<MockWebUIProvider> mock_provider_ =
void WebUIBrowserTest::SetUpOnMainThread() {
JavaScriptBrowserTest::SetUpOnMainThread();
- logging::SetLogMessageHandler(&LogHandler);
-
AddLibrary(base::FilePath(kA11yAuditLibraryJSPath));
content::WebUIControllerFactory::UnregisterFactoryForTesting(
@@ -390,8 +387,6 @@ void WebUIBrowserTest::SetUpOnMainThread() {
}
void WebUIBrowserTest::TearDownOnMainThread() {
- logging::SetLogMessageHandler(NULL);
-
test_factory_->RemoveFactoryOverride(GURL(kDummyURL).host());
content::WebUIControllerFactory::UnregisterFactoryForTesting(
test_factory_.get());

Powered by Google App Engine
This is Rietveld 408576698