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 "media/base/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 |
(...skipping 16 matching lines...) Expand all Loading... |
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(FilterCollectionTest, SelectXXXMethods) { | 35 TEST_F(FilterCollectionTest, SelectXXXMethods) { |
36 scoped_refptr<AudioDecoder> audio_decoder; | 36 scoped_refptr<AudioDecoder> audio_decoder; |
37 scoped_refptr<VideoDecoder> video_decoder; | |
38 | 37 |
39 collection_.AddVideoDecoder(mock_filters_.video_decoder()); | 38 EXPECT_TRUE(collection_.IsEmpty()); |
40 EXPECT_FALSE(collection_.IsEmpty()); | |
41 | 39 |
42 // Verify that the video decoder will not be returned if we | |
43 // ask for a different type. | |
44 collection_.SelectAudioDecoder(&audio_decoder); | 40 collection_.SelectAudioDecoder(&audio_decoder); |
45 EXPECT_FALSE(audio_decoder); | 41 EXPECT_FALSE(audio_decoder); |
46 EXPECT_FALSE(collection_.IsEmpty()); | |
47 | |
48 // Verify that we can actually retrieve the video decoder | |
49 // and that it is removed from the collection. | |
50 collection_.SelectVideoDecoder(&video_decoder); | |
51 EXPECT_TRUE(video_decoder); | |
52 EXPECT_TRUE(collection_.IsEmpty()); | 42 EXPECT_TRUE(collection_.IsEmpty()); |
53 | 43 |
54 // Add a video decoder and audio decoder. | 44 // Add an audio decoder. |
55 collection_.AddVideoDecoder(mock_filters_.video_decoder()); | |
56 collection_.AddAudioDecoder(mock_filters_.audio_decoder()); | 45 collection_.AddAudioDecoder(mock_filters_.audio_decoder()); |
| 46 EXPECT_FALSE(collection_.IsEmpty()); |
57 | 47 |
58 // Verify that we can select the audio decoder. | 48 // Verify that we can select the audio decoder. |
59 collection_.SelectAudioDecoder(&audio_decoder); | 49 collection_.SelectAudioDecoder(&audio_decoder); |
60 EXPECT_TRUE(audio_decoder); | 50 EXPECT_TRUE(audio_decoder); |
61 EXPECT_FALSE(collection_.IsEmpty()); | 51 EXPECT_TRUE(collection_.IsEmpty()); |
62 | 52 |
63 // Verify that we can't select it again since only one has been added. | 53 // Verify that we can't select it again since only one has been added. |
64 collection_.SelectAudioDecoder(&audio_decoder); | 54 collection_.SelectAudioDecoder(&audio_decoder); |
65 EXPECT_FALSE(audio_decoder); | 55 EXPECT_FALSE(audio_decoder); |
66 | |
67 // Verify that we can select the video decoder and that doing so will | |
68 // empty the collection again. | |
69 collection_.SelectVideoDecoder(&video_decoder); | |
70 EXPECT_TRUE(collection_.IsEmpty()); | 56 EXPECT_TRUE(collection_.IsEmpty()); |
71 } | 57 } |
72 | 58 |
73 TEST_F(FilterCollectionTest, MultipleFiltersOfSameType) { | 59 TEST_F(FilterCollectionTest, MultipleFiltersOfSameType) { |
74 scoped_refptr<AudioDecoder> audio_decoder_a(new MockAudioDecoder()); | 60 scoped_refptr<AudioDecoder> audio_decoder_a(new MockAudioDecoder()); |
75 scoped_refptr<AudioDecoder> audio_decoder_b(new MockAudioDecoder()); | 61 scoped_refptr<AudioDecoder> audio_decoder_b(new MockAudioDecoder()); |
76 | 62 |
77 scoped_refptr<AudioDecoder> audio_decoder; | 63 scoped_refptr<AudioDecoder> audio_decoder; |
78 | 64 |
79 collection_.AddAudioDecoder(audio_decoder_a.get()); | 65 collection_.AddAudioDecoder(audio_decoder_a.get()); |
(...skipping 10 matching lines...) Expand all Loading... |
90 EXPECT_TRUE(audio_decoder); | 76 EXPECT_TRUE(audio_decoder); |
91 EXPECT_EQ(audio_decoder, audio_decoder_b); | 77 EXPECT_EQ(audio_decoder, audio_decoder_b); |
92 EXPECT_TRUE(collection_.IsEmpty()); | 78 EXPECT_TRUE(collection_.IsEmpty()); |
93 | 79 |
94 // Verify that third SelectAudioDecoder() returns nothing. | 80 // Verify that third SelectAudioDecoder() returns nothing. |
95 collection_.SelectAudioDecoder(&audio_decoder); | 81 collection_.SelectAudioDecoder(&audio_decoder); |
96 EXPECT_FALSE(audio_decoder); | 82 EXPECT_FALSE(audio_decoder); |
97 } | 83 } |
98 | 84 |
99 } // namespace media | 85 } // namespace media |
OLD | NEW |