Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: media/base/filter_collection_unittest.cc

Issue 10836167: Move VideoDecoder initialization into VideoRendererBase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 class FilterCollectionTest : public ::testing::Test { 11 class FilterCollectionTest : public ::testing::Test {
12 public: 12 public:
13 FilterCollectionTest() {} 13 FilterCollectionTest() {}
14 virtual ~FilterCollectionTest() {} 14 virtual ~FilterCollectionTest() {}
15 15
16 protected: 16 protected:
17 FilterCollection collection_; 17 FilterCollection collection_;
18 MockFilterCollection mock_filters_; 18 MockFilterCollection mock_filters_;
19 19
20 DISALLOW_COPY_AND_ASSIGN(FilterCollectionTest); 20 DISALLOW_COPY_AND_ASSIGN(FilterCollectionTest);
21 }; 21 };
22 22
23 TEST_F(FilterCollectionTest, TestIsEmptyAndClear) {
24 EXPECT_TRUE(collection_.IsEmpty());
25
26 collection_.AddAudioDecoder(mock_filters_.audio_decoder());
27
28 EXPECT_FALSE(collection_.IsEmpty());
29
30 collection_.Clear();
31
32 EXPECT_TRUE(collection_.IsEmpty());
33 }
34
35 TEST_F(FilterCollectionTest, SelectXXXMethods) { 23 TEST_F(FilterCollectionTest, SelectXXXMethods) {
36 scoped_refptr<AudioDecoder> audio_decoder; 24 scoped_refptr<AudioDecoder> audio_decoder;
37 scoped_refptr<VideoDecoder> video_decoder;
38 25
39 collection_.AddVideoDecoder(mock_filters_.video_decoder());
40 EXPECT_FALSE(collection_.IsEmpty());
41
42 // Verify that the video decoder will not be returned if we
43 // ask for a different type.
44 collection_.SelectAudioDecoder(&audio_decoder); 26 collection_.SelectAudioDecoder(&audio_decoder);
45 EXPECT_FALSE(audio_decoder); 27 EXPECT_FALSE(audio_decoder);
46 EXPECT_FALSE(collection_.IsEmpty());
47 28
48 // Verify that we can actually retrieve the video decoder 29 // Add an audio 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());
53
54 // Add a video decoder and audio decoder.
55 collection_.AddVideoDecoder(mock_filters_.video_decoder());
56 collection_.AddAudioDecoder(mock_filters_.audio_decoder()); 30 collection_.AddAudioDecoder(mock_filters_.audio_decoder());
57 31
58 // Verify that we can select the audio decoder. 32 // Verify that we can select the audio decoder.
59 collection_.SelectAudioDecoder(&audio_decoder); 33 collection_.SelectAudioDecoder(&audio_decoder);
60 EXPECT_TRUE(audio_decoder); 34 EXPECT_TRUE(audio_decoder);
61 EXPECT_FALSE(collection_.IsEmpty());
62 35
63 // Verify that we can't select it again since only one has been added. 36 // Verify that we can't select it again since only one has been added.
64 collection_.SelectAudioDecoder(&audio_decoder); 37 collection_.SelectAudioDecoder(&audio_decoder);
65 EXPECT_FALSE(audio_decoder); 38 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());
71 } 39 }
72 40
73 TEST_F(FilterCollectionTest, MultipleFiltersOfSameType) { 41 TEST_F(FilterCollectionTest, MultipleFiltersOfSameType) {
74 scoped_refptr<AudioDecoder> audio_decoder_a(new MockAudioDecoder()); 42 scoped_refptr<AudioDecoder> audio_decoder_a(new MockAudioDecoder());
75 scoped_refptr<AudioDecoder> audio_decoder_b(new MockAudioDecoder()); 43 scoped_refptr<AudioDecoder> audio_decoder_b(new MockAudioDecoder());
76 44
77 scoped_refptr<AudioDecoder> audio_decoder; 45 scoped_refptr<AudioDecoder> audio_decoder;
78 46
79 collection_.AddAudioDecoder(audio_decoder_a.get()); 47 collection_.AddAudioDecoder(audio_decoder_a.get());
80 collection_.AddAudioDecoder(audio_decoder_b.get()); 48 collection_.AddAudioDecoder(audio_decoder_b.get());
81 49
82 // Verify that first SelectAudioDecoder() returns audio_decoder_a. 50 // Verify that first SelectAudioDecoder() returns audio_decoder_a.
83 collection_.SelectAudioDecoder(&audio_decoder); 51 collection_.SelectAudioDecoder(&audio_decoder);
84 EXPECT_TRUE(audio_decoder); 52 EXPECT_TRUE(audio_decoder);
85 EXPECT_EQ(audio_decoder, audio_decoder_a); 53 EXPECT_EQ(audio_decoder, audio_decoder_a);
86 EXPECT_FALSE(collection_.IsEmpty());
87 54
88 // Verify that second SelectAudioDecoder() returns audio_decoder_b. 55 // Verify that second SelectAudioDecoder() returns audio_decoder_b.
89 collection_.SelectAudioDecoder(&audio_decoder); 56 collection_.SelectAudioDecoder(&audio_decoder);
90 EXPECT_TRUE(audio_decoder); 57 EXPECT_TRUE(audio_decoder);
91 EXPECT_EQ(audio_decoder, audio_decoder_b); 58 EXPECT_EQ(audio_decoder, audio_decoder_b);
92 EXPECT_TRUE(collection_.IsEmpty());
93 59
94 // Verify that third SelectAudioDecoder() returns nothing. 60 // Verify that third SelectAudioDecoder() returns nothing.
95 collection_.SelectAudioDecoder(&audio_decoder); 61 collection_.SelectAudioDecoder(&audio_decoder);
96 EXPECT_FALSE(audio_decoder); 62 EXPECT_FALSE(audio_decoder);
97 } 63 }
98 64
99 } // namespace media 65 } // namespace media
OLDNEW
« no previous file with comments | « media/base/filter_collection.cc ('k') | media/base/media_log.cc » ('j') | media/base/pipeline.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698