Index: media/capture/webm_muxer_unittest.cc |
diff --git a/media/capture/webm_muxer_unittest.cc b/media/capture/webm_muxer_unittest.cc |
index bde9b4fb49a6d398240d17bb34f220f09bd84b48..58da23e280a5e40cf51f60429c83fbdb15e44526 100644 |
--- a/media/capture/webm_muxer_unittest.cc |
+++ b/media/capture/webm_muxer_unittest.cc |
@@ -19,18 +19,11 @@ using ::testing::WithArgs; |
namespace media { |
-// Dummy interface class to be able to MOCK its only function below. |
-class EventHandlerInterface { |
- public: |
- virtual void WriteCallback(const base::StringPiece& encoded_data) = 0; |
- virtual ~EventHandlerInterface() {} |
-}; |
- |
-class WebmMuxerTest : public testing::Test, public EventHandlerInterface { |
+class WebmMuxerTest : public testing::Test { |
public: |
WebmMuxerTest() |
- : webm_muxer_(base::Bind(&WebmMuxerTest::WriteCallback, |
- base::Unretained(this))), |
+ : webm_muxer_(WebmMuxer(base::Bind(&WebmMuxerTest::WriteData, |
+ base::Unretained(this)))), |
last_encoded_length_(0), |
accumulated_position_(0) { |
EXPECT_EQ(webm_muxer_.Position(), 0); |
@@ -39,9 +32,12 @@ class WebmMuxerTest : public testing::Test, public EventHandlerInterface { |
EXPECT_FALSE(webm_muxer_.Seekable()); |
} |
- MOCK_METHOD1(WriteCallback, void(const base::StringPiece&)); |
+ MOCK_METHOD1(WriteCallback, void(const std::string&)); |
+ void WriteData(scoped_ptr<std::string> data) { |
+ WriteCallback(*data); |
+ } |
- void SaveEncodedDataLen(const base::StringPiece& encoded_data) { |
+ void SaveEncodedDataLen(const std::string& encoded_data) { |
last_encoded_length_ = encoded_data.size(); |
accumulated_position_ += encoded_data.size(); |
} |
@@ -70,7 +66,7 @@ class WebmMuxerTest : public testing::Test, public EventHandlerInterface { |
// Checks that the WriteCallback is called with appropriate params when |
// WebmMuxer::Write() method is called. |
TEST_F(WebmMuxerTest, Write) { |
- const base::StringPiece encoded_data("abcdefghijklmnopqrstuvwxyz"); |
+ const std::string encoded_data("abcdefghijklmnopqrstuvwxyz"); |
EXPECT_CALL(*this, WriteCallback(encoded_data)); |
WebmMuxerWrite(encoded_data.data(), encoded_data.size()); |
@@ -84,14 +80,14 @@ TEST_F(WebmMuxerTest, OnEncodedVideoTwoFrames) { |
const gfx::Size frame_size(160, 80); |
const scoped_refptr<VideoFrame> video_frame = |
VideoFrame::CreateBlackFrame(frame_size); |
- const base::StringPiece encoded_data("abcdefghijklmnopqrstuvwxyz"); |
+ const std::string encoded_data("abcdefghijklmnopqrstuvwxyz"); |
EXPECT_CALL(*this, WriteCallback(_)) |
.Times(AtLeast(1)) |
.WillRepeatedly(WithArgs<0>( |
Invoke(this, &WebmMuxerTest::SaveEncodedDataLen))); |
webm_muxer_.OnEncodedVideo(video_frame, |
- encoded_data, |
+ make_scoped_ptr(new std::string(encoded_data)), |
base::TimeTicks::Now(), |
false /* keyframe */); |
@@ -108,7 +104,7 @@ TEST_F(WebmMuxerTest, OnEncodedVideoTwoFrames) { |
.WillRepeatedly(WithArgs<0>( |
Invoke(this, &WebmMuxerTest::SaveEncodedDataLen))); |
webm_muxer_.OnEncodedVideo(video_frame, |
- encoded_data, |
+ make_scoped_ptr(new std::string(encoded_data)), |
base::TimeTicks::Now(), |
false /* keyframe */); |