1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 #include "base/callback_helpers.h"
7 #include "base/message_loop.h"
8 #include "media/base/composite_filter.h"
9 #include "media/base/mock_callback.h"
10 #include "media/base/mock_filter_host.h"
11 #include "media/base/mock_filters.h"
12 #include "testing/gtest/include/gtest/gtest.h"
15 using ::testing::InSequence
;
16 using ::testing::Return
;
17 using ::testing::SaveArg
;
18 using ::testing::StrictMock
;
22 class CompositeFilterTest
: public testing::Test
{
24 CompositeFilterTest();
25 virtual ~CompositeFilterTest();
27 // Sets up a new CompositeFilter in |composite_|, creates |filter_1_| and
28 // |filter_2_|, and adds these filters to |composite_|.
29 void SetupAndAdd2Filters();
31 // Helper enum that indicates what filter method to call.
40 // Helper method that adds a filter method call expectation based on the value
41 // of |method_to_call|.
43 // |method_to_call| - Indicates which method we expect a call for.
44 // |filter| - The MockFilter to add the expectation to.
45 // |seek_time| - The time to pass to the Seek() call if |method_to_call|
47 void ExpectFilterCall(MethodToCall method_to_call
, MockFilter
* filter
,
48 base::TimeDelta seek_time
);
50 // Helper method that calls a filter method based on the value of
53 // |method_to_call| - Indicates which method to call.
54 // |filter| - The Filter to make the method call on.
55 // |seek_time| - The time to pass to the Seek() call if |method_to_call|
57 // |callback| - The callback object to pass to the method.
58 // |expected_status| - Some filter methods use a PipelineStatusCB instead of
59 // a Closure. For these methods this function
60 // creates a PipelineStatusCB that makes sure the status
61 // passed to the callback matches |expected_status| and
62 // then calls |callback|.
63 void DoFilterCall(MethodToCall method_to_call
, Filter
* filter
,
64 base::TimeDelta seek_time
,
65 const base::Closure
& callback
,
66 PipelineStatus expected_status
);
68 // Creates an expectation sequence based on the value of method_to_call.
70 // |method_to_call| - Indicates which method we want a success sequence for.
71 // |seek_time| - The time to pass in the Seek() call if |method_to_call|
73 void ExpectSuccess(MethodToCall method_to_call
,
74 base::TimeDelta seek_time
= base::TimeDelta());
76 // Issue a Play(), Pause(), Flush(), Stop(), or Seek() on the composite and
77 // verify all the expected calls on the filters.
82 void DoSeek(base::TimeDelta time
);
84 // Issue a Play(), Pause(), Flush(), or Seek() and expect the calls to fail
85 // with a PIPELINE_ERROR_INVALID_STATE error.
87 // |method_to_call| - Indicates whick method to call.
88 // |seek_time| - The time to pass to the Seek() call if |method_to_call|
90 void ExpectInvalidStateFail(MethodToCall method_to_call
,
91 base::TimeDelta seek_time
= base::TimeDelta());
93 // Returns whether |filter_1_cb_| or |filter_1_status_cb_| is set.
94 bool HasFilter1Callback() const;
96 // Run the callback stored in |filter_1_cb_| or |filter_2_status_cb_|.
97 void RunFilter1Callback();
99 // Returns whether |filter_2_cb_| or |filter_2_status_cb_| is set.
100 bool HasFilter2Callback() const;
102 // Run the callback stored in |filter_2_cb_| or |filter_2_status_cb_|.
103 void RunFilter2Callback();
106 MessageLoop message_loop_
;
108 // The composite object being tested.
109 scoped_refptr
<CompositeFilter
> composite_
;
111 // First filter added to the composite.
112 scoped_refptr
<StrictMock
<MockFilter
> > filter_1_
;
114 // Callback passed to |filter_1_| during last Play(), Pause(), Flush(),
116 base::Closure filter_1_cb_
;
118 // Status to pass to |filter_1_status_cb_|.
119 PipelineStatus filter_1_status_
;
121 // Callback passed to |filter_1_| during last Seek() call.
122 PipelineStatusCB filter_1_status_cb_
;
124 // Second filter added to the composite.
125 scoped_refptr
<StrictMock
<MockFilter
> > filter_2_
;
127 // Callback passed to |filter_2_| during last Play(), Pause(), Flush(),
128 // Stop(), or Seek() call.
129 base::Closure filter_2_cb_
;
131 // Status to pass to |filter_2_status_cb_|.
132 PipelineStatus filter_2_status_
;
134 // Callback passed to |filter_2_| during last Seek() call.
135 PipelineStatusCB filter_2_status_cb_
;
137 // FilterHost implementation passed to |composite_| via set_host().
138 scoped_ptr
<StrictMock
<MockFilterHost
> > mock_filter_host_
;
140 DISALLOW_COPY_AND_ASSIGN(CompositeFilterTest
);
143 CompositeFilterTest::CompositeFilterTest() :
144 composite_(new CompositeFilter(message_loop_
.message_loop_proxy())),
145 filter_1_status_(PIPELINE_OK
),
146 filter_2_status_(PIPELINE_OK
),
147 mock_filter_host_(new StrictMock
<MockFilterHost
>()) {
150 CompositeFilterTest::~CompositeFilterTest() {}
152 void CompositeFilterTest::SetupAndAdd2Filters() {
153 mock_filter_host_
.reset(new StrictMock
<MockFilterHost
>());
154 composite_
= new CompositeFilter(message_loop_
.message_loop_proxy());
155 composite_
->set_host(mock_filter_host_
.get());
157 // Setup |filter_1_| and arrange for methods to set
158 // |filter_1_cb_| when they are called.
159 filter_1_
= new StrictMock
<MockFilter
>();
160 filter_1_cb_
.Reset();
161 filter_1_status_
= PIPELINE_OK
;
162 filter_1_status_cb_
.Reset();
163 ON_CALL(*filter_1_
, Play(_
))
164 .WillByDefault(SaveArg
<0>(&filter_1_cb_
));
165 ON_CALL(*filter_1_
, Pause(_
))
166 .WillByDefault(SaveArg
<0>(&filter_1_cb_
));
167 ON_CALL(*filter_1_
, Flush(_
))
168 .WillByDefault(SaveArg
<0>(&filter_1_cb_
));
169 ON_CALL(*filter_1_
, Stop(_
))
170 .WillByDefault(SaveArg
<0>(&filter_1_cb_
));
171 ON_CALL(*filter_1_
, Seek(_
,_
))
172 .WillByDefault(SaveArg
<1>(&filter_1_status_cb_
));
174 // Setup |filter_2_| and arrange for methods to set
175 // |filter_2_cb_| when they are called.
176 filter_2_
= new StrictMock
<MockFilter
>();
177 filter_2_cb_
.Reset();
178 filter_2_status_
= PIPELINE_OK
;
179 filter_2_status_cb_
.Reset();
180 ON_CALL(*filter_2_
, Play(_
))
181 .WillByDefault(SaveArg
<0>(&filter_2_cb_
));
182 ON_CALL(*filter_2_
, Pause(_
))
183 .WillByDefault(SaveArg
<0>(&filter_2_cb_
));
184 ON_CALL(*filter_2_
, Flush(_
))
185 .WillByDefault(SaveArg
<0>(&filter_2_cb_
));
186 ON_CALL(*filter_2_
, Stop(_
))
187 .WillByDefault(SaveArg
<0>(&filter_2_cb_
));
188 ON_CALL(*filter_2_
, Seek(_
,_
))
189 .WillByDefault(SaveArg
<1>(&filter_2_status_cb_
));
191 composite_
->AddFilter(filter_1_
);
192 composite_
->AddFilter(filter_2_
);
195 void CompositeFilterTest::ExpectFilterCall(MethodToCall method_to_call
,
197 base::TimeDelta seek_time
) {
198 switch(method_to_call
) {
200 EXPECT_CALL(*filter
, Play(_
));
203 EXPECT_CALL(*filter
, Pause(_
));
206 EXPECT_CALL(*filter
, Flush(_
));
209 EXPECT_CALL(*filter
, Stop(_
));
212 EXPECT_CALL(*filter
, Seek(seek_time
, _
));
217 void OnStatusCB(PipelineStatus expected_status
, const base::Closure
& callback
,
218 PipelineStatus status
) {
219 EXPECT_EQ(status
, expected_status
);
223 void CompositeFilterTest::DoFilterCall(MethodToCall method_to_call
,
225 base::TimeDelta seek_time
,
226 const base::Closure
& callback
,
227 PipelineStatus expected_status
) {
228 filter_1_status_
= expected_status
;
229 filter_2_status_
= expected_status
;
231 switch(method_to_call
) {
233 filter
->Play(callback
);
236 filter
->Pause(callback
);
239 filter
->Flush(callback
);
242 filter
->Stop(callback
);
245 filter
->Seek(seek_time
, base::Bind(&OnStatusCB
, expected_status
,
251 void CompositeFilterTest::ExpectSuccess(MethodToCall method_to_call
,
252 base::TimeDelta seek_time
) {
255 bool is_parallel_call
= (method_to_call
== FLUSH
);
257 ExpectFilterCall(method_to_call
, filter_1_
.get(), seek_time
);
259 if (is_parallel_call
) {
260 ExpectFilterCall(method_to_call
, filter_2_
.get(), seek_time
);
263 // Make method call on the composite.
264 StrictMock
<MockClosure
>* callback
= new StrictMock
<MockClosure
>();
265 DoFilterCall(method_to_call
, composite_
.get(), seek_time
,
266 base::Bind(&MockClosure::Run
, callback
),
269 if (is_parallel_call
) {
270 // Make sure both filters have their callbacks set.
271 EXPECT_TRUE(HasFilter1Callback());
272 EXPECT_TRUE(HasFilter2Callback());
274 RunFilter1Callback();
276 // Make sure that only |filter_1_| has its callback set.
277 EXPECT_TRUE(HasFilter1Callback());
278 EXPECT_FALSE(HasFilter2Callback());
280 ExpectFilterCall(method_to_call
, filter_2_
.get(), seek_time
);
282 RunFilter1Callback();
284 // Verify that |filter_2_| was called by checking the callback pointer.
285 EXPECT_TRUE(HasFilter2Callback());
288 EXPECT_CALL(*callback
, Run());
290 RunFilter2Callback();
293 void CompositeFilterTest::DoPlay() {
297 void CompositeFilterTest::DoPause() {
298 ExpectSuccess(PAUSE
);
301 void CompositeFilterTest::DoFlush() {
302 ExpectSuccess(FLUSH
);
305 void CompositeFilterTest::DoStop() {
309 void CompositeFilterTest::DoSeek(base::TimeDelta time
) {
310 ExpectSuccess(SEEK
, time
);
313 void CompositeFilterTest::ExpectInvalidStateFail(MethodToCall method_to_call
,
314 base::TimeDelta seek_time
) {
317 if (method_to_call
!= SEEK
) {
318 EXPECT_CALL(*mock_filter_host_
, SetError(PIPELINE_ERROR_INVALID_STATE
))
322 DoFilterCall(method_to_call
, composite_
, seek_time
, NewExpectedClosure(),
323 PIPELINE_ERROR_INVALID_STATE
);
325 // Make sure that neither of the filters were called by
326 // verifying that the callback pointers weren't set.
327 EXPECT_FALSE(HasFilter1Callback());
328 EXPECT_FALSE(HasFilter2Callback());
331 bool CompositeFilterTest::HasFilter1Callback() const {
332 CHECK(filter_1_cb_
.is_null() || filter_1_status_cb_
.is_null());
333 return !filter_1_cb_
.is_null() || !filter_1_status_cb_
.is_null();
336 void CompositeFilterTest::RunFilter1Callback() {
337 EXPECT_TRUE(HasFilter1Callback());
339 if (!filter_1_status_cb_
.is_null()) {
340 base::ResetAndReturn(&filter_1_status_cb_
).Run(filter_1_status_
);
341 filter_1_status_
= PIPELINE_OK
;
345 EXPECT_TRUE(!filter_1_cb_
.is_null());
346 base::Closure callback
= filter_1_cb_
;
347 filter_1_cb_
.Reset();
351 bool CompositeFilterTest::HasFilter2Callback() const {
352 CHECK(filter_2_cb_
.is_null() || filter_2_status_cb_
.is_null());
353 return !filter_2_cb_
.is_null() || !filter_2_status_cb_
.is_null();
356 void CompositeFilterTest::RunFilter2Callback() {
357 EXPECT_TRUE(HasFilter2Callback());
359 if (!filter_2_status_cb_
.is_null()) {
360 base::ResetAndReturn(&filter_2_status_cb_
).Run(filter_2_status_
);
361 filter_2_status_
= PIPELINE_OK
;
365 EXPECT_FALSE(filter_2_cb_
.is_null());
366 base::Closure callback
= filter_2_cb_
;
367 filter_2_cb_
.Reset();
371 // Test successful {Add,Remove}Filter() cases.
372 TEST_F(CompositeFilterTest
, TestAddRemoveFilter
) {
373 composite_
->set_host(mock_filter_host_
.get());
376 scoped_refptr
<StrictMock
<MockFilter
> > filter
= new StrictMock
<MockFilter
>();
377 EXPECT_EQ(NULL
, filter
->host());
379 composite_
->AddFilter(filter
);
380 EXPECT_TRUE(filter
->host() != NULL
);
381 composite_
->RemoveFilter(filter
);
382 EXPECT_TRUE(filter
->host() == NULL
);
385 class CompositeFilterDeathTest
: public CompositeFilterTest
{};
387 // Test AddFilter() failure cases.
388 TEST_F(CompositeFilterDeathTest
, TestAddFilterFailCases
) {
389 // Test adding a null pointer.
390 EXPECT_DEATH_IF_SUPPORTED(composite_
->AddFilter(NULL
), "");
392 scoped_refptr
<StrictMock
<MockFilter
> > filter
= new StrictMock
<MockFilter
>();
393 EXPECT_EQ(NULL
, filter
->host());
395 // Test failing because set_host() hasn't been called yet.
396 EXPECT_DEATH_IF_SUPPORTED(composite_
->AddFilter(filter
), "");
399 // Test failure of RemoveFilter() on an unknown filter.
400 TEST_F(CompositeFilterDeathTest
, TestRemoveUnknownFilter
) {
401 composite_
->set_host(mock_filter_host_
.get());
402 // Remove unknown filter.
403 scoped_refptr
<StrictMock
<MockFilter
> > filter
= new StrictMock
<MockFilter
>();
404 EXPECT_DEATH_IF_SUPPORTED(composite_
->RemoveFilter(filter
), "");
407 TEST_F(CompositeFilterTest
, TestPlay
) {
410 SetupAndAdd2Filters();
412 // Verify successful call to Play().
415 // At this point we are now in the kPlaying state.
417 // Try calling Play() again to make sure that we simply get a callback.
418 // We are already in the Play() state so there is no point calling the
420 composite_
->Play(NewExpectedClosure());
422 // Verify that neither of the filter callbacks were set.
423 EXPECT_FALSE(HasFilter1Callback());
424 EXPECT_FALSE(HasFilter2Callback());
429 // At this point we should be in the kStopped state.
431 // Try calling Stop() again to make sure neither filter is called.
432 composite_
->Stop(NewExpectedClosure());
434 // Verify that neither of the filter callbacks were set.
435 EXPECT_FALSE(HasFilter1Callback());
436 EXPECT_FALSE(HasFilter2Callback());
438 // Try calling Play() again to make sure we get an error.
439 ExpectInvalidStateFail(PLAY
);
442 // Test errors in the middle of a serial call sequence like Play().
443 TEST_F(CompositeFilterTest
, TestPlayErrors
) {
446 SetupAndAdd2Filters();
448 EXPECT_CALL(*filter_1_
, Play(_
));
450 // Call Play() on the composite.
451 StrictMock
<MockClosure
>* callback
= new StrictMock
<MockClosure
>();
452 composite_
->Play(base::Bind(&MockClosure::Run
, callback
));
454 EXPECT_CALL(*filter_2_
, Play(_
));
456 // Run callback to indicate that |filter_1_|'s Play() has completed.
457 RunFilter1Callback();
459 // At this point Play() has been called on |filter_2_|. Simulate an
460 // error by calling SetError() on its FilterHost interface.
461 filter_2_
->host()->SetError(PIPELINE_ERROR_DECODE
);
463 // Expect error to be reported and "play done" callback to be called.
464 EXPECT_CALL(*mock_filter_host_
, SetError(PIPELINE_ERROR_DECODE
));
465 EXPECT_CALL(*callback
, Run());
467 // Run callback to indicate that |filter_2_|'s Play() has completed.
468 RunFilter2Callback();
470 // Verify that Play/Pause/Flush/Seek fail now that an error occured.
471 ExpectInvalidStateFail(PLAY
);
472 ExpectInvalidStateFail(PAUSE
);
473 ExpectInvalidStateFail(FLUSH
);
474 ExpectInvalidStateFail(SEEK
);
476 // Make sure you can still Stop().
480 TEST_F(CompositeFilterTest
, TestPause
) {
483 SetupAndAdd2Filters();
485 // Try calling Pause() to make sure we get an error because we aren't in
486 // the playing state.
487 ExpectInvalidStateFail(PAUSE
);
489 // Transition to playing state.
492 // Issue a successful Pause().
495 // At this point we are paused.
497 // Try calling Pause() again to make sure that the filters aren't called
498 // because we are already in the paused state.
499 composite_
->Pause(NewExpectedClosure());
501 // Verify that neither of the filter callbacks were set.
502 EXPECT_FALSE(HasFilter1Callback());
503 EXPECT_FALSE(HasFilter2Callback());
505 // Verify that we can transition pack to the play state.
508 // Go back to the pause state.
511 // Transition to the stop state.
514 // Try calling Pause() to make sure we get an error because we aren't in
515 // the playing state.
516 ExpectInvalidStateFail(PAUSE
);
519 // Test errors in the middle of a serial call sequence like Pause().
520 TEST_F(CompositeFilterTest
, TestPauseErrors
) {
523 SetupAndAdd2Filters();
527 EXPECT_CALL(*filter_1_
, Pause(_
));
529 // Call Pause() on the composite.
530 StrictMock
<MockClosure
>* callback
= new StrictMock
<MockClosure
>();
531 composite_
->Pause(base::Bind(&MockClosure::Run
, callback
));
533 // Simulate an error by calling SetError() on |filter_1_|'s FilterHost
535 filter_1_
->host()->SetError(PIPELINE_ERROR_DECODE
);
537 // Expect error to be reported and "pause done" callback to be called.
538 EXPECT_CALL(*mock_filter_host_
, SetError(PIPELINE_ERROR_DECODE
));
539 EXPECT_CALL(*callback
, Run());
541 RunFilter1Callback();
543 // Make sure |filter_2_cb_| was not set.
544 EXPECT_FALSE(HasFilter2Callback());
546 // Verify that Play/Pause/Flush/Seek fail now that an error occured.
547 ExpectInvalidStateFail(PLAY
);
548 ExpectInvalidStateFail(PAUSE
);
549 ExpectInvalidStateFail(FLUSH
);
550 ExpectInvalidStateFail(SEEK
);
552 // Make sure you can still Stop().
556 TEST_F(CompositeFilterTest
, TestFlush
) {
559 SetupAndAdd2Filters();
561 // Make sure Flush() works before calling Play().
564 // Transition to playing state.
567 // Call Flush() to make sure we get an error because we are in
568 // the playing state.
569 ExpectInvalidStateFail(FLUSH
);
571 // Issue a successful Pause().
574 // Make sure Flush() works after pausing.
577 // Verify that we can transition back to the play state.
580 // Transition to the stop state.
583 // Try calling Flush() to make sure we get an error because we are stopped.
584 ExpectInvalidStateFail(FLUSH
);
587 // Test errors in the middle of a parallel call sequence like Flush().
588 TEST_F(CompositeFilterTest
, TestFlushErrors
) {
591 SetupAndAdd2Filters();
593 EXPECT_CALL(*filter_1_
, Flush(_
));
594 EXPECT_CALL(*filter_2_
, Flush(_
));
596 // Call Flush() on the composite.
597 StrictMock
<MockClosure
>* callback
= new StrictMock
<MockClosure
>();
598 composite_
->Flush(base::Bind(&MockClosure::Run
, callback
));
600 // Simulate an error by calling SetError() on |filter_1_|'s FilterHost
602 filter_1_
->host()->SetError(PIPELINE_ERROR_DECODE
);
604 RunFilter1Callback();
606 // Expect error to be reported and "pause done" callback to be called.
607 EXPECT_CALL(*mock_filter_host_
, SetError(PIPELINE_ERROR_DECODE
));
608 EXPECT_CALL(*callback
, Run());
610 RunFilter2Callback();
612 // Verify that Play/Pause/Flush/Seek fail now that an error occured.
613 ExpectInvalidStateFail(PLAY
);
614 ExpectInvalidStateFail(PAUSE
);
615 ExpectInvalidStateFail(FLUSH
);
616 ExpectInvalidStateFail(SEEK
);
618 // Make sure you can still Stop().
622 TEST_F(CompositeFilterTest
, TestSeek
) {
625 SetupAndAdd2Filters();
627 // Verify that seek is allowed to be called before a Play() call.
628 DoSeek(base::TimeDelta::FromSeconds(5));
630 // Verify we can issue a Play() after the Seek().
633 // Try calling Seek() while playing to make sure we get an error.
634 ExpectInvalidStateFail(SEEK
);
636 // Transition to paused state.
639 // Verify that seek is allowed after pausing.
640 DoSeek(base::TimeDelta::FromSeconds(5));
642 // Verify we can still play again.
648 // Try calling Seek() to make sure we get an error.
649 ExpectInvalidStateFail(SEEK
);
652 TEST_F(CompositeFilterTest
, TestStop
) {
655 // Test Stop() before any other call.
656 SetupAndAdd2Filters();
659 // Test error during Stop() sequence.
660 SetupAndAdd2Filters();
662 EXPECT_CALL(*filter_1_
, Stop(_
));
664 StrictMock
<MockClosure
>* callback
= new StrictMock
<MockClosure
>();
665 composite_
->Stop(base::Bind(&MockClosure::Run
, callback
));
667 // Have |filter_1_| signal an error.
668 filter_1_
->host()->SetError(PIPELINE_ERROR_READ
);
670 EXPECT_CALL(*filter_2_
, Stop(_
));
672 RunFilter1Callback();
674 EXPECT_CALL(*callback
, Run());
676 RunFilter2Callback();
679 // Test stopping in the middle of a serial call sequence.
680 TEST_F(CompositeFilterTest
, TestStopWhilePlayPending
) {
683 SetupAndAdd2Filters();
685 EXPECT_CALL(*filter_1_
, Play(_
));
687 StrictMock
<MockClosure
>* callback
= new StrictMock
<MockClosure
>();
688 composite_
->Play(base::Bind(&MockClosure::Run
, callback
));
690 // Note: Play() is pending on |filter_1_| right now.
692 callback
= new StrictMock
<MockClosure
>();
693 composite_
->Stop(base::Bind(&MockClosure::Run
, callback
));
695 EXPECT_CALL(*filter_1_
, Stop(_
));
697 // Run |filter_1_|'s callback again to indicate Play() has completed.
698 RunFilter1Callback();
700 EXPECT_CALL(*filter_2_
, Stop(_
));
702 // Run |filter_1_|'s callback again to indicate Stop() has completed.
703 RunFilter1Callback();
705 EXPECT_CALL(*callback
, Run());
707 // Run |filter_2_|'s callback to indicate Stop() has completed.
708 RunFilter2Callback();
711 // Test stopping in the middle of a parallel call sequence.
712 TEST_F(CompositeFilterTest
, TestStopWhileFlushPending
) {
715 SetupAndAdd2Filters();
717 EXPECT_CALL(*filter_1_
, Flush(_
));
718 EXPECT_CALL(*filter_2_
, Flush(_
));
720 StrictMock
<MockClosure
>* callback
= new StrictMock
<MockClosure
>();
721 composite_
->Flush(base::Bind(&MockClosure::Run
, callback
));
723 // Note: |filter_1_| and |filter_2_| have pending Flush() calls at this point.
725 callback
= new StrictMock
<MockClosure
>();
726 composite_
->Stop(base::Bind(&MockClosure::Run
, callback
));
728 // Run callback to indicate that |filter_1_|'s Flush() has completed.
729 RunFilter1Callback();
731 EXPECT_CALL(*filter_1_
, Stop(_
));
733 // Run callback to indicate that |filter_2_|'s Flush() has completed.
734 RunFilter2Callback();
736 EXPECT_CALL(*filter_2_
, Stop(_
));
738 // Run callback to indicate that |filter_1_|'s Stop() has completed.
739 RunFilter1Callback();
741 EXPECT_CALL(*callback
, Run());
743 // Run callback to indicate that |filter_2_|'s Stop() has completed.
744 RunFilter2Callback();
747 TEST_F(CompositeFilterTest
, TestErrorWhilePlaying
) {
750 SetupAndAdd2Filters();
754 // Simulate an error on |filter_2_| while playing.
755 EXPECT_CALL(*mock_filter_host_
, SetError(PIPELINE_ERROR_DECODE
));
756 filter_2_
->host()->SetError(PIPELINE_ERROR_DECODE
);
760 // Simulate an error on |filter_2_| while paused.
761 EXPECT_CALL(*mock_filter_host_
, SetError(PIPELINE_ERROR_NETWORK
));
762 filter_2_
->host()->SetError(PIPELINE_ERROR_NETWORK
);
766 // Verify that errors are not passed to |mock_filter_host_|
767 // after Stop() has been called.
768 filter_2_
->host()->SetError(PIPELINE_ERROR_NETWORK
);
771 // Make sure that state transitions act as expected even
772 // if the composite doesn't contain any filters.
773 TEST_F(CompositeFilterTest
, TestEmptyComposite
) {
776 composite_
->set_host(mock_filter_host_
.get());
778 // Issue a Play() and expect no errors.
779 composite_
->Play(NewExpectedClosure());
781 // Issue a Pause() and expect no errors.
782 composite_
->Pause(NewExpectedClosure());
784 // Issue a Flush() and expect no errors.
785 composite_
->Flush(NewExpectedClosure());
787 // Issue a Seek() and expect no errors.
788 composite_
->Seek(base::TimeDelta::FromSeconds(5),
789 NewExpectedStatusCB(PIPELINE_OK
));
791 // Issue a Play() and expect no errors.
792 composite_
->Play(NewExpectedClosure());
794 // Issue a Stop() and expect no errors.
795 composite_
->Stop(NewExpectedClosure());