Chromium Code Reviews| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "media/base/data_buffer.h" | 7 #include "media/base/data_buffer.h" |
| 8 #include "media/base/mock_ffmpeg.h" | 8 #include "media/base/mock_ffmpeg.h" |
| 9 #include "media/base/mock_task.h" | 9 #include "media/base/mock_task.h" |
| 10 #include "media/base/pipeline.h" | 10 #include "media/base/pipeline.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 test_engine_.reset(); | 79 test_engine_.reset(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void Initialize() { | 82 void Initialize() { |
| 83 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext()) | 83 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext()) |
| 84 .WillOnce(Return(&codec_context_)); | 84 .WillOnce(Return(&codec_context_)); |
| 85 EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264)) | 85 EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264)) |
| 86 .WillOnce(Return(&codec_)); | 86 .WillOnce(Return(&codec_)); |
| 87 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame()) | 87 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame()) |
| 88 .WillOnce(Return(&yuv_frame_)); | 88 .WillOnce(Return(&yuv_frame_)); |
| 89 EXPECT_CALL(mock_ffmpeg_, AVCodecThreadInit(&codec_context_, 2)) | 89 // EXPECT_CALL(mock_ffmpeg_, AVCodecThreadInit(&codec_context_, 2)) |
| 90 .WillOnce(Return(0)); | 90 // .WillOnce(Return(0)); |
|
scherkus (not reviewing)
2011/06/29 17:00:36
you can remove
ilja
2011/06/29 21:40:05
Done.
| |
| 91 EXPECT_CALL(mock_ffmpeg_, AVCodecOpen(&codec_context_, &codec_)) | 91 EXPECT_CALL(mock_ffmpeg_, AVCodecOpen(&codec_context_, &codec_)) |
| 92 .WillOnce(Return(0)); | 92 .WillOnce(Return(0)); |
| 93 EXPECT_CALL(mock_ffmpeg_, AVCodecClose(&codec_context_)) | 93 EXPECT_CALL(mock_ffmpeg_, AVCodecClose(&codec_context_)) |
| 94 .WillOnce(Return(0)); | 94 .WillOnce(Return(0)); |
| 95 EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_)) | 95 EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_)) |
| 96 .Times(1); | 96 .Times(1); |
| 97 EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_)) | 97 EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_)) |
| 98 .Times(1); | 98 .Times(1); |
| 99 | 99 |
| 100 EXPECT_CALL(*this, OnInitializeComplete(_)) | 100 EXPECT_CALL(*this, OnInitializeComplete(_)) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 .Times(1); | 182 .Times(1); |
| 183 EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_)) | 183 EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_)) |
| 184 .Times(1); | 184 .Times(1); |
| 185 | 185 |
| 186 EXPECT_CALL(*this, OnInitializeComplete(_)) | 186 EXPECT_CALL(*this, OnInitializeComplete(_)) |
| 187 .WillOnce(SaveInitializeResult(this)); | 187 .WillOnce(SaveInitializeResult(this)); |
| 188 test_engine_->Initialize(MessageLoop::current(), this, NULL, config_); | 188 test_engine_->Initialize(MessageLoop::current(), this, NULL, config_); |
| 189 EXPECT_FALSE(info_.success); | 189 EXPECT_FALSE(info_.success); |
| 190 } | 190 } |
| 191 | 191 |
| 192 // Note There are 2 threads for FFmpeg-mt. | 192 /* |
| 193 TODO(ihf): remove this as test is obsolete | |
| 194 (InitThread can't fail anymore as is deprecated) | |
|
scherkus (not reviewing)
2011/06/29 17:00:36
just nuke the test :)
ilja
2011/06/29 21:40:05
Done.
| |
| 195 // Note There are 2 threads for FFmpeg | |
| 193 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_InitThreadFails) { | 196 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_InitThreadFails) { |
| 194 // Test avcodec_thread_init() failing. | 197 // Test avcodec_thread_init() failing. |
| 195 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext()) | 198 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext()) |
| 196 .WillOnce(Return(&codec_context_)); | 199 .WillOnce(Return(&codec_context_)); |
| 197 EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264)) | 200 EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264)) |
| 198 .WillOnce(Return(&codec_)); | 201 .WillOnce(Return(&codec_)); |
| 199 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame()) | 202 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame()) |
| 200 .WillOnce(Return(&yuv_frame_)); | 203 .WillOnce(Return(&yuv_frame_)); |
| 201 EXPECT_CALL(mock_ffmpeg_, AVCodecThreadInit(&codec_context_, 2)) | 204 EXPECT_CALL(mock_ffmpeg_, AVCodecThreadInit(&codec_context_, 2)) |
| 202 .WillOnce(Return(-1)); | 205 .WillOnce(Return(-1)); |
| 203 EXPECT_CALL(mock_ffmpeg_, AVCodecClose(&codec_context_)) | 206 EXPECT_CALL(mock_ffmpeg_, AVCodecClose(&codec_context_)) |
| 204 .WillOnce(Return(0)); | 207 .WillOnce(Return(0)); |
| 205 EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_)) | 208 EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_)) |
| 206 .Times(1); | 209 .Times(1); |
| 207 EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_)) | 210 EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_)) |
| 208 .Times(1); | 211 .Times(1); |
| 209 | 212 |
| 210 EXPECT_CALL(*this, OnInitializeComplete(_)) | 213 EXPECT_CALL(*this, OnInitializeComplete(_)) |
| 211 .WillOnce(SaveInitializeResult(this)); | 214 .WillOnce(SaveInitializeResult(this)); |
| 212 test_engine_->Initialize(MessageLoop::current(), this, NULL, config_); | 215 test_engine_->Initialize(MessageLoop::current(), this, NULL, config_); |
| 213 EXPECT_FALSE(info_.success); | 216 EXPECT_FALSE(info_.success); |
| 214 } | 217 } |
| 218 */ | |
| 215 | 219 |
| 216 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) { | 220 TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) { |
| 217 // Test avcodec_open() failing. | 221 // Test avcodec_open() failing. |
| 218 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext()) | 222 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocContext()) |
| 219 .WillOnce(Return(&codec_context_)); | 223 .WillOnce(Return(&codec_context_)); |
| 220 EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264)) | 224 EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_H264)) |
| 221 .WillOnce(Return(&codec_)); | 225 .WillOnce(Return(&codec_)); |
| 222 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame()) | 226 EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame()) |
| 223 .WillOnce(Return(&yuv_frame_)); | 227 .WillOnce(Return(&yuv_frame_)); |
| 224 EXPECT_CALL(mock_ffmpeg_, AVCodecThreadInit(&codec_context_, 2)) | 228 // EXPECT_CALL(mock_ffmpeg_, AVCodecThreadInit(&codec_context_, 2)) |
| 225 .WillOnce(Return(0)); | 229 // .WillOnce(Return(0)); |
|
scherkus (not reviewing)
2011/06/29 17:00:36
ditto
ilja
2011/06/29 21:40:05
Done.
| |
| 226 EXPECT_CALL(mock_ffmpeg_, AVCodecOpen(&codec_context_, &codec_)) | 230 EXPECT_CALL(mock_ffmpeg_, AVCodecOpen(&codec_context_, &codec_)) |
| 227 .WillOnce(Return(-1)); | 231 .WillOnce(Return(-1)); |
| 228 EXPECT_CALL(mock_ffmpeg_, AVCodecClose(&codec_context_)) | 232 EXPECT_CALL(mock_ffmpeg_, AVCodecClose(&codec_context_)) |
| 229 .WillOnce(Return(0)); | 233 .WillOnce(Return(0)); |
| 230 EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_)) | 234 EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_)) |
| 231 .Times(1); | 235 .Times(1); |
| 232 EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_)) | 236 EXPECT_CALL(mock_ffmpeg_, AVFree(&codec_context_)) |
| 233 .Times(1); | 237 .Times(1); |
| 234 | 238 |
| 235 EXPECT_CALL(*this, OnInitializeComplete(_)) | 239 EXPECT_CALL(*this, OnInitializeComplete(_)) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 EXPECT_EQ(VideoFrame::YV16, test_engine_->GetSurfaceFormat()); | 339 EXPECT_EQ(VideoFrame::YV16, test_engine_->GetSurfaceFormat()); |
| 336 codec_context_.pix_fmt = PIX_FMT_YUVJ422P; | 340 codec_context_.pix_fmt = PIX_FMT_YUVJ422P; |
| 337 EXPECT_EQ(VideoFrame::YV16, test_engine_->GetSurfaceFormat()); | 341 EXPECT_EQ(VideoFrame::YV16, test_engine_->GetSurfaceFormat()); |
| 338 | 342 |
| 339 // Invalid value. | 343 // Invalid value. |
| 340 codec_context_.pix_fmt = PIX_FMT_NONE; | 344 codec_context_.pix_fmt = PIX_FMT_NONE; |
| 341 EXPECT_EQ(VideoFrame::INVALID, test_engine_->GetSurfaceFormat()); | 345 EXPECT_EQ(VideoFrame::INVALID, test_engine_->GetSurfaceFormat()); |
| 342 } | 346 } |
| 343 | 347 |
| 344 } // namespace media | 348 } // namespace media |
| OLD | NEW |