diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 00:11:07 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 00:11:07 +0000 |
commit | 5214f719b7009c844604ffca4a24d741ec10bb6d (patch) | |
tree | 1a031b75bf46a55ab5380c7eb85bf9ca25338f15 /media | |
parent | bacc94464e429a3c650158f3d5c786752506a98c (diff) | |
download | chromium_src-5214f719b7009c844604ffca4a24d741ec10bb6d.zip chromium_src-5214f719b7009c844604ffca4a24d741ec10bb6d.tar.gz chromium_src-5214f719b7009c844604ffca4a24d741ec10bb6d.tar.bz2 |
Make the generated stubs weak. Enable the unittests that had conflicting symbols.
Also move some of the old mocks into their own namespace. They were causing linker confusion due to inlining or something which generated bad test executables that segfaulted.
Review URL: http://codereview.chromium.org/126170
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18457 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/base/mock_media_filters.h | 9 | ||||
-rw-r--r-- | media/base/pipeline_impl_unittest.cc | 11 | ||||
-rw-r--r-- | media/base/video_frame_impl_unittest.cc | 4 | ||||
-rw-r--r-- | media/filters/ffmpeg_demuxer_unittest.cc | 14 | ||||
-rw-r--r-- | media/filters/ffmpeg_glue_unittest.cc | 42 | ||||
-rw-r--r-- | media/filters/ffmpeg_video_decoder_unittest.cc | 11 | ||||
-rw-r--r-- | media/filters/file_data_source_unittest.cc | 9 | ||||
-rw-r--r-- | media/filters/test_video_decoder.h | 3 | ||||
-rw-r--r-- | media/filters/video_decoder_unittest.cc | 13 | ||||
-rw-r--r-- | media/filters/video_renderer_unittest.cc | 5 | ||||
-rw-r--r-- | media/media.gyp | 14 |
11 files changed, 63 insertions, 72 deletions
diff --git a/media/base/mock_media_filters.h b/media/base/mock_media_filters.h index 1d215c4..b8a8f74 100644 --- a/media/base/mock_media_filters.h +++ b/media/base/mock_media_filters.h @@ -1,6 +1,11 @@ // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this // source code is governed by a BSD-style license that can be found in the // LICENSE file. +// +// TODO(ajwong): This whole file is deprecated in favor or gmock style mocks. +// The deprecated classes have been moved into the old_mocks to avoid colliding +// with the newer mock classes. Once all the unittests have been migrated, this +// should be deleted. #ifndef MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ #define MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ @@ -20,6 +25,8 @@ namespace media { +namespace old_mocks { + // Behaviors for MockDataSource filter. enum MockDataSourceBehavior { MOCK_DATA_SOURCE_NORMAL_INIT, @@ -667,6 +674,8 @@ class InitializationHelper { DISALLOW_COPY_AND_ASSIGN(InitializationHelper); }; +} // namespace old_mocks + } // namespace media #endif // MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc index adfc3a6..f28ee1c 100644 --- a/media/base/pipeline_impl_unittest.cc +++ b/media/base/pipeline_impl_unittest.cc @@ -36,7 +36,7 @@ class PipelineImplTest : public testing::Test { // was executed, false otherwise. bool InitializeAndWait() { DCHECK(!filters_); - filters_ = new media::MockFilterFactory(&config_); + filters_ = new media::old_mocks::MockFilterFactory(&config_); pipeline_.Start(filters_, "", NewCallback(this, &PipelineImplTest::OnInitialize)); return initialize_event_.TimedWait(base::TimeDelta::FromMilliseconds(500)); @@ -51,8 +51,8 @@ class PipelineImplTest : public testing::Test { // Fixture members. media::PipelineImpl pipeline_; - scoped_refptr<media::MockFilterFactory> filters_; - media::MockFilterConfig config_; + scoped_refptr<media::old_mocks::MockFilterFactory> filters_; + media::old_mocks::MockFilterConfig config_; bool initialize_result_; bool seek_result_; @@ -75,7 +75,7 @@ class PipelineImplTest : public testing::Test { }; TEST_F(PipelineImplTest, NeverInitializes) { - config_.data_source_behavior = media::MOCK_DATA_SOURCE_NEVER_INIT; + config_.data_source_behavior = media::old_mocks::MOCK_DATA_SOURCE_NEVER_INIT; // This test hangs during initialization by never calling // InitializationComplete(). Make sure we tear down the pipeline properly. @@ -96,7 +96,8 @@ TEST_F(PipelineImplTest, RequiredFilterMissing) { } TEST_F(PipelineImplTest, URLNotFound) { - config_.data_source_behavior = media::MOCK_DATA_SOURCE_URL_ERROR_IN_INIT; + config_.data_source_behavior = + media::old_mocks::MOCK_DATA_SOURCE_URL_ERROR_IN_INIT; ASSERT_TRUE(InitializeAndWait()); EXPECT_FALSE(initialize_result_); diff --git a/media/base/video_frame_impl_unittest.cc b/media/base/video_frame_impl_unittest.cc index fe0d37c..a6a1a6a 100644 --- a/media/base/video_frame_impl_unittest.cc +++ b/media/base/video_frame_impl_unittest.cc @@ -98,9 +98,9 @@ TEST(VideoFrameImpl, Basic) { EXPECT_FALSE(frame->IsDiscontinuous()); // Test VideoFrame implementation. - media::MockVideoDecoder::InitializeYV12Frame(frame, 0.0f); + media::old_mocks::MockVideoDecoder::InitializeYV12Frame(frame, 0.0f); ExpectFrameColor(frame, 0xFF000000); - media::MockVideoDecoder::InitializeYV12Frame(frame, 1.0f); + media::old_mocks::MockVideoDecoder::InitializeYV12Frame(frame, 1.0f); ExpectFrameColor(frame, 0xFFFFFFFF); // Test an empty frame. diff --git a/media/filters/ffmpeg_demuxer_unittest.cc b/media/filters/ffmpeg_demuxer_unittest.cc index d1e79a2..002f6d5 100644 --- a/media/filters/ffmpeg_demuxer_unittest.cc +++ b/media/filters/ffmpeg_demuxer_unittest.cc @@ -268,8 +268,8 @@ class FFmpegDemuxerTest : public testing::Test { // Prepare a filter host and data source for the demuxer. pipeline_.reset(new MockPipeline()); filter_host_.reset(new MockFilterHost<Demuxer>(pipeline_.get(), demuxer_)); - MockFilterConfig config; - data_source_ = new MockDataSource(&config); + old_mocks::MockFilterConfig config; + data_source_ = new old_mocks::MockDataSource(&config); } virtual void TearDown() { @@ -281,8 +281,8 @@ class FFmpegDemuxerTest : public testing::Test { scoped_refptr<FilterFactory> factory_; scoped_refptr<Demuxer> demuxer_; scoped_ptr<MockPipeline> pipeline_; - scoped_ptr< MockFilterHost<Demuxer> > filter_host_; - scoped_refptr<MockDataSource> data_source_; + scoped_ptr<MockFilterHost<Demuxer> > filter_host_; + scoped_refptr<old_mocks::MockDataSource> data_source_; private: static void InitializeFFmpegMocks() { @@ -400,7 +400,7 @@ TEST_F(FFmpegDemuxerTest, InitializeStreams) { EXPECT_EQ(g_streams[1].duration, pipeline_->GetDuration().InMicroseconds()); // Verify that 2 out of 3 streams were created. - EXPECT_EQ(2, demuxer_->GetNumberOfStreams()); + EXPECT_EQ(2u, demuxer_->GetNumberOfStreams()); // First stream should be video and support FFmpegDemuxerStream interface. scoped_refptr<DemuxerStream> stream = demuxer_->GetStream(0); @@ -459,7 +459,7 @@ TEST_F(FFmpegDemuxerTest, ReadAndSeek) { EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); // Verify both streams were created. - EXPECT_EQ(2, demuxer_->GetNumberOfStreams()); + EXPECT_EQ(2u, demuxer_->GetNumberOfStreams()); // Get our streams. scoped_refptr<DemuxerStream> audio_stream = demuxer_->GetStream(kAudio); @@ -655,7 +655,7 @@ TEST_F(FFmpegDemuxerTest, DISABLED_MP3Hack) { EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); // Verify the stream was created. - EXPECT_EQ(1, demuxer_->GetNumberOfStreams()); + EXPECT_EQ(1u, demuxer_->GetNumberOfStreams()); scoped_refptr<DemuxerStream> audio_stream = demuxer_->GetStream(kAudio); ASSERT_TRUE(audio_stream); diff --git a/media/filters/ffmpeg_glue_unittest.cc b/media/filters/ffmpeg_glue_unittest.cc index 0fe7d04..993fb31 100644 --- a/media/filters/ffmpeg_glue_unittest.cc +++ b/media/filters/ffmpeg_glue_unittest.cc @@ -55,18 +55,18 @@ TEST(FFmpegGlueTest, AddRemoveGetDataSource) { // Create our data sources and add them to the glue layer. bool deleted_a = false; bool deleted_b = false; - media::MockFilterConfig config_a; - media::MockFilterConfig config_b; - scoped_refptr<media::MockDataSource> data_source_a - = new media::MockDataSource(&config_a, &deleted_a); - scoped_refptr<media::MockDataSource> data_source_b - = new media::MockDataSource(&config_b, &deleted_b); + media::old_mocks::MockFilterConfig config_a; + media::old_mocks::MockFilterConfig config_b; + scoped_refptr<media::old_mocks::MockDataSource> data_source_a + = new media::old_mocks::MockDataSource(&config_a, &deleted_a); + scoped_refptr<media::old_mocks::MockDataSource> data_source_b + = new media::old_mocks::MockDataSource(&config_b, &deleted_b); // Make sure the keys are unique. std::string key_a = glue->AddDataSource(data_source_a); std::string key_b = glue->AddDataSource(data_source_b); - EXPECT_EQ(0, key_a.find("http://")); - EXPECT_EQ(0, key_b.find("http://")); + EXPECT_EQ(0u, key_a.find("http://")); + EXPECT_EQ(0u, key_b.find("http://")); EXPECT_NE(key_a, key_b); // Our keys should return our data sources. @@ -108,9 +108,9 @@ TEST(FFmpegGlueTest, OpenClose) { // Create our data source and add them to the glue layer. bool deleted = false; - media::MockFilterConfig config; - scoped_refptr<media::MockDataSource> data_source - = new media::MockDataSource(&config, &deleted); + media::old_mocks::MockFilterConfig config; + scoped_refptr<media::old_mocks::MockDataSource> data_source + = new media::old_mocks::MockDataSource(&config, &deleted); std::string key = glue->AddDataSource(data_source); // Prepare FFmpeg URLContext structure. @@ -147,8 +147,8 @@ TEST(FFmpegGlueTest, ReadingWriting) { // Configure MockDataSource to be 8 characters long and fill reads with // periods. Therefore our expected string should be a character of 8 periods. - const size_t kExpectedSize = 8; - media::MockFilterConfig config; + const int kExpectedSize = 8; + media::old_mocks::MockFilterConfig config; config.media_total_bytes = kExpectedSize; config.data_source_value = '.'; const char kExpected[] = "........"; @@ -156,8 +156,8 @@ TEST(FFmpegGlueTest, ReadingWriting) { // Create our data source and add them to the glue layer. bool deleted = false; - scoped_refptr<media::MockDataSource> data_source - = new media::MockDataSource(&config, &deleted); + scoped_refptr<media::old_mocks::MockDataSource> data_source + = new media::old_mocks::MockDataSource(&config, &deleted); std::string key = glue->AddDataSource(data_source); // Open our data source and then remove it from the glue layer. @@ -204,10 +204,10 @@ TEST(FFmpegGlueTest, Seeking) { // Create our data source and add them to the glue layer. bool deleted = false; - media::MockFilterConfig config; + media::old_mocks::MockFilterConfig config; config.media_total_bytes = kSize; - scoped_refptr<media::MockDataSource> data_source - = new media::MockDataSource(&config, &deleted); + scoped_refptr<media::old_mocks::MockDataSource> data_source + = new media::old_mocks::MockDataSource(&config, &deleted); std::string key = glue->AddDataSource(data_source); // Open our data source and then remove it from the glue layer. @@ -292,9 +292,9 @@ TEST(FFmpegGlueTest, Destructor) { static bool deleted = false; // Create our data source and add them to the glue layer. - media::MockFilterConfig config; - scoped_refptr<media::MockDataSource> data_source - = new media::MockDataSource(&config, &deleted); + media::old_mocks::MockFilterConfig config; + scoped_refptr<media::old_mocks::MockDataSource> data_source + = new media::old_mocks::MockDataSource(&config, &deleted); std::string key = glue->AddDataSource(data_source); // Remove our own reference. diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc index 4faf0f8..4d11e15 100644 --- a/media/filters/ffmpeg_video_decoder_unittest.cc +++ b/media/filters/ffmpeg_video_decoder_unittest.cc @@ -37,8 +37,8 @@ namespace media { // FFmpeg, pipeline and filter host mocks. class FFmpegVideoDecoderTest : public testing::Test { protected: - static const int kWidth = 1280; - static const int kHeight = 720; + static const int kWidth; + static const int kHeight; FFmpegVideoDecoderTest() { MediaFormat media_format; @@ -79,7 +79,7 @@ class FFmpegVideoDecoderTest : public testing::Test { scoped_refptr<FilterFactory> factory_; scoped_refptr<VideoDecoder> decoder_; scoped_ptr<MockPipeline> pipeline_; - scoped_ptr< MockFilterHost<VideoDecoder> > filter_host_; + scoped_ptr<MockFilterHost<VideoDecoder> > filter_host_; scoped_refptr<MockDemuxerStream> demuxer_; // FFmpeg fixtures. @@ -92,6 +92,9 @@ class FFmpegVideoDecoderTest : public testing::Test { DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoderTest); }; +const int FFmpegVideoDecoderTest::kWidth = 1280; +const int FFmpegVideoDecoderTest::kHeight = 720; + TEST(FFmpegVideoDecoderFactoryTest, Create) { // Should only accept video/x-ffmpeg mime type. scoped_refptr<FilterFactory> factory = FFmpegVideoDecoder::CreateFactory(); @@ -112,7 +115,7 @@ TEST(FFmpegVideoDecoderFactoryTest, Create) { TEST_F(FFmpegVideoDecoderTest, Initialize_QueryInterfaceFails) { // Test QueryInterface returning NULL. EXPECT_CALL(*demuxer_, QueryInterface(AVStreamProvider::interface_id())) - .WillOnce(ReturnNull()); + .WillOnce(ReturnNull()); EXPECT_FALSE(decoder_->Initialize(demuxer_)); EXPECT_TRUE(filter_host_->WaitForError(PIPELINE_ERROR_DECODE)); diff --git a/media/filters/file_data_source_unittest.cc b/media/filters/file_data_source_unittest.cc index 1d2f054..8ef1b4b 100644 --- a/media/filters/file_data_source_unittest.cc +++ b/media/filters/file_data_source_unittest.cc @@ -25,16 +25,13 @@ using media::FileDataSource; using media::FilterFactory; using media::FilterFactoryCollection; -using media::InitializationHelper; using media::MediaFormat; -using media::MockDemuxer; -using media::MockAudioDecoder; -using media::MockAudioRenderer; -using media::MockFilterConfig; -using media::MockFilterFactory; using media::MockFilterHost; using media::MockPipeline; using media::PipelineImpl; +using media::old_mocks::InitializationHelper; +using media::old_mocks::MockFilterConfig; +using media::old_mocks::MockFilterFactory; namespace { diff --git a/media/filters/test_video_decoder.h b/media/filters/test_video_decoder.h index 15423d6..ca442bf 100644 --- a/media/filters/test_video_decoder.h +++ b/media/filters/test_video_decoder.h @@ -11,6 +11,7 @@ #include "media/base/buffers.h" #include "media/base/factory.h" #include "media/base/filters.h" +#include "media/base/mock_media_filters.h" #include "media/base/video_frame_impl.h" #include "media/filters/decoder_base.h" @@ -52,7 +53,7 @@ class TestVideoDecoder : public DecoderBase<VideoDecoder, VideoFrame> { buffer->GetDuration(), &frame); if (frame) { - MockVideoDecoder::InitializeYV12Frame(frame, 0.5f); + old_mocks::MockVideoDecoder::InitializeYV12Frame(frame, 0.5f); EnqueueResult(frame); } else { host_->Error(PIPELINE_ERROR_OUT_OF_MEMORY); diff --git a/media/filters/video_decoder_unittest.cc b/media/filters/video_decoder_unittest.cc index d400d2f..621371c 100644 --- a/media/filters/video_decoder_unittest.cc +++ b/media/filters/video_decoder_unittest.cc @@ -15,16 +15,11 @@ using media::FilterFactoryCollection; using media::InstanceFilterFactory; -using media::MockAudioDecoder; -using media::MockAudioRenderer; -using media::MockDataSource; -using media::MockDemuxer; -using media::MockFilterConfig; -using media::MockFilterFactory; -using media::MockVideoRenderer; using media::PipelineImpl; using media::TestVideoDecoder; -using media::VideoFrame; +using media::old_mocks::InitializationHelper; +using media::old_mocks::MockFilterConfig; +using media::old_mocks::MockFilterFactory; TEST(VideoDecoder, CreateTestDecoder) { std::string url(""); @@ -34,7 +29,7 @@ TEST(VideoDecoder, CreateTestDecoder) { scoped_refptr<FilterFactoryCollection> c = new FilterFactoryCollection(); c->AddFactory(new InstanceFilterFactory<TestVideoDecoder>(test_decoder)); c->AddFactory(new MockFilterFactory(&config)); - media::InitializationHelper h; + InitializationHelper h; h.Start(&p, c, url); p.SetPlaybackRate(1.0f); p.Stop(); diff --git a/media/filters/video_renderer_unittest.cc b/media/filters/video_renderer_unittest.cc index c7f6330..9790b24 100644 --- a/media/filters/video_renderer_unittest.cc +++ b/media/filters/video_renderer_unittest.cc @@ -9,12 +9,11 @@ #include "media/filters/test_video_renderer.h" #include "testing/gtest/include/gtest/gtest.h" -using media::FilterFactory; -using media::MockFilterConfig; using media::MockFilterHost; using media::MockPipeline; -using media::MockVideoDecoder; using media::TestVideoRenderer; +using media::old_mocks::MockFilterConfig; +using media::old_mocks::MockVideoDecoder; TEST(VideoRenderer, CreateAndPlay) { // Prepare test data. diff --git a/media/media.gyp b/media/media.gyp index 0545788..b6c895b 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -173,20 +173,6 @@ # gtk/gtk.h '../build/linux/system.gyp:gtk', ], - 'sources!': [ - 'base/mock_ffmpeg.cc', - 'filters/ffmpeg_demuxer_unittest.cc', - 'filters/ffmpeg_glue_unittest.cc', - 'filters/ffmpeg_video_decoder_unittest.cc', - ], - }], - ['OS=="mac"', { - 'sources!': [ - 'base/mock_ffmpeg.cc', - 'filters/ffmpeg_demuxer_unittest.cc', - 'filters/ffmpeg_glue_unittest.cc', - 'filters/ffmpeg_video_decoder_unittest.cc', - ], }], ], }, |