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

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

Issue 126170: Make the generated stubs weak. Enable the unittests that had conflicting symbols. (Closed)
Patch Set: Fix indent.w Created 11 years, 6 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
« no previous file with comments | « media/base/mock_media_filters.h ('k') | media/base/video_frame_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 <string> 5 #include <string>
6 6
7 #include "base/waitable_event.h" 7 #include "base/waitable_event.h"
8 #include "media/base/pipeline_impl.h" 8 #include "media/base/pipeline_impl.h"
9 #include "media/base/media_format.h" 9 #include "media/base/media_format.h"
10 #include "media/base/filters.h" 10 #include "media/base/filters.h"
(...skipping 18 matching lines...) Expand all
29 virtual void TearDown() { 29 virtual void TearDown() {
30 // Force the pipeline to shut down its thread. 30 // Force the pipeline to shut down its thread.
31 pipeline_.Stop(); 31 pipeline_.Stop();
32 } 32 }
33 33
34 // Called by tests after they have finished setting up MockFilterConfig. 34 // Called by tests after they have finished setting up MockFilterConfig.
35 // Initializes the pipeline and returns true if the initialization callback 35 // Initializes the pipeline and returns true if the initialization callback
36 // was executed, false otherwise. 36 // was executed, false otherwise.
37 bool InitializeAndWait() { 37 bool InitializeAndWait() {
38 DCHECK(!filters_); 38 DCHECK(!filters_);
39 filters_ = new media::MockFilterFactory(&config_); 39 filters_ = new media::old_mocks::MockFilterFactory(&config_);
40 pipeline_.Start(filters_, "", 40 pipeline_.Start(filters_, "",
41 NewCallback(this, &PipelineImplTest::OnInitialize)); 41 NewCallback(this, &PipelineImplTest::OnInitialize));
42 return initialize_event_.TimedWait(base::TimeDelta::FromMilliseconds(500)); 42 return initialize_event_.TimedWait(base::TimeDelta::FromMilliseconds(500));
43 } 43 }
44 44
45 // Issues a seek on the pipeline and returns true if the seek callback was 45 // Issues a seek on the pipeline and returns true if the seek callback was
46 // executed, false otherwise. 46 // executed, false otherwise.
47 bool SeekAndWait(const base::TimeDelta& time) { 47 bool SeekAndWait(const base::TimeDelta& time) {
48 pipeline_.Seek(time, NewCallback(this, &PipelineImplTest::OnSeek)); 48 pipeline_.Seek(time, NewCallback(this, &PipelineImplTest::OnSeek));
49 return seek_event_.TimedWait(base::TimeDelta::FromMilliseconds(500)); 49 return seek_event_.TimedWait(base::TimeDelta::FromMilliseconds(500));
50 } 50 }
51 51
52 // Fixture members. 52 // Fixture members.
53 media::PipelineImpl pipeline_; 53 media::PipelineImpl pipeline_;
54 scoped_refptr<media::MockFilterFactory> filters_; 54 scoped_refptr<media::old_mocks::MockFilterFactory> filters_;
55 media::MockFilterConfig config_; 55 media::old_mocks::MockFilterConfig config_;
56 bool initialize_result_; 56 bool initialize_result_;
57 bool seek_result_; 57 bool seek_result_;
58 58
59 private: 59 private:
60 void OnInitialize(bool result) { 60 void OnInitialize(bool result) {
61 initialize_result_ = result; 61 initialize_result_ = result;
62 initialize_event_.Signal(); 62 initialize_event_.Signal();
63 } 63 }
64 64
65 void OnSeek(bool result) { 65 void OnSeek(bool result) {
66 seek_result_ = result; 66 seek_result_ = result;
67 seek_event_.Signal(); 67 seek_event_.Signal();
68 } 68 }
69 69
70 // Used to wait for callbacks. 70 // Used to wait for callbacks.
71 base::WaitableEvent initialize_event_; 71 base::WaitableEvent initialize_event_;
72 base::WaitableEvent seek_event_; 72 base::WaitableEvent seek_event_;
73 73
74 DISALLOW_COPY_AND_ASSIGN(PipelineImplTest); 74 DISALLOW_COPY_AND_ASSIGN(PipelineImplTest);
75 }; 75 };
76 76
77 TEST_F(PipelineImplTest, NeverInitializes) { 77 TEST_F(PipelineImplTest, NeverInitializes) {
78 config_.data_source_behavior = media::MOCK_DATA_SOURCE_NEVER_INIT; 78 config_.data_source_behavior = media::old_mocks::MOCK_DATA_SOURCE_NEVER_INIT;
79 79
80 // This test hangs during initialization by never calling 80 // This test hangs during initialization by never calling
81 // InitializationComplete(). Make sure we tear down the pipeline properly. 81 // InitializationComplete(). Make sure we tear down the pipeline properly.
82 ASSERT_FALSE(InitializeAndWait()); 82 ASSERT_FALSE(InitializeAndWait());
83 EXPECT_FALSE(initialize_result_); 83 EXPECT_FALSE(initialize_result_);
84 EXPECT_FALSE(pipeline_.IsInitialized()); 84 EXPECT_FALSE(pipeline_.IsInitialized());
85 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError()); 85 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError());
86 } 86 }
87 87
88 TEST_F(PipelineImplTest, RequiredFilterMissing) { 88 TEST_F(PipelineImplTest, RequiredFilterMissing) {
89 config_.create_filter = false; 89 config_.create_filter = false;
90 90
91 ASSERT_TRUE(InitializeAndWait()); 91 ASSERT_TRUE(InitializeAndWait());
92 EXPECT_FALSE(initialize_result_); 92 EXPECT_FALSE(initialize_result_);
93 EXPECT_FALSE(pipeline_.IsInitialized()); 93 EXPECT_FALSE(pipeline_.IsInitialized());
94 EXPECT_EQ(media::PIPELINE_ERROR_REQUIRED_FILTER_MISSING, 94 EXPECT_EQ(media::PIPELINE_ERROR_REQUIRED_FILTER_MISSING,
95 pipeline_.GetError()); 95 pipeline_.GetError());
96 } 96 }
97 97
98 TEST_F(PipelineImplTest, URLNotFound) { 98 TEST_F(PipelineImplTest, URLNotFound) {
99 config_.data_source_behavior = media::MOCK_DATA_SOURCE_URL_ERROR_IN_INIT; 99 config_.data_source_behavior =
100 media::old_mocks::MOCK_DATA_SOURCE_URL_ERROR_IN_INIT;
100 101
101 ASSERT_TRUE(InitializeAndWait()); 102 ASSERT_TRUE(InitializeAndWait());
102 EXPECT_FALSE(initialize_result_); 103 EXPECT_FALSE(initialize_result_);
103 EXPECT_FALSE(pipeline_.IsInitialized()); 104 EXPECT_FALSE(pipeline_.IsInitialized());
104 EXPECT_EQ(media::PIPELINE_ERROR_URL_NOT_FOUND, pipeline_.GetError()); 105 EXPECT_EQ(media::PIPELINE_ERROR_URL_NOT_FOUND, pipeline_.GetError());
105 } 106 }
106 107
107 TEST_F(PipelineImplTest, NoStreams) { 108 TEST_F(PipelineImplTest, NoStreams) {
108 config_.has_audio = false; 109 config_.has_audio = false;
109 config_.has_video = false; 110 config_.has_video = false;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 EXPECT_TRUE(expected == filters_->audio_renderer()->seek_time()); 198 EXPECT_TRUE(expected == filters_->audio_renderer()->seek_time());
198 EXPECT_TRUE(expected == filters_->video_decoder()->seek_time()); 199 EXPECT_TRUE(expected == filters_->video_decoder()->seek_time());
199 EXPECT_TRUE(expected == filters_->video_renderer()->seek_time()); 200 EXPECT_TRUE(expected == filters_->video_renderer()->seek_time());
200 } 201 }
201 202
202 // TODO(ralphl): Add a unit test that makes sure that the mock audio filter 203 // TODO(ralphl): Add a unit test that makes sure that the mock audio filter
203 // is actually called on a SetVolume() call to the pipeline. I almost checked 204 // is actually called on a SetVolume() call to the pipeline. I almost checked
204 // in code that broke this, but all unit tests were passing. 205 // in code that broke this, but all unit tests were passing.
205 206
206 } // namespace 207 } // namespace
OLDNEW
« no previous file with comments | « media/base/mock_media_filters.h ('k') | media/base/video_frame_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698