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" | 5 #include "media/base/text_renderer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <memory> |
8 #include <utility> | 9 #include <utility> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
16 #include "media/base/audio_decoder_config.h" | 17 #include "media/base/audio_decoder_config.h" |
17 #include "media/base/decoder_buffer.h" | 18 #include "media/base/decoder_buffer.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 void OnAddTextTrack(const TextTrackConfig& config, | 94 void OnAddTextTrack(const TextTrackConfig& config, |
94 const AddTextTrackDoneCB& done_cb) { | 95 const AddTextTrackDoneCB& done_cb) { |
95 base::Closure destroy_cb = | 96 base::Closure destroy_cb = |
96 base::Bind(&TextRendererTest::OnDestroyTextTrack, | 97 base::Bind(&TextRendererTest::OnDestroyTextTrack, |
97 base::Unretained(this), | 98 base::Unretained(this), |
98 text_tracks_.size()); | 99 text_tracks_.size()); |
99 // Text track objects are owned by the text renderer, but we cache them | 100 // Text track objects are owned by the text renderer, but we cache them |
100 // here so we can inspect them. They get removed from our cache when the | 101 // here so we can inspect them. They get removed from our cache when the |
101 // text renderer deallocates them. | 102 // text renderer deallocates them. |
102 text_tracks_.push_back(new FakeTextTrack(destroy_cb, config)); | 103 text_tracks_.push_back(new FakeTextTrack(destroy_cb, config)); |
103 scoped_ptr<TextTrack> text_track(text_tracks_.back()); | 104 std::unique_ptr<TextTrack> text_track(text_tracks_.back()); |
104 done_cb.Run(std::move(text_track)); | 105 done_cb.Run(std::move(text_track)); |
105 } | 106 } |
106 | 107 |
107 void RemoveTextTrack(unsigned idx) { | 108 void RemoveTextTrack(unsigned idx) { |
108 FakeTextTrackStream* const stream = text_track_streams_[idx]; | 109 FakeTextTrackStream* const stream = text_track_streams_[idx]; |
109 text_renderer_->RemoveTextStream(stream); | 110 text_renderer_->RemoveTextStream(stream); |
110 EXPECT_FALSE(text_tracks_[idx]); | 111 EXPECT_FALSE(text_tracks_[idx]); |
111 } | 112 } |
112 | 113 |
113 void SatisfyPendingReads(const base::TimeDelta& start, | 114 void SatisfyPendingReads(const base::TimeDelta& start, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 MOCK_METHOD0(OnFlush, void()); | 204 MOCK_METHOD0(OnFlush, void()); |
204 | 205 |
205 base::MessageLoop message_loop_; | 206 base::MessageLoop message_loop_; |
206 | 207 |
207 typedef ScopedVector<FakeTextTrackStream> TextTrackStreams; | 208 typedef ScopedVector<FakeTextTrackStream> TextTrackStreams; |
208 TextTrackStreams text_track_streams_; | 209 TextTrackStreams text_track_streams_; |
209 | 210 |
210 typedef std::vector<FakeTextTrack*> TextTracks; | 211 typedef std::vector<FakeTextTrack*> TextTracks; |
211 TextTracks text_tracks_; | 212 TextTracks text_tracks_; |
212 | 213 |
213 scoped_ptr<TextRenderer> text_renderer_; | 214 std::unique_ptr<TextRenderer> text_renderer_; |
214 | 215 |
215 private: | 216 private: |
216 DISALLOW_COPY_AND_ASSIGN(TextRendererTest); | 217 DISALLOW_COPY_AND_ASSIGN(TextRendererTest); |
217 }; | 218 }; |
218 | 219 |
219 TEST_F(TextRendererTest, CreateTextRendererNoInit) { | 220 TEST_F(TextRendererTest, CreateTextRendererNoInit) { |
220 text_renderer_.reset( | 221 text_renderer_.reset( |
221 new TextRenderer(message_loop_.task_runner(), | 222 new TextRenderer(message_loop_.task_runner(), |
222 base::Bind(&TextRendererTest::OnAddTextTrack, | 223 base::Bind(&TextRendererTest::OnAddTextTrack, |
223 base::Unretained(this)))); | 224 base::Unretained(this)))); |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 Play(); | 1205 Play(); |
1205 AbortPendingRead(0); | 1206 AbortPendingRead(0); |
1206 RemoveTextTrack(0); | 1207 RemoveTextTrack(0); |
1207 EXPECT_TRUE(text_renderer_->HasTracks()); | 1208 EXPECT_TRUE(text_renderer_->HasTracks()); |
1208 Pause(); | 1209 Pause(); |
1209 EXPECT_CALL(*this, OnPause()); | 1210 EXPECT_CALL(*this, OnPause()); |
1210 SendEosNotification(1); | 1211 SendEosNotification(1); |
1211 } | 1212 } |
1212 | 1213 |
1213 } // namespace media | 1214 } // namespace media |
OLD | NEW |