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_ |