summaryrefslogtreecommitdiffstats
path: root/media/base
diff options
context:
space:
mode:
authorxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-24 12:44:17 +0000
committerxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-24 12:44:17 +0000
commit79e1dc33312c9d2a015af379af038466c6813313 (patch)
treeb93311b5f8cfabf77852e089098ce3edea15d5d8 /media/base
parent4375ae01768ce1032f0f6345da5c26f2934a3d77 (diff)
downloadchromium_src-79e1dc33312c9d2a015af379af038466c6813313.zip
chromium_src-79e1dc33312c9d2a015af379af038466c6813313.tar.gz
chromium_src-79e1dc33312c9d2a015af379af038466c6813313.tar.bz2
Fold TextRenderer::Stop() into the dtor.
BUG=349211 TEST=All existing tests pass. Review URL: https://codereview.chromium.org/416713002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285213 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r--media/base/pipeline.cc16
-rw-r--r--media/base/pipeline_unittest.cc1
-rw-r--r--media/base/text_renderer.cc58
-rw-r--r--media/base/text_renderer.h23
-rw-r--r--media/base/text_renderer_unittest.cc205
5 files changed, 40 insertions, 263 deletions
diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc
index e11fe32..705a3eb 100644
--- a/media/base/pipeline.cc
+++ b/media/base/pipeline.cc
@@ -497,20 +497,14 @@ void Pipeline::DoStop(const PipelineStatusCB& done_cb) {
audio_renderer_.reset();
video_renderer_.reset();
-
- SerialRunner::Queue bound_fns;
+ text_renderer_.reset();
if (demuxer_) {
- bound_fns.Push(base::Bind(
- &Demuxer::Stop, base::Unretained(demuxer_)));
- }
-
- if (text_renderer_) {
- bound_fns.Push(base::Bind(
- &TextRenderer::Stop, base::Unretained(text_renderer_.get())));
+ demuxer_->Stop(base::Bind(done_cb, PIPELINE_OK));
+ return;
}
- pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb);
+ task_runner_->PostTask(FROM_HERE, base::Bind(done_cb, PIPELINE_OK));
}
void Pipeline::OnStopCompleted(PipelineStatus status) {
@@ -518,6 +512,7 @@ void Pipeline::OnStopCompleted(PipelineStatus status) {
DCHECK_EQ(state_, kStopping);
DCHECK(!audio_renderer_);
DCHECK(!video_renderer_);
+ DCHECK(!text_renderer_);
{
base::AutoLock l(lock_);
running_ = false;
@@ -526,7 +521,6 @@ void Pipeline::OnStopCompleted(PipelineStatus status) {
SetState(kStopped);
pending_callbacks_.reset();
filter_collection_.reset();
- text_renderer_.reset();
demuxer_ = NULL;
// If we stop during initialization/seeking we want to run |seek_cb_|
diff --git a/media/base/pipeline_unittest.cc b/media/base/pipeline_unittest.cc
index 6a12a11..f7d0ec9 100644
--- a/media/base/pipeline_unittest.cc
+++ b/media/base/pipeline_unittest.cc
@@ -1093,6 +1093,7 @@ class PipelineTeardownTest : public PipelineTest {
break;
case kErrorAndStop:
+ EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_READ));
EXPECT_CALL(callbacks_, OnStop());
pipeline_->SetErrorForTesting(PIPELINE_ERROR_READ);
pipeline_->Stop(base::Bind(
diff --git a/media/base/text_renderer.cc b/media/base/text_renderer.cc
index 3a04348..29638f3 100644
--- a/media/base/text_renderer.cc
+++ b/media/base/text_renderer.cc
@@ -27,10 +27,10 @@ TextRenderer::TextRenderer(
weak_factory_(this) {}
TextRenderer::~TextRenderer() {
- DCHECK(state_ == kUninitialized ||
- state_ == kStopped) << "state_ " << state_;
- DCHECK_EQ(pending_read_count_, 0);
+ DCHECK(task_runner_->BelongsToCurrentThread());
STLDeleteValues(&text_track_state_map_);
+ if (!pause_cb_.is_null())
+ base::ResetAndReturn(&pause_cb_).Run();
}
void TextRenderer::Initialize(const base::Closure& ended_cb) {
@@ -68,14 +68,14 @@ void TextRenderer::Pause(const base::Closure& callback) {
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(state_ == kPlaying || state_ == kEnded) << "state_ " << state_;
DCHECK_GE(pending_read_count_, 0);
- pause_cb_ = callback;
if (pending_read_count_ == 0) {
state_ = kPaused;
- base::ResetAndReturn(&pause_cb_).Run();
+ task_runner_->PostTask(FROM_HERE, callback);
return;
}
+ pause_cb_ = callback;
state_ = kPausePending;
}
@@ -90,35 +90,13 @@ void TextRenderer::Flush(const base::Closure& callback) {
itr->second->text_ranges_.Reset();
}
DCHECK_EQ(pending_eos_set_.size(), text_track_state_map_.size());
- callback.Run();
-}
-
-void TextRenderer::Stop(const base::Closure& cb) {
- DCHECK(task_runner_->BelongsToCurrentThread());
- DCHECK(!cb.is_null());
- DCHECK(state_ == kPlaying ||
- state_ == kPausePending ||
- state_ == kPaused ||
- state_ == kEnded) << "state_ " << state_;
- DCHECK_GE(pending_read_count_, 0);
-
- stop_cb_ = cb;
-
- if (pending_read_count_ == 0) {
- state_ = kStopped;
- base::ResetAndReturn(&stop_cb_).Run();
- return;
- }
-
- state_ = kStopPending;
+ task_runner_->PostTask(FROM_HERE, callback);
}
void TextRenderer::AddTextStream(DemuxerStream* text_stream,
const TextTrackConfig& config) {
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(state_ != kUninitialized) << "state_ " << state_;
- DCHECK_NE(state_, kStopPending);
- DCHECK_NE(state_, kStopped);
DCHECK(text_track_state_map_.find(text_stream) ==
text_track_state_map_.end());
DCHECK(pending_eos_set_.find(text_stream) ==
@@ -184,16 +162,7 @@ void TextRenderer::BufferReady(
return;
- case kStopPending:
- if (pending_read_count_ == 0) {
- state_ = kStopped;
- base::ResetAndReturn(&stop_cb_).Run();
- }
-
- return;
-
case kPaused:
- case kStopped:
case kUninitialized:
case kEnded:
NOTREACHED();
@@ -239,8 +208,7 @@ void TextRenderer::CueReady(
DemuxerStream* text_stream,
const scoped_refptr<TextCue>& text_cue) {
DCHECK(task_runner_->BelongsToCurrentThread());
- DCHECK(state_ != kUninitialized &&
- state_ != kStopped) << "state_ " << state_;
+ DCHECK_NE(state_, kUninitialized);
DCHECK_GT(pending_read_count_, 0);
DCHECK(pending_eos_set_.find(text_stream) != pending_eos_set_.end());
@@ -289,16 +257,8 @@ void TextRenderer::CueReady(
return;
}
- case kStopPending:
- if (pending_read_count_ == 0) {
- state_ = kStopped;
- base::ResetAndReturn(&stop_cb_).Run();
- }
-
- return;
case kPaused:
- case kStopped:
case kUninitialized:
case kEnded:
NOTREACHED();
@@ -331,9 +291,7 @@ void TextRenderer::CueReady(
void TextRenderer::OnAddTextTrackDone(DemuxerStream* text_stream,
scoped_ptr<TextTrack> text_track) {
DCHECK(task_runner_->BelongsToCurrentThread());
- DCHECK(state_ != kUninitialized &&
- state_ != kStopped &&
- state_ != kStopPending) << "state_ " << state_;
+ DCHECK_NE(state_, kUninitialized);
DCHECK(text_stream);
DCHECK(text_track);
diff --git a/media/base/text_renderer.h b/media/base/text_renderer.h
index 7e719db..5890952 100644
--- a/media/base/text_renderer.h
+++ b/media/base/text_renderer.h
@@ -38,32 +38,30 @@ class MEDIA_EXPORT TextRenderer {
TextRenderer(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
const AddTextTrackCB& add_text_track_cb);
+
+ // Stops all operations and fires all pending callbacks.
~TextRenderer();
// |ended_cb| is executed when all of the text tracks have reached
// end of stream, following a play request.
void Initialize(const base::Closure& ended_cb);
- // Start text track cue decoding and rendering.
+ // Starts text track cue decoding and rendering.
void StartPlaying();
- // Temporarily suspend decoding and rendering, executing |callback| when
+ // Temporarily suspends decoding and rendering, executing |callback| when
// playback has been suspended.
void Pause(const base::Closure& callback);
- // Discard any text data, executing |callback| when completed.
+ // Discards any text data, executing |callback| when completed.
void Flush(const base::Closure& callback);
- // Stop all operations in preparation for being deleted, executing |callback|
- // when complete.
- void Stop(const base::Closure& callback);
-
- // Add new |text_stream|, having the indicated |config|, to the text stream
+ // Adds new |text_stream|, having the indicated |config|, to the text stream
// collection managed by this text renderer.
void AddTextStream(DemuxerStream* text_stream,
const TextTrackConfig& config);
- // Remove |text_stream| from the text stream collection.
+ // Removes |text_stream| from the text stream collection.
void RemoveTextStream(DemuxerStream* text_stream);
// Returns true if there are extant text tracks.
@@ -112,18 +110,13 @@ class MEDIA_EXPORT TextRenderer {
// Callback provided to Pause().
base::Closure pause_cb_;
- // Callback provided to Stop().
- base::Closure stop_cb_;
-
// Simple state tracking variable.
enum State {
kUninitialized,
kPausePending,
kPaused,
kPlaying,
- kEnded,
- kStopPending,
- kStopped
+ kEnded
};
State state_;
diff --git a/media/base/text_renderer_unittest.cc b/media/base/text_renderer_unittest.cc
index 2c31c92..3b9e95a 100644
--- a/media/base/text_renderer_unittest.cc
+++ b/media/base/text_renderer_unittest.cc
@@ -19,11 +19,6 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-using ::testing::Eq;
-using ::testing::Exactly;
-using ::testing::Invoke;
-using ::testing::_;
-
namespace media {
// Local implementation of the TextTrack interface.
@@ -66,14 +61,9 @@ class TextRendererTest : public testing::Test {
base::Unretained(this)));
}
- void DestroyTextRenderer() {
- EXPECT_CALL(*this, OnStop());
- text_renderer_->Stop(base::Bind(&TextRendererTest::OnStop,
- base::Unretained(this)));
- message_loop_.RunUntilIdle();
-
+ void Destroy() {
text_renderer_.reset();
- text_track_streams_.clear();
+ message_loop_.RunUntilIdle();
}
void AddTextTrack(TextKind kind,
@@ -199,23 +189,15 @@ class TextRendererTest : public testing::Test {
base::Unretained(this)));
}
- void Stop() {
- text_renderer_->Stop(base::Bind(&TextRendererTest::OnStop,
- base::Unretained(this)));
- message_loop_.RunUntilIdle();
- }
-
void ExpectRead(size_t idx) {
FakeTextTrackStream* const stream = text_track_streams_[idx];
EXPECT_CALL(*stream, OnRead());
}
MOCK_METHOD0(OnEnd, void());
- MOCK_METHOD0(OnStop, void());
MOCK_METHOD0(OnPause, void());
MOCK_METHOD0(OnFlush, void());
- scoped_ptr<TextRenderer> text_renderer_;
base::MessageLoop message_loop_;
typedef ScopedVector<FakeTextTrackStream> TextTrackStreams;
@@ -224,6 +206,8 @@ class TextRendererTest : public testing::Test {
typedef std::vector<FakeTextTrack*> TextTracks;
TextTracks text_tracks_;
+ scoped_ptr<TextRenderer> text_renderer_;
+
private:
DISALLOW_COPY_AND_ASSIGN(TextRendererTest);
};
@@ -236,28 +220,24 @@ TEST_F(TextRendererTest, CreateTextRendererNoInit) {
text_renderer_.reset();
}
-TEST_F(TextRendererTest, TestStop) {
+TEST_F(TextRendererTest, Create) {
CreateTextRenderer();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTextTrackOnly_OneTrack) {
CreateTextRenderer();
AddTextTrack(kTextSubtitles, "", "", false);
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTextTrackOnly_TwoTracks) {
CreateTextRenderer();
AddTextTrack(kTextSubtitles, "track 1", "", false);
AddTextTrack(kTextSubtitles, "track 2", "", false);
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayOnly) {
CreateTextRenderer();
Play();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackBeforePlay_OneTrack) {
@@ -265,7 +245,6 @@ TEST_F(TextRendererTest, AddTrackBeforePlay_OneTrack) {
AddTextTrack(kTextSubtitles, "", "", true);
Play();
AbortPendingReads();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackBeforePlay_TwoTracks) {
@@ -274,7 +253,6 @@ TEST_F(TextRendererTest, AddTrackBeforePlay_TwoTracks) {
AddTextTrack(kTextSubtitles, "2", "", true);
Play();
AbortPendingReads();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackAfterPlay_OneTrackAfter) {
@@ -282,7 +260,6 @@ TEST_F(TextRendererTest, AddTrackAfterPlay_OneTrackAfter) {
Play();
AddTextTrack(kTextSubtitles, "", "", true);
AbortPendingReads();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackAfterPlay_TwoTracksAfter) {
@@ -291,7 +268,6 @@ TEST_F(TextRendererTest, AddTrackAfterPlay_TwoTracksAfter) {
AddTextTrack(kTextSubtitles, "1", "", true);
AddTextTrack(kTextSubtitles, "2", "", true);
AbortPendingReads();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackAfterPlay_OneTrackBeforeOneTrackAfter) {
@@ -300,7 +276,6 @@ TEST_F(TextRendererTest, AddTrackAfterPlay_OneTrackBeforeOneTrackAfter) {
Play();
AddTextTrack(kTextSubtitles, "2", "", true);
AbortPendingReads();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayAddCue_OneTrack) {
@@ -310,7 +285,6 @@ TEST_F(TextRendererTest, PlayAddCue_OneTrack) {
ExpectRead(0);
SendCues(true);
AbortPendingReads();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayAddCue_TwoTracks) {
@@ -322,7 +296,6 @@ TEST_F(TextRendererTest, PlayAddCue_TwoTracks) {
ExpectRead(1);
SendCues(true);
AbortPendingReads();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosOnly_OneTrack) {
@@ -331,7 +304,6 @@ TEST_F(TextRendererTest, PlayEosOnly_OneTrack) {
Play();
EXPECT_CALL(*this, OnEnd());
SendEosNotifications();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosOnly_TwoTracks) {
@@ -341,7 +313,6 @@ TEST_F(TextRendererTest, PlayEosOnly_TwoTracks) {
Play();
EXPECT_CALL(*this, OnEnd());
SendEosNotifications();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayCueEos_OneTrack) {
@@ -352,7 +323,6 @@ TEST_F(TextRendererTest, PlayCueEos_OneTrack) {
SendCues(true);
EXPECT_CALL(*this, OnEnd());
SendEosNotifications();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayCueEos_TwoTracks) {
@@ -365,30 +335,23 @@ TEST_F(TextRendererTest, PlayCueEos_TwoTracks) {
SendCues(true);
EXPECT_CALL(*this, OnEnd());
SendEosNotifications();
- DestroyTextRenderer();
}
-TEST_F(TextRendererTest, StopPending_OneTrack) {
+TEST_F(TextRendererTest, DestroyPending_OneTrack) {
CreateTextRenderer();
AddTextTrack(kTextSubtitles, "", "", true);
Play();
- Stop();
- EXPECT_CALL(*this, OnStop());
+ Destroy();
SendEosNotifications();
- text_renderer_.reset();
- text_track_streams_.clear();
}
-TEST_F(TextRendererTest, StopPending_TwoTracks) {
+TEST_F(TextRendererTest, DestroyPending_TwoTracks) {
CreateTextRenderer();
AddTextTrack(kTextSubtitles, "1", "", true);
AddTextTrack(kTextSubtitles, "2", "", true);
Play();
- Stop();
- EXPECT_CALL(*this, OnStop());
+ Destroy();
SendEosNotifications();
- text_renderer_.reset();
- text_track_streams_.clear();
}
TEST_F(TextRendererTest, PlayPause_OneTrack) {
@@ -398,7 +361,6 @@ TEST_F(TextRendererTest, PlayPause_OneTrack) {
AbortPendingReads();
EXPECT_CALL(*this, OnPause());
Pause();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayPause_TwoTracks) {
@@ -409,7 +371,6 @@ TEST_F(TextRendererTest, PlayPause_TwoTracks) {
AbortPendingReads();
EXPECT_CALL(*this, OnPause());
Pause();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPausePending_OneTrack) {
@@ -419,7 +380,6 @@ TEST_F(TextRendererTest, PlayEosPausePending_OneTrack) {
Pause();
EXPECT_CALL(*this, OnPause());
SendEosNotifications();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPausePending_TwoTracks) {
@@ -430,7 +390,6 @@ TEST_F(TextRendererTest, PlayEosPausePending_TwoTracks) {
Pause();
EXPECT_CALL(*this, OnPause());
SendEosNotifications();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayCuePausePending_OneTrack) {
@@ -440,7 +399,6 @@ TEST_F(TextRendererTest, PlayCuePausePending_OneTrack) {
Pause();
EXPECT_CALL(*this, OnPause());
SendCues(true);
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayCuePausePending_TwoTracks) {
@@ -451,7 +409,6 @@ TEST_F(TextRendererTest, PlayCuePausePending_TwoTracks) {
Pause();
EXPECT_CALL(*this, OnPause());
SendCues(true);
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPause_OneTrack) {
@@ -462,7 +419,6 @@ TEST_F(TextRendererTest, PlayEosPause_OneTrack) {
SendEosNotifications();
EXPECT_CALL(*this, OnPause());
Pause();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPause_TwoTracks) {
@@ -474,7 +430,6 @@ TEST_F(TextRendererTest, PlayEosPause_TwoTracks) {
SendEosNotifications();
EXPECT_CALL(*this, OnPause());
Pause();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPause_SplitEos) {
@@ -487,7 +442,6 @@ TEST_F(TextRendererTest, PlayEosPause_SplitEos) {
SendEosNotification(1);
EXPECT_CALL(*this, OnPause());
Pause();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosFlush_OneTrack) {
@@ -503,7 +457,6 @@ TEST_F(TextRendererTest, PlayEosFlush_OneTrack) {
Play();
EXPECT_CALL(*this, OnEnd());
SendEosNotifications();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosFlush_TwoTracks) {
@@ -521,14 +474,12 @@ TEST_F(TextRendererTest, PlayEosFlush_TwoTracks) {
Play();
EXPECT_CALL(*this, OnEnd());
SendEosNotifications();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTextTrackOnlyRemove_OneTrack) {
CreateTextRenderer();
AddTextTrack(kTextSubtitles, "", "", false);
EXPECT_TRUE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTextTrackOnlyRemove_TwoTracks) {
@@ -539,7 +490,6 @@ TEST_F(TextRendererTest, AddTextTrackOnlyRemove_TwoTracks) {
EXPECT_TRUE(text_renderer_->HasTracks());
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackBeforePlayRemove_OneTrack) {
@@ -549,7 +499,6 @@ TEST_F(TextRendererTest, AddTrackBeforePlayRemove_OneTrack) {
AbortPendingReads();
RemoveTextTrack(0);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackBeforePlayRemove_TwoTracks) {
@@ -562,7 +511,6 @@ TEST_F(TextRendererTest, AddTrackBeforePlayRemove_TwoTracks) {
EXPECT_TRUE(text_renderer_->HasTracks());
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackBeforePlayRemove_SeparateCancel) {
@@ -576,7 +524,6 @@ TEST_F(TextRendererTest, AddTrackBeforePlayRemove_SeparateCancel) {
AbortPendingRead(1);
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackBeforePlayRemove_RemoveOneThenPlay) {
@@ -589,7 +536,6 @@ TEST_F(TextRendererTest, AddTrackBeforePlayRemove_RemoveOneThenPlay) {
AbortPendingRead(1);
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackBeforePlayRemove_RemoveTwoThenPlay) {
@@ -601,7 +547,6 @@ TEST_F(TextRendererTest, AddTrackBeforePlayRemove_RemoveTwoThenPlay) {
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
Play();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackAfterPlayRemove_OneTrack) {
@@ -611,7 +556,6 @@ TEST_F(TextRendererTest, AddTrackAfterPlayRemove_OneTrack) {
AbortPendingReads();
RemoveTextTrack(0);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackAfterPlayRemove_TwoTracks) {
@@ -624,7 +568,6 @@ TEST_F(TextRendererTest, AddTrackAfterPlayRemove_TwoTracks) {
EXPECT_TRUE(text_renderer_->HasTracks());
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackAfterPlayRemove_SplitCancel) {
@@ -638,7 +581,6 @@ TEST_F(TextRendererTest, AddTrackAfterPlayRemove_SplitCancel) {
AbortPendingRead(1);
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddTrackAfterPlayRemove_SplitAdd) {
@@ -652,7 +594,6 @@ TEST_F(TextRendererTest, AddTrackAfterPlayRemove_SplitAdd) {
AbortPendingRead(1);
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayAddCueRemove_OneTrack) {
@@ -664,7 +605,6 @@ TEST_F(TextRendererTest, PlayAddCueRemove_OneTrack) {
AbortPendingReads();
RemoveTextTrack(0);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayAddCueRemove_TwoTracks) {
@@ -681,7 +621,6 @@ TEST_F(TextRendererTest, PlayAddCueRemove_TwoTracks) {
EXPECT_TRUE(text_renderer_->HasTracks());
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosOnlyRemove_OneTrack) {
@@ -692,7 +631,6 @@ TEST_F(TextRendererTest, PlayEosOnlyRemove_OneTrack) {
SendEosNotifications();
RemoveTextTrack(0);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosOnlyRemove_TwoTracks) {
@@ -706,7 +644,6 @@ TEST_F(TextRendererTest, PlayEosOnlyRemove_TwoTracks) {
EXPECT_TRUE(text_renderer_->HasTracks());
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayCueEosRemove_OneTrack) {
@@ -719,7 +656,6 @@ TEST_F(TextRendererTest, PlayCueEosRemove_OneTrack) {
SendEosNotifications();
RemoveTextTrack(0);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayCueEosRemove_TwoTracks) {
@@ -736,54 +672,6 @@ TEST_F(TextRendererTest, PlayCueEosRemove_TwoTracks) {
EXPECT_TRUE(text_renderer_->HasTracks());
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
-}
-
-TEST_F(TextRendererTest, TestStopPendingRemove_OneTrack) {
- CreateTextRenderer();
- AddTextTrack(kTextSubtitles, "", "", true);
- Play();
- Stop();
- EXPECT_CALL(*this, OnStop());
- SendEosNotifications();
- RemoveTextTrack(0);
- EXPECT_FALSE(text_renderer_->HasTracks());
- text_renderer_.reset();
- text_track_streams_.clear();
-}
-
-TEST_F(TextRendererTest, TestStopPendingRemove_TwoTracks) {
- CreateTextRenderer();
- AddTextTrack(kTextSubtitles, "1", "", true);
- AddTextTrack(kTextSubtitles, "2", "", true);
- Play();
- Stop();
- SendEosNotification(0);
- EXPECT_CALL(*this, OnStop());
- SendEosNotification(1);
- RemoveTextTrack(0);
- EXPECT_TRUE(text_renderer_->HasTracks());
- RemoveTextTrack(1);
- EXPECT_FALSE(text_renderer_->HasTracks());
- text_renderer_.reset();
- text_track_streams_.clear();
-}
-
-TEST_F(TextRendererTest, TestStopPendingRemove_RemoveThenSendEos) {
- CreateTextRenderer();
- AddTextTrack(kTextSubtitles, "1", "", true);
- AddTextTrack(kTextSubtitles, "2", "", true);
- Play();
- Stop();
- SendEosNotification(0);
- RemoveTextTrack(0);
- EXPECT_TRUE(text_renderer_->HasTracks());
- EXPECT_CALL(*this, OnStop());
- SendEosNotification(1);
- RemoveTextTrack(1);
- EXPECT_FALSE(text_renderer_->HasTracks());
- text_renderer_.reset();
- text_track_streams_.clear();
}
TEST_F(TextRendererTest, PlayPauseRemove_PauseThenRemove) {
@@ -795,7 +683,6 @@ TEST_F(TextRendererTest, PlayPauseRemove_PauseThenRemove) {
Pause();
RemoveTextTrack(0);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayPauseRemove_RemoveThanPause) {
@@ -807,7 +694,6 @@ TEST_F(TextRendererTest, PlayPauseRemove_RemoveThanPause) {
EXPECT_FALSE(text_renderer_->HasTracks());
EXPECT_CALL(*this, OnPause());
Pause();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayPause_PauseThenRemoveTwoTracks) {
@@ -822,7 +708,6 @@ TEST_F(TextRendererTest, PlayPause_PauseThenRemoveTwoTracks) {
EXPECT_TRUE(text_renderer_->HasTracks());
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayPauseRemove_RemoveThenPauseTwoTracks) {
@@ -837,7 +722,6 @@ TEST_F(TextRendererTest, PlayPauseRemove_RemoveThenPauseTwoTracks) {
Pause();
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayPauseRemove_SplitCancel) {
@@ -853,7 +737,6 @@ TEST_F(TextRendererTest, PlayPauseRemove_SplitCancel) {
Pause();
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
@@ -870,7 +753,6 @@ TEST_F(TextRendererTest, PlayPauseRemove_PauseLast) {
EXPECT_FALSE(text_renderer_->HasTracks());
EXPECT_CALL(*this, OnPause());
Pause();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPausePendingRemove_OneTrack) {
@@ -882,7 +764,6 @@ TEST_F(TextRendererTest, PlayEosPausePendingRemove_OneTrack) {
SendEosNotifications();
RemoveTextTrack(0);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPausePendingRemove_TwoTracks) {
@@ -898,7 +779,6 @@ TEST_F(TextRendererTest, PlayEosPausePendingRemove_TwoTracks) {
EXPECT_TRUE(text_renderer_->HasTracks());
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPausePendingRemove_SplitEos) {
@@ -914,7 +794,6 @@ TEST_F(TextRendererTest, PlayEosPausePendingRemove_SplitEos) {
SendEosNotification(1);
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayCuePausePendingRemove_OneTrack) {
@@ -926,7 +805,6 @@ TEST_F(TextRendererTest, PlayCuePausePendingRemove_OneTrack) {
SendCues(true);
RemoveTextTrack(0);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayCuePausePendingRemove_TwoTracks) {
@@ -942,7 +820,6 @@ TEST_F(TextRendererTest, PlayCuePausePendingRemove_TwoTracks) {
EXPECT_TRUE(text_renderer_->HasTracks());
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayCuePausePendingRemove_SplitSendCue) {
@@ -958,7 +835,6 @@ TEST_F(TextRendererTest, PlayCuePausePendingRemove_SplitSendCue) {
SendCue(1, true);
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPauseRemove_PauseThenRemove) {
@@ -971,7 +847,6 @@ TEST_F(TextRendererTest, PlayEosPauseRemove_PauseThenRemove) {
Pause();
RemoveTextTrack(0);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPauseRemove_RemoveThenPause) {
@@ -984,7 +859,6 @@ TEST_F(TextRendererTest, PlayEosPauseRemove_RemoveThenPause) {
EXPECT_FALSE(text_renderer_->HasTracks());
EXPECT_CALL(*this, OnPause());
Pause();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPause_PauseThenRemoveTwoTracks) {
@@ -1001,7 +875,6 @@ TEST_F(TextRendererTest, PlayEosPause_PauseThenRemoveTwoTracks) {
EXPECT_TRUE(text_renderer_->HasTracks());
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPause_RemovePauseRemove) {
@@ -1018,7 +891,6 @@ TEST_F(TextRendererTest, PlayEosPause_RemovePauseRemove) {
Pause();
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPause_EosThenPause) {
@@ -1035,7 +907,6 @@ TEST_F(TextRendererTest, PlayEosPause_EosThenPause) {
Pause();
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPause_PauseLast) {
@@ -1052,7 +923,6 @@ TEST_F(TextRendererTest, PlayEosPause_PauseLast) {
EXPECT_FALSE(text_renderer_->HasTracks());
EXPECT_CALL(*this, OnPause());
Pause();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPause_EosPauseRemove) {
@@ -1069,7 +939,6 @@ TEST_F(TextRendererTest, PlayEosPause_EosPauseRemove) {
EXPECT_TRUE(text_renderer_->HasTracks());
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPause_EosRemovePause) {
@@ -1086,7 +955,6 @@ TEST_F(TextRendererTest, PlayEosPause_EosRemovePause) {
Pause();
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPause_EosRemoveEosPause) {
@@ -1103,7 +971,6 @@ TEST_F(TextRendererTest, PlayEosPause_EosRemoveEosPause) {
Pause();
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosPause_EosRemoveEosRemovePause) {
@@ -1120,7 +987,6 @@ TEST_F(TextRendererTest, PlayEosPause_EosRemoveEosRemovePause) {
EXPECT_FALSE(text_renderer_->HasTracks());
EXPECT_CALL(*this, OnPause());
Pause();
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosFlushRemove_OneTrack) {
@@ -1138,7 +1004,6 @@ TEST_F(TextRendererTest, PlayEosFlushRemove_OneTrack) {
SendEosNotifications();
RemoveTextTrack(0);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosFlushRemove_TwoTracks) {
@@ -1161,7 +1026,6 @@ TEST_F(TextRendererTest, PlayEosFlushRemove_TwoTracks) {
EXPECT_TRUE(text_renderer_->HasTracks());
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayEosFlushRemove_EosRemove) {
@@ -1184,7 +1048,6 @@ TEST_F(TextRendererTest, PlayEosFlushRemove_EosRemove) {
SendEosNotification(1);
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayShort_SendCueThenEos) {
@@ -1196,7 +1059,6 @@ TEST_F(TextRendererTest, PlayShort_SendCueThenEos) {
SendCue(0, true);
EXPECT_CALL(*this, OnPause());
SendEosNotification(1);
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayShort_EosThenSendCue) {
@@ -1208,7 +1070,6 @@ TEST_F(TextRendererTest, PlayShort_EosThenSendCue) {
SendEosNotification(0);
EXPECT_CALL(*this, OnPause());
SendCue(1, true);
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayShortRemove_SendEosRemove) {
@@ -1224,7 +1085,6 @@ TEST_F(TextRendererTest, PlayShortRemove_SendEosRemove) {
EXPECT_TRUE(text_renderer_->HasTracks());
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayShortRemove_SendRemoveEos) {
@@ -1240,7 +1100,6 @@ TEST_F(TextRendererTest, PlayShortRemove_SendRemoveEos) {
SendEosNotification(1);
RemoveTextTrack(1);
EXPECT_FALSE(text_renderer_->HasTracks());
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayCuePausePendingCancel_OneTrack) {
@@ -1250,7 +1109,6 @@ TEST_F(TextRendererTest, PlayCuePausePendingCancel_OneTrack) {
Pause();
EXPECT_CALL(*this, OnPause());
AbortPendingRead(0);
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayCuePausePendingCancel_SendThenCancel) {
@@ -1262,7 +1120,6 @@ TEST_F(TextRendererTest, PlayCuePausePendingCancel_SendThenCancel) {
SendCue(0, true);
EXPECT_CALL(*this, OnPause());
AbortPendingRead(1);
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, PlayCuePausePendingCancel_CancelThenSend) {
@@ -1274,47 +1131,40 @@ TEST_F(TextRendererTest, PlayCuePausePendingCancel_CancelThenSend) {
AbortPendingRead(0);
EXPECT_CALL(*this, OnPause());
SendCue(1, true);
- DestroyTextRenderer();
}
-TEST_F(TextRendererTest, PlayCueStopPendingCancel_OneTrack) {
+TEST_F(TextRendererTest, PlayCueDestroyPendingCancel_OneTrack) {
CreateTextRenderer();
AddTextTrack(kTextSubtitles, "", "", true);
Play();
Pause();
- Stop();
- EXPECT_CALL(*this, OnStop());
+ EXPECT_CALL(*this, OnPause());
+ Destroy();
AbortPendingRead(0);
- text_renderer_.reset();
- text_track_streams_.clear();
}
-TEST_F(TextRendererTest, PlayCueStopPendingCancel_SendThenCancel) {
+TEST_F(TextRendererTest, PlayCueDestroyPendingCancel_SendThenCancel) {
CreateTextRenderer();
AddTextTrack(kTextSubtitles, "1", "", true);
AddTextTrack(kTextSubtitles, "2", "", true);
Play();
Pause();
- Stop();
+ EXPECT_CALL(*this, OnPause());
+ Destroy();
SendCue(0, false);
- EXPECT_CALL(*this, OnStop());
AbortPendingRead(1);
- text_renderer_.reset();
- text_track_streams_.clear();
}
-TEST_F(TextRendererTest, PlayCueStopPendingCancel_CancelThenSend) {
+TEST_F(TextRendererTest, PlayCueDestroyPendingCancel_CancelThenSend) {
CreateTextRenderer();
AddTextTrack(kTextSubtitles, "1", "", true);
AddTextTrack(kTextSubtitles, "2", "", true);
Play();
Pause();
- Stop();
+ EXPECT_CALL(*this, OnPause());
+ Destroy();
AbortPendingRead(0);
- EXPECT_CALL(*this, OnStop());
SendCue(1, false);
- text_renderer_.reset();
- text_track_streams_.clear();
}
TEST_F(TextRendererTest, AddRemoveAdd) {
@@ -1329,7 +1179,6 @@ TEST_F(TextRendererTest, AddRemoveAdd) {
Play();
EXPECT_CALL(*this, OnEnd());
SendEosNotification(1);
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddRemoveEos) {
@@ -1342,7 +1191,6 @@ TEST_F(TextRendererTest, AddRemoveEos) {
EXPECT_TRUE(text_renderer_->HasTracks());
EXPECT_CALL(*this, OnEnd());
SendEosNotification(1);
- DestroyTextRenderer();
}
TEST_F(TextRendererTest, AddRemovePause) {
@@ -1356,23 +1204,6 @@ TEST_F(TextRendererTest, AddRemovePause) {
Pause();
EXPECT_CALL(*this, OnPause());
SendEosNotification(1);
- DestroyTextRenderer();
-}
-
-TEST_F(TextRendererTest, AddRemovePauseStop) {
- CreateTextRenderer();
- AddTextTrack(kTextSubtitles, "1", "", true);
- AddTextTrack(kTextSubtitles, "2", "", true);
- Play();
- AbortPendingRead(0);
- RemoveTextTrack(0);
- EXPECT_TRUE(text_renderer_->HasTracks());
- Pause();
- Stop();
- EXPECT_CALL(*this, OnStop());
- SendEosNotification(1);
- text_renderer_.reset();
- text_track_streams_.clear();
}
} // namespace media