| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/base/media_filter_collection.h" | 5 #include "media/base/filter_collection.h" |
| 6 #include "media/base/mock_filters.h" | 6 #include "media/base/mock_filters.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 | 10 |
| 11 class MediaFilterCollectionTest : public ::testing::Test { | 11 class FilterCollectionTest : public ::testing::Test { |
| 12 public: | 12 public: |
| 13 MediaFilterCollectionTest() {} | 13 FilterCollectionTest() {} |
| 14 virtual ~MediaFilterCollectionTest() {} | 14 virtual ~FilterCollectionTest() {} |
| 15 | 15 |
| 16 protected: | 16 protected: |
| 17 MediaFilterCollection collection_; | 17 FilterCollection collection_; |
| 18 MockFilterCollection mock_filters_; | 18 MockFilterCollection mock_filters_; |
| 19 | 19 |
| 20 DISALLOW_COPY_AND_ASSIGN(MediaFilterCollectionTest); | 20 DISALLOW_COPY_AND_ASSIGN(FilterCollectionTest); |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 TEST_F(MediaFilterCollectionTest, TestIsEmptyAndClear) { | 23 TEST_F(FilterCollectionTest, TestIsEmptyAndClear) { |
| 24 EXPECT_TRUE(collection_.IsEmpty()); | 24 EXPECT_TRUE(collection_.IsEmpty()); |
| 25 | 25 |
| 26 collection_.AddDataSource(mock_filters_.data_source()); | 26 collection_.AddDataSource(mock_filters_.data_source()); |
| 27 | 27 |
| 28 EXPECT_FALSE(collection_.IsEmpty()); | 28 EXPECT_FALSE(collection_.IsEmpty()); |
| 29 | 29 |
| 30 collection_.Clear(); | 30 collection_.Clear(); |
| 31 | 31 |
| 32 EXPECT_TRUE(collection_.IsEmpty()); | 32 EXPECT_TRUE(collection_.IsEmpty()); |
| 33 } | 33 } |
| 34 | 34 |
| 35 TEST_F(MediaFilterCollectionTest, SelectXXXMethods) { | 35 TEST_F(FilterCollectionTest, SelectXXXMethods) { |
| 36 scoped_refptr<AudioDecoder> audio_decoder; | 36 scoped_refptr<AudioDecoder> audio_decoder; |
| 37 scoped_refptr<DataSource> data_source; | 37 scoped_refptr<DataSource> data_source; |
| 38 | 38 |
| 39 collection_.AddDataSource(mock_filters_.data_source()); | 39 collection_.AddDataSource(mock_filters_.data_source()); |
| 40 EXPECT_FALSE(collection_.IsEmpty()); | 40 EXPECT_FALSE(collection_.IsEmpty()); |
| 41 | 41 |
| 42 // Verify that the data source will not be returned if we | 42 // Verify that the data source will not be returned if we |
| 43 // ask for a different type. | 43 // ask for a different type. |
| 44 collection_.SelectAudioDecoder(&audio_decoder); | 44 collection_.SelectAudioDecoder(&audio_decoder); |
| 45 EXPECT_FALSE(audio_decoder); | 45 EXPECT_FALSE(audio_decoder); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 63 // Verify that we can't select it again since only one has been added. | 63 // Verify that we can't select it again since only one has been added. |
| 64 collection_.SelectAudioDecoder(&audio_decoder); | 64 collection_.SelectAudioDecoder(&audio_decoder); |
| 65 EXPECT_FALSE(audio_decoder); | 65 EXPECT_FALSE(audio_decoder); |
| 66 | 66 |
| 67 // Verify that we can select the data source and that doing so will | 67 // Verify that we can select the data source and that doing so will |
| 68 // empty the collection again. | 68 // empty the collection again. |
| 69 collection_.SelectDataSource(&data_source); | 69 collection_.SelectDataSource(&data_source); |
| 70 EXPECT_TRUE(collection_.IsEmpty()); | 70 EXPECT_TRUE(collection_.IsEmpty()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 TEST_F(MediaFilterCollectionTest, MultipleFiltersOfSameType) { | 73 TEST_F(FilterCollectionTest, MultipleFiltersOfSameType) { |
| 74 scoped_refptr<DataSource> data_source_a(new MockDataSource()); | 74 scoped_refptr<DataSource> data_source_a(new MockDataSource()); |
| 75 scoped_refptr<DataSource> data_source_b(new MockDataSource()); | 75 scoped_refptr<DataSource> data_source_b(new MockDataSource()); |
| 76 | 76 |
| 77 scoped_refptr<DataSource> data_source; | 77 scoped_refptr<DataSource> data_source; |
| 78 | 78 |
| 79 collection_.AddDataSource(data_source_a.get()); | 79 collection_.AddDataSource(data_source_a.get()); |
| 80 collection_.AddDataSource(data_source_b.get()); | 80 collection_.AddDataSource(data_source_b.get()); |
| 81 | 81 |
| 82 // Verify that first SelectDataSource() returns data_source_a. | 82 // Verify that first SelectDataSource() returns data_source_a. |
| 83 collection_.SelectDataSource(&data_source); | 83 collection_.SelectDataSource(&data_source); |
| 84 EXPECT_TRUE(data_source); | 84 EXPECT_TRUE(data_source); |
| 85 EXPECT_EQ(data_source, data_source_a); | 85 EXPECT_EQ(data_source, data_source_a); |
| 86 EXPECT_FALSE(collection_.IsEmpty()); | 86 EXPECT_FALSE(collection_.IsEmpty()); |
| 87 | 87 |
| 88 // Verify that second SelectDataSource() returns data_source_b. | 88 // Verify that second SelectDataSource() returns data_source_b. |
| 89 collection_.SelectDataSource(&data_source); | 89 collection_.SelectDataSource(&data_source); |
| 90 EXPECT_TRUE(data_source); | 90 EXPECT_TRUE(data_source); |
| 91 EXPECT_EQ(data_source, data_source_b); | 91 EXPECT_EQ(data_source, data_source_b); |
| 92 EXPECT_TRUE(collection_.IsEmpty()); | 92 EXPECT_TRUE(collection_.IsEmpty()); |
| 93 | 93 |
| 94 // Verify that third SelectDataSource() returns nothing. | 94 // Verify that third SelectDataSource() returns nothing. |
| 95 collection_.SelectDataSource(&data_source); | 95 collection_.SelectDataSource(&data_source); |
| 96 EXPECT_FALSE(data_source); | 96 EXPECT_FALSE(data_source); |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace media | 99 } // namespace media |
| OLD | NEW |