OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "media/base/composite_filter.h" | 7 #include "media/base/composite_filter.h" |
8 #include "media/base/mock_callback.h" | 8 #include "media/base/mock_callback.h" |
9 #include "media/base/mock_filter_host.h" | 9 #include "media/base/mock_filter_host.h" |
10 #include "media/base/mock_filters.h" | 10 #include "media/base/mock_filters.h" |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 // Test adding a null pointer. | 372 // Test adding a null pointer. |
373 EXPECT_FALSE(composite_->AddFilter(NULL)); | 373 EXPECT_FALSE(composite_->AddFilter(NULL)); |
374 | 374 |
375 scoped_refptr<StrictMock<MockFilter> > filter = new StrictMock<MockFilter>(); | 375 scoped_refptr<StrictMock<MockFilter> > filter = new StrictMock<MockFilter>(); |
376 EXPECT_EQ(NULL, filter->host()); | 376 EXPECT_EQ(NULL, filter->host()); |
377 | 377 |
378 // Test failing because set_host() hasn't been called yet. | 378 // Test failing because set_host() hasn't been called yet. |
379 EXPECT_FALSE(composite_->AddFilter(filter)); | 379 EXPECT_FALSE(composite_->AddFilter(filter)); |
380 } | 380 } |
381 | 381 |
382 // Test successful {Add,Remove}Filter() cases. | 382 // Test successful AddFilter() cases. |
383 TEST_F(CompositeFilterTest, TestAddRemoveFilter) { | 383 TEST_F(CompositeFilterTest, TestAddFilter) { |
384 composite_->set_host(mock_filter_host_.get()); | 384 composite_->set_host(mock_filter_host_.get()); |
385 | 385 |
386 // Add a filter. | 386 // Add a filter. |
387 scoped_refptr<StrictMock<MockFilter> > filter = new StrictMock<MockFilter>(); | 387 scoped_refptr<StrictMock<MockFilter> > filter = new StrictMock<MockFilter>(); |
388 EXPECT_EQ(NULL, filter->host()); | 388 EXPECT_EQ(NULL, filter->host()); |
389 | 389 |
390 EXPECT_TRUE(composite_->AddFilter(filter)); | 390 EXPECT_TRUE(composite_->AddFilter(filter)); |
| 391 |
391 EXPECT_TRUE(filter->host() != NULL); | 392 EXPECT_TRUE(filter->host() != NULL); |
392 | |
393 composite_->RemoveFilter(filter); | |
394 EXPECT_TRUE(filter->host() == NULL); | |
395 } | |
396 | |
397 class CompositeFilterDeathTest : public CompositeFilterTest {}; | |
398 | |
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(composite_->RemoveFilter(filter), ""); | |
405 } | 393 } |
406 | 394 |
407 TEST_F(CompositeFilterTest, TestPlay) { | 395 TEST_F(CompositeFilterTest, TestPlay) { |
408 InSequence sequence; | 396 InSequence sequence; |
409 | 397 |
410 SetupAndAdd2Filters(); | 398 SetupAndAdd2Filters(); |
411 | 399 |
412 // Verify successful call to Play(). | 400 // Verify successful call to Play(). |
413 DoPlay(); | 401 DoPlay(); |
414 | 402 |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 NewExpectedStatusCB(PIPELINE_OK)); | 782 NewExpectedStatusCB(PIPELINE_OK)); |
795 | 783 |
796 // Issue a Play() and expect no errors. | 784 // Issue a Play() and expect no errors. |
797 composite_->Play(NewExpectedClosure()); | 785 composite_->Play(NewExpectedClosure()); |
798 | 786 |
799 // Issue a Stop() and expect no errors. | 787 // Issue a Stop() and expect no errors. |
800 composite_->Stop(NewExpectedClosure()); | 788 composite_->Stop(NewExpectedClosure()); |
801 } | 789 } |
802 | 790 |
803 } // namespace media | 791 } // namespace media |
OLD | NEW |