| 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 AddFilter() cases. | 382 // Test successful {Add,Remove}Filter() cases. |
| 383 TEST_F(CompositeFilterTest, TestAddFilter) { | 383 TEST_F(CompositeFilterTest, TestAddRemoveFilter) { |
| 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 EXPECT_TRUE(filter->host() != NULL); |
| 391 | 392 |
| 392 EXPECT_TRUE(filter->host() != NULL); | 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), ""); |
| 393 } | 405 } |
| 394 | 406 |
| 395 TEST_F(CompositeFilterTest, TestPlay) { | 407 TEST_F(CompositeFilterTest, TestPlay) { |
| 396 InSequence sequence; | 408 InSequence sequence; |
| 397 | 409 |
| 398 SetupAndAdd2Filters(); | 410 SetupAndAdd2Filters(); |
| 399 | 411 |
| 400 // Verify successful call to Play(). | 412 // Verify successful call to Play(). |
| 401 DoPlay(); | 413 DoPlay(); |
| 402 | 414 |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 NewExpectedStatusCB(PIPELINE_OK)); | 794 NewExpectedStatusCB(PIPELINE_OK)); |
| 783 | 795 |
| 784 // Issue a Play() and expect no errors. | 796 // Issue a Play() and expect no errors. |
| 785 composite_->Play(NewExpectedClosure()); | 797 composite_->Play(NewExpectedClosure()); |
| 786 | 798 |
| 787 // Issue a Stop() and expect no errors. | 799 // Issue a Stop() and expect no errors. |
| 788 composite_->Stop(NewExpectedClosure()); | 800 composite_->Stop(NewExpectedClosure()); |
| 789 } | 801 } |
| 790 | 802 |
| 791 } // namespace media | 803 } // namespace media |
| OLD | NEW |