Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: media/filters/pipeline_controller_unittest.cc

Issue 2618883002: [Media, Video] Enable the video track for a new renderer. (Closed)
Patch Set: Immediate resume_cb_, fixed unittests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/filters/pipeline_controller.h" 5 #include "media/filters/pipeline_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 21 matching lines...) Expand all
32 class PipelineControllerTest : public ::testing::Test, public Pipeline::Client { 32 class PipelineControllerTest : public ::testing::Test, public Pipeline::Client {
33 public: 33 public:
34 PipelineControllerTest() 34 PipelineControllerTest()
35 : pipeline_controller_(&pipeline_, 35 : pipeline_controller_(&pipeline_,
36 base::Bind(&PipelineControllerTest::CreateRenderer, 36 base::Bind(&PipelineControllerTest::CreateRenderer,
37 base::Unretained(this)), 37 base::Unretained(this)),
38 base::Bind(&PipelineControllerTest::OnSeeked, 38 base::Bind(&PipelineControllerTest::OnSeeked,
39 base::Unretained(this)), 39 base::Unretained(this)),
40 base::Bind(&PipelineControllerTest::OnSuspended, 40 base::Bind(&PipelineControllerTest::OnSuspended,
41 base::Unretained(this)), 41 base::Unretained(this)),
42 base::Bind(&PipelineControllerTest::OnResumed,
43 base::Unretained(this)),
42 base::Bind(&PipelineControllerTest::OnError, 44 base::Bind(&PipelineControllerTest::OnError,
43 base::Unretained(this))) {} 45 base::Unretained(this))) {}
44 46
45 ~PipelineControllerTest() override {} 47 ~PipelineControllerTest() override {}
46 48
47 PipelineStatusCB StartPipeline(bool is_streaming, bool is_static) { 49 PipelineStatusCB StartPipeline(bool is_streaming, bool is_static) {
48 EXPECT_FALSE(pipeline_controller_.IsStable()); 50 EXPECT_FALSE(pipeline_controller_.IsStable());
49 PipelineStatusCB start_cb; 51 PipelineStatusCB start_cb;
50 EXPECT_CALL(pipeline_, Start(_, _, _, _)).WillOnce(SaveArg<3>(&start_cb)); 52 EXPECT_CALL(pipeline_, Start(_, _, _, _)).WillOnce(SaveArg<3>(&start_cb));
51 pipeline_controller_.Start(&demuxer_, this, is_streaming, is_static); 53 pipeline_controller_.Start(&demuxer_, this, is_streaming, is_static);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 std::unique_ptr<Renderer> CreateRenderer() { 113 std::unique_ptr<Renderer> CreateRenderer() {
112 return std::unique_ptr<Renderer>(); 114 return std::unique_ptr<Renderer>();
113 } 115 }
114 116
115 void OnSeeked(bool time_updated) { 117 void OnSeeked(bool time_updated) {
116 was_seeked_ = true; 118 was_seeked_ = true;
117 last_seeked_time_updated_ = time_updated; 119 last_seeked_time_updated_ = time_updated;
118 } 120 }
119 121
120 void OnSuspended() { was_suspended_ = true; } 122 void OnSuspended() { was_suspended_ = true; }
123 void OnResumed() { was_resumed_ = true; }
121 124
122 // Pipeline::Client overrides 125 // Pipeline::Client overrides
123 void OnError(PipelineStatus status) override { NOTREACHED(); } 126 void OnError(PipelineStatus status) override { NOTREACHED(); }
124 void OnEnded() override {} 127 void OnEnded() override {}
125 void OnMetadata(PipelineMetadata metadata) override {} 128 void OnMetadata(PipelineMetadata metadata) override {}
126 void OnBufferingStateChange(BufferingState state) override {} 129 void OnBufferingStateChange(BufferingState state) override {}
127 void OnDurationChange() override {} 130 void OnDurationChange() override {}
128 void OnAddTextTrack(const TextTrackConfig& config, 131 void OnAddTextTrack(const TextTrackConfig& config,
129 const AddTextTrackDoneCB& done_cb) override {} 132 const AddTextTrackDoneCB& done_cb) override {}
130 void OnWaitingForDecryptionKey() override {} 133 void OnWaitingForDecryptionKey() override {}
131 void OnVideoNaturalSizeChange(const gfx::Size& size) override {} 134 void OnVideoNaturalSizeChange(const gfx::Size& size) override {}
132 void OnVideoOpacityChange(bool opaque) override {} 135 void OnVideoOpacityChange(bool opaque) override {}
133 136
134 base::MessageLoop message_loop_; 137 base::MessageLoop message_loop_;
135 138
136 NiceMock<MockDemuxer> demuxer_; 139 NiceMock<MockDemuxer> demuxer_;
137 StrictMock<MockPipeline> pipeline_; 140 StrictMock<MockPipeline> pipeline_;
138 PipelineController pipeline_controller_; 141 PipelineController pipeline_controller_;
139 142
140 bool was_seeked_ = false; 143 bool was_seeked_ = false;
141 bool last_seeked_time_updated_ = false; 144 bool last_seeked_time_updated_ = false;
142 bool was_suspended_ = false; 145 bool was_suspended_ = false;
146 bool was_resumed_ = false;
143 base::TimeDelta last_resume_time_; 147 base::TimeDelta last_resume_time_;
144 148
145 DISALLOW_COPY_AND_ASSIGN(PipelineControllerTest); 149 DISALLOW_COPY_AND_ASSIGN(PipelineControllerTest);
146 }; 150 };
147 151
148 TEST_F(PipelineControllerTest, Startup) { 152 TEST_F(PipelineControllerTest, Startup) {
149 PipelineStatusCB start_cb = StartPipeline(); 153 PipelineStatusCB start_cb = StartPipeline();
150 EXPECT_FALSE(was_seeked_); 154 EXPECT_FALSE(was_seeked_);
151 155
152 Complete(start_cb); 156 Complete(start_cb);
153 EXPECT_TRUE(was_seeked_); 157 EXPECT_TRUE(was_seeked_);
154 EXPECT_FALSE(last_seeked_time_updated_); 158 EXPECT_FALSE(last_seeked_time_updated_);
155 EXPECT_FALSE(was_suspended_); 159 EXPECT_FALSE(was_suspended_);
156 EXPECT_TRUE(pipeline_controller_.IsStable()); 160 EXPECT_TRUE(pipeline_controller_.IsStable());
157 } 161 }
158 162
159 TEST_F(PipelineControllerTest, SuspendResume) { 163 TEST_F(PipelineControllerTest, SuspendResume) {
160 Complete(StartPipeline()); 164 Complete(StartPipeline());
161 EXPECT_TRUE(was_seeked_); 165 EXPECT_TRUE(was_seeked_);
162 was_seeked_ = false; 166 was_seeked_ = false;
163 167
164 Complete(SuspendPipeline()); 168 Complete(SuspendPipeline());
165 EXPECT_TRUE(was_suspended_); 169 EXPECT_TRUE(was_suspended_);
166 EXPECT_FALSE(pipeline_controller_.IsStable()); 170 EXPECT_FALSE(pipeline_controller_.IsStable());
167 171
168 Complete(ResumePipeline()); 172 Complete(ResumePipeline());
173 EXPECT_TRUE(was_resumed_);
169 EXPECT_TRUE(pipeline_controller_.IsStable()); 174 EXPECT_TRUE(pipeline_controller_.IsStable());
170 175
171 // |was_seeked_| should not be affected by Suspend()/Resume() at all. 176 // |was_seeked_| should not be affected by Suspend()/Resume() at all.
172 EXPECT_FALSE(was_seeked_); 177 EXPECT_FALSE(was_seeked_);
173 } 178 }
174 179
175 TEST_F(PipelineControllerTest, Seek) { 180 TEST_F(PipelineControllerTest, Seek) {
176 // Normal seeking should not result in a cancel. 181 // Normal seeking should not result in a cancel.
177 EXPECT_CALL(demuxer_, CancelPendingSeek(_)).Times(0); 182 EXPECT_CALL(demuxer_, CancelPendingSeek(_)).Times(0);
178 183
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 // Request a seek to the same time again. 324 // Request a seek to the same time again.
320 pipeline_controller_.Seek(seek_time, true); 325 pipeline_controller_.Seek(seek_time, true);
321 base::RunLoop().RunUntilIdle(); 326 base::RunLoop().RunUntilIdle();
322 327
323 // Expect the second seek to trigger when the first seek completes. 328 // Expect the second seek to trigger when the first seek completes.
324 EXPECT_CALL(pipeline_, Seek(seek_time, _)); 329 EXPECT_CALL(pipeline_, Seek(seek_time, _));
325 Complete(seek_cb_1); 330 Complete(seek_cb_1);
326 } 331 }
327 332
328 } // namespace media 333 } // namespace media
OLDNEW
« media/blink/webmediaplayer_impl.cc ('K') | « media/filters/pipeline_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698