class MockDelegate : public MediaStreamBufferManager::Delegate {
public:
MockDelegate() : new_buffer_enqueue_counter_(0) {}
+
+#if !(defined(OFFICIAL_BUILD) && defined(NDEBUG))
+ static bool HandleStandardLogMessage(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str) {
+ if (severity == logging::LOG_FATAL) {
+ fprintf(stderr, str.c_str());
+ }
+ // This function only used to monitor LogMessage, and should not
+ // block LogMessage from the original output destination.
+ // Return false to guarantee LogMessage reach original destination.
+ return false;
+ }
+#endif //!(defined(OFFICIAL_BUILD) && defined(NDEBUG))
+
void OnNewBufferEnqueued() override {
new_buffer_enqueue_counter_++;
}
EXPECT_DEATH(manager.EnqueueBuffer(-1), "");
EXPECT_DEATH(manager.EnqueueBuffer(kNumberOfBuffers), "");
#else
+ auto previous_handler = logging::GetLogMessageHandler();
+ logging::SetLogMessageHandler(&MockDelegate::HandleStandardLogMessage);
+
EXPECT_DEATH(manager.EnqueueBuffer(-1), ".*Check failed: index >= 0.*");
EXPECT_DEATH(manager.EnqueueBuffer(kNumberOfBuffers),
".*Check failed: index < number_of_buffers_.*");
+
+ logging::SetLogMessageHandler(previous_handler);
#endif
}