| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/base/text_renderer.h" |
| 6 |
| 5 #include <stddef.h> | 7 #include <stddef.h> |
| 6 | 8 #include <utility> |
| 7 #include <vector> | 9 #include <vector> |
| 8 | 10 |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 13 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 14 #include "media/base/audio_decoder_config.h" | 16 #include "media/base/audio_decoder_config.h" |
| 15 #include "media/base/decoder_buffer.h" | 17 #include "media/base/decoder_buffer.h" |
| 16 #include "media/base/demuxer_stream.h" | 18 #include "media/base/demuxer_stream.h" |
| 17 #include "media/base/fake_text_track_stream.h" | 19 #include "media/base/fake_text_track_stream.h" |
| 18 #include "media/base/text_renderer.h" | |
| 19 #include "media/base/text_track_config.h" | 20 #include "media/base/text_track_config.h" |
| 20 #include "media/base/video_decoder_config.h" | 21 #include "media/base/video_decoder_config.h" |
| 21 #include "media/filters/webvtt_util.h" | 22 #include "media/filters/webvtt_util.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 25 |
| 25 namespace media { | 26 namespace media { |
| 26 | 27 |
| 27 // Local implementation of the TextTrack interface. | 28 // Local implementation of the TextTrack interface. |
| 28 class FakeTextTrack : public TextTrack { | 29 class FakeTextTrack : public TextTrack { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 const AddTextTrackDoneCB& done_cb) { | 94 const AddTextTrackDoneCB& done_cb) { |
| 94 base::Closure destroy_cb = | 95 base::Closure destroy_cb = |
| 95 base::Bind(&TextRendererTest::OnDestroyTextTrack, | 96 base::Bind(&TextRendererTest::OnDestroyTextTrack, |
| 96 base::Unretained(this), | 97 base::Unretained(this), |
| 97 text_tracks_.size()); | 98 text_tracks_.size()); |
| 98 // Text track objects are owned by the text renderer, but we cache them | 99 // Text track objects are owned by the text renderer, but we cache them |
| 99 // here so we can inspect them. They get removed from our cache when the | 100 // here so we can inspect them. They get removed from our cache when the |
| 100 // text renderer deallocates them. | 101 // text renderer deallocates them. |
| 101 text_tracks_.push_back(new FakeTextTrack(destroy_cb, config)); | 102 text_tracks_.push_back(new FakeTextTrack(destroy_cb, config)); |
| 102 scoped_ptr<TextTrack> text_track(text_tracks_.back()); | 103 scoped_ptr<TextTrack> text_track(text_tracks_.back()); |
| 103 done_cb.Run(text_track.Pass()); | 104 done_cb.Run(std::move(text_track)); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void RemoveTextTrack(unsigned idx) { | 107 void RemoveTextTrack(unsigned idx) { |
| 107 FakeTextTrackStream* const stream = text_track_streams_[idx]; | 108 FakeTextTrackStream* const stream = text_track_streams_[idx]; |
| 108 text_renderer_->RemoveTextStream(stream); | 109 text_renderer_->RemoveTextStream(stream); |
| 109 EXPECT_FALSE(text_tracks_[idx]); | 110 EXPECT_FALSE(text_tracks_[idx]); |
| 110 } | 111 } |
| 111 | 112 |
| 112 void SatisfyPendingReads(const base::TimeDelta& start, | 113 void SatisfyPendingReads(const base::TimeDelta& start, |
| 113 const base::TimeDelta& duration, | 114 const base::TimeDelta& duration, |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 Play(); | 1204 Play(); |
| 1204 AbortPendingRead(0); | 1205 AbortPendingRead(0); |
| 1205 RemoveTextTrack(0); | 1206 RemoveTextTrack(0); |
| 1206 EXPECT_TRUE(text_renderer_->HasTracks()); | 1207 EXPECT_TRUE(text_renderer_->HasTracks()); |
| 1207 Pause(); | 1208 Pause(); |
| 1208 EXPECT_CALL(*this, OnPause()); | 1209 EXPECT_CALL(*this, OnPause()); |
| 1209 SendEosNotification(1); | 1210 SendEosNotification(1); |
| 1210 } | 1211 } |
| 1211 | 1212 |
| 1212 } // namespace media | 1213 } // namespace media |
| OLD | NEW |