This source file includes following definitions.
- TEST
#include <string>
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "chrome/renderer/media/chrome_webrtc_log_message_delegate.h"
#include "chrome/renderer/media/mock_webrtc_logging_message_filter.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(ChromeWebRtcLogMessageDelegateTest, Basic) {
const char kTestString[] = "abcdefghijklmnopqrstuvwxyz";
base::MessageLoopForIO message_loop;
scoped_refptr<MockWebRtcLoggingMessageFilter> log_message_filter(
new MockWebRtcLoggingMessageFilter(message_loop.message_loop_proxy()));
message_loop.RunUntilIdle();
ChromeWebRtcLogMessageDelegate* log_message_delegate =
log_message_filter->log_message_delegate();
message_loop.message_loop_proxy()->PostTask(
FROM_HERE, base::Bind(
&ChromeWebRtcLogMessageDelegate::OnStartLogging,
base::Unretained(log_message_delegate)));
log_message_delegate->LogMessage(kTestString);
log_message_delegate->LogMessage(kTestString);
message_loop.message_loop_proxy()->PostTask(
FROM_HERE, base::Bind(
&ChromeWebRtcLogMessageDelegate::OnStopLogging,
base::Unretained(log_message_delegate)));
log_message_delegate->LogMessage(kTestString);
message_loop.RunUntilIdle();
const uint32 kExpectedSize = sizeof(kTestString) * 2;
EXPECT_EQ(kExpectedSize, log_message_filter->log_buffer_.size());
std::string ref_output = kTestString;
ref_output.append("\n");
ref_output.append(kTestString);
ref_output.append("\n");
EXPECT_STREQ(ref_output.c_str(), log_message_filter->log_buffer_.c_str());
}