shill: Add NiceScopedMockLog
Add a variant to ScopedMockLog that automatically expects any Log
message. This allows us to expect only unique messages that are
specific to the test at hand.
BUG=None
TEST=Unit test that contains an explicit call to log.Log()
Change-Id: I19567b8cfa331daf48367ff8cfc1c266d0618159
Reviewed-on: https://gerrit.chromium.org/gerrit/48154
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Commit-Queue: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/mock_log.cc b/mock_log.cc
index e34d983..dcc8438 100644
--- a/mock_log.cc
+++ b/mock_log.cc
@@ -6,9 +6,13 @@
#include <string>
+#include <gtest/gtest.h>
+
#include "shill/memory_log.h"
using std::string;
+using testing::_;
+using testing::AnyNumber;
namespace shill {
@@ -57,4 +61,10 @@
return false;
}
+NiceScopedMockLog::NiceScopedMockLog() : ScopedMockLog() {
+ EXPECT_CALL(*this, Log(_, _, _)).Times(AnyNumber());
+}
+
+NiceScopedMockLog::~NiceScopedMockLog() {}
+
} // namespace shill