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

Unified Diff: base/test/scoped_mock_log.h

Issue 966423003: Moving ScopedMockLog from net/test to base/test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@separate-port-range
Patch Set: Limiting the changes to moving ScopedMockLog to base/test Created 5 years, 10 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: base/test/scoped_mock_log.h
diff --git a/net/test/scoped_mock_log.h b/base/test/scoped_mock_log.h
similarity index 87%
rename from net/test/scoped_mock_log.h
rename to base/test/scoped_mock_log.h
index e1edfcccde8cd5150708a792043799b41cc8cc00..ee48de18a6966e725469a9c56bd27439a3516efe 100644
--- a/net/test/scoped_mock_log.h
+++ b/base/test/scoped_mock_log.h
@@ -2,15 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef NET_QUIC_TEST_TOOLS_SCOPED_MOCK_LOG_H_
-#define NET_QUIC_TEST_TOOLS_SCOPED_MOCK_LOG_H_
+#ifndef BASE_TEST_SCOPED_MOCK_LOG_H_
+#define BASE_TEST_SCOPED_MOCK_LOG_H_
+
+#include <string>
#include "base/logging.h"
+#include "base/synchronization/lock.h"
#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-namespace net {
-namespace test {
rvargas (doing something else) 2015/03/03 19:45:34 Almost all files on the new destination are outsid
Łukasz Anforowicz 2015/03/04 00:23:01 Good point. I was torn on this myself and ended u
+namespace base {
// A ScopedMockLog object intercepts LOG() messages issued during its
// lifespan. Using this together with gMock, it's very easy to test
@@ -67,16 +68,20 @@ class ScopedMockLog {
// it's sent to other log destinations (if any).
// Returns true to signal that it handled the message and the message
// should not be sent to other log destinations.
- MOCK_METHOD5(Log, bool(int severity,
- const char* file,
- int line,
- size_t message_start,
- const std::string& str));
+ MOCK_METHOD5(Log,
+ bool(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str));
private:
// The currently active scoped mock log.
static ScopedMockLog* g_instance_;
+ // Lock protecting access to g_instance_.
+ static Lock g_lock;
+
// Static function which is set as the logging message handler.
// Called once for each message.
static bool LogMessageHandler(int severity,
@@ -92,7 +97,6 @@ class ScopedMockLog {
logging::LogMessageHandlerFunction previous_handler_;
};
rvargas (doing something else) 2015/03/03 19:45:34 DISALLOW_COPY_AND_ASSIGN ?
Łukasz Anforowicz 2015/03/04 00:23:01 Done.
-} // namespace test
-} // namespace net
+} // namespace base
-#endif // NET_QUIC_TEST_TOOLS_SCOPED_MOCK_LOG_H_
+#endif // BASE_TEST_SCOPED_MOCK_LOG_H_

Powered by Google App Engine
This is Rietveld 408576698