| 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); |
| 392 composite_->RemoveFilter(filter); |
| 393 EXPECT_TRUE(filter->host() == NULL); |
| 394 } |
| 391 | 395 |
| 392 EXPECT_TRUE(filter->host() != NULL); | 396 class CompositeFilterDeathTest : public CompositeFilterTest {}; |
| 397 |
| 398 // Test failure of RemoveFilter() on an unknown filter. |
| 399 TEST_F(CompositeFilterDeathTest, TestRemoveUnknownFilter) { |
| 400 composite_->set_host(mock_filter_host_.get()); |
| 401 // Remove unknown filter. |
| 402 scoped_refptr<StrictMock<MockFilter> > filter = new StrictMock<MockFilter>(); |
| 403 EXPECT_DEATH(composite_->RemoveFilter(filter), ""); |
| 393 } | 404 } |
| 394 | 405 |
| 395 TEST_F(CompositeFilterTest, TestPlay) { | 406 TEST_F(CompositeFilterTest, TestPlay) { |
| 396 InSequence sequence; | 407 InSequence sequence; |
| 397 | 408 |
| 398 SetupAndAdd2Filters(); | 409 SetupAndAdd2Filters(); |
| 399 | 410 |
| 400 // Verify successful call to Play(). | 411 // Verify successful call to Play(). |
| 401 DoPlay(); | 412 DoPlay(); |
| 402 | 413 |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 NewExpectedStatusCB(PIPELINE_OK)); | 793 NewExpectedStatusCB(PIPELINE_OK)); |
| 783 | 794 |
| 784 // Issue a Play() and expect no errors. | 795 // Issue a Play() and expect no errors. |
| 785 composite_->Play(NewExpectedClosure()); | 796 composite_->Play(NewExpectedClosure()); |
| 786 | 797 |
| 787 // Issue a Stop() and expect no errors. | 798 // Issue a Stop() and expect no errors. |
| 788 composite_->Stop(NewExpectedClosure()); | 799 composite_->Stop(NewExpectedClosure()); |
| 789 } | 800 } |
| 790 | 801 |
| 791 } // namespace media | 802 } // namespace media |
| OLD | NEW |