| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #define _CRT_SECURE_NO_WARNINGS | 5 #define _CRT_SECURE_NO_WARNINGS |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 MockOmxConfigurator() | 108 MockOmxConfigurator() |
| 109 : OmxConfigurator(MediaFormat(), MediaFormat()) {} | 109 : OmxConfigurator(MediaFormat(), MediaFormat()) {} |
| 110 | 110 |
| 111 MOCK_CONST_METHOD0(GetRoleName, std::string()); | 111 MOCK_CONST_METHOD0(GetRoleName, std::string()); |
| 112 MOCK_CONST_METHOD3(ConfigureIOPorts, | 112 MOCK_CONST_METHOD3(ConfigureIOPorts, |
| 113 bool(OMX_COMPONENTTYPE* component, | 113 bool(OMX_COMPONENTTYPE* component, |
| 114 OMX_PARAM_PORTDEFINITIONTYPE* input_fef, | 114 OMX_PARAM_PORTDEFINITIONTYPE* input_fef, |
| 115 OMX_PARAM_PORTDEFINITIONTYPE* output_def)); | 115 OMX_PARAM_PORTDEFINITIONTYPE* output_def)); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 class MockOmxOutputSink : public OmxOutputSink { | |
| 119 public: | |
| 120 MOCK_CONST_METHOD0(ProvidesEGLImages, bool()); | |
| 121 MOCK_METHOD3(AllocateEGLImages, | |
| 122 bool(int width, int height, | |
| 123 std::vector<EGLImageKHR>* images)); | |
| 124 MOCK_METHOD1(ReleaseEGLImages, | |
| 125 void(const std::vector<EGLImageKHR>& images)); | |
| 126 MOCK_METHOD2(UseThisBuffer, void(int buffer_id, | |
| 127 OMX_BUFFERHEADERTYPE* buffer)); | |
| 128 MOCK_METHOD1(StopUsingThisBuffer, void(int buffer_id)); | |
| 129 MOCK_METHOD2(BufferReady, void(int buffer_id, | |
| 130 BufferUsedCallback* callback)); | |
| 131 }; | |
| 132 | |
| 133 class OmxCodecTest : public testing::Test { | 118 class OmxCodecTest : public testing::Test { |
| 134 public: | 119 public: |
| 135 OmxCodecTest () | 120 OmxCodecTest () |
| 136 : omx_codec_(new OmxCodec(&message_loop_)) { | 121 : omx_codec_(new OmxCodec(&message_loop_)) { |
| 137 omx_codec_->Setup(&mock_configurator_, &mock_output_sink_); | 122 omx_codec_->Setup(&mock_configurator_); |
| 138 } | 123 } |
| 139 | 124 |
| 140 ~OmxCodecTest() { | 125 ~OmxCodecTest() { |
| 141 CHECK(output_units_.size() == 0); | 126 CHECK(output_units_.size() == 0); |
| 142 } | 127 } |
| 143 | 128 |
| 144 protected: | 129 protected: |
| 145 void ExpectSettings() { | 130 void ExpectSettings() { |
| 146 // Return the component name. | 131 // Return the component name. |
| 147 EXPECT_CALL(*MockOmx::get(), GetComponentsOfRole(_, _, IsNull())) | 132 EXPECT_CALL(*MockOmx::get(), GetComponentsOfRole(_, _, IsNull())) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 DoAll( | 184 DoAll( |
| 200 SendEvent(OMX_EventCmdComplete, OMX_CommandStateSet), | 185 SendEvent(OMX_EventCmdComplete, OMX_CommandStateSet), |
| 201 Return(OMX_ErrorNone))); | 186 Return(OMX_ErrorNone))); |
| 202 | 187 |
| 203 // Expect allocation of buffers. | 188 // Expect allocation of buffers. |
| 204 EXPECT_CALL(*MockOmx::get(), | 189 EXPECT_CALL(*MockOmx::get(), |
| 205 UseBuffer(NotNull(), 0, IsNull(), kBufferSize, _)) | 190 UseBuffer(NotNull(), 0, IsNull(), kBufferSize, _)) |
| 206 .Times(kBufferCount) | 191 .Times(kBufferCount) |
| 207 .WillRepeatedly(DoAll(UseBuffer(), Return(OMX_ErrorNone))); | 192 .WillRepeatedly(DoAll(UseBuffer(), Return(OMX_ErrorNone))); |
| 208 | 193 |
| 209 // Don't support EGL images in this case. | |
| 210 EXPECT_CALL(mock_output_sink_, ProvidesEGLImages()) | |
| 211 .WillOnce(Return(false)); | |
| 212 | |
| 213 // Expect allocation of output buffers and send command complete. | 194 // Expect allocation of output buffers and send command complete. |
| 214 EXPECT_CALL(*MockOmx::get(), | 195 EXPECT_CALL(*MockOmx::get(), |
| 215 AllocateBuffer(NotNull(), 1, IsNull(), kBufferSize)) | 196 AllocateBuffer(NotNull(), 1, IsNull(), kBufferSize)) |
| 216 .Times(kBufferCount) | 197 .Times(kBufferCount) |
| 217 .WillRepeatedly(DoAll(AllocateBuffer(), Return(OMX_ErrorNone))); | 198 .WillRepeatedly(DoAll(AllocateBuffer(), Return(OMX_ErrorNone))); |
| 218 | |
| 219 // The allocate output buffers will then be passed to output sink. | |
| 220 for (int i = 0; i < kBufferCount; ++i) { | |
| 221 EXPECT_CALL(mock_output_sink_, UseThisBuffer(i, _)); | |
| 222 } | |
| 223 } | 199 } |
| 224 | 200 |
| 225 void ExpectToExecuting() { | 201 void ExpectToExecuting() { |
| 226 InSequence s; | 202 InSequence s; |
| 227 | 203 |
| 228 // Expect transition to executing. | 204 // Expect transition to executing. |
| 229 EXPECT_CALL(*MockOmx::get(), | 205 EXPECT_CALL(*MockOmx::get(), |
| 230 SendCommand(OMX_CommandStateSet, OMX_StateExecuting, _)) | 206 SendCommand(OMX_CommandStateSet, OMX_StateExecuting, _)) |
| 231 .WillOnce(DoAll( | 207 .WillOnce(DoAll( |
| 232 SendEvent(OMX_EventCmdComplete, OMX_CommandStateSet), | 208 SendEvent(OMX_EventCmdComplete, OMX_CommandStateSet), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 255 SendCommand(OMX_CommandStateSet, OMX_StateLoaded, _)) | 231 SendCommand(OMX_CommandStateSet, OMX_StateLoaded, _)) |
| 256 .WillOnce(DoAll( | 232 .WillOnce(DoAll( |
| 257 SendEvent(OMX_EventCmdComplete, OMX_CommandStateSet), | 233 SendEvent(OMX_EventCmdComplete, OMX_CommandStateSet), |
| 258 Return(OMX_ErrorNone))); | 234 Return(OMX_ErrorNone))); |
| 259 | 235 |
| 260 // Expect free buffer for input port. | 236 // Expect free buffer for input port. |
| 261 EXPECT_CALL(*MockOmx::get(), FreeBuffer(0, NotNull())) | 237 EXPECT_CALL(*MockOmx::get(), FreeBuffer(0, NotNull())) |
| 262 .Times(kBufferCount) | 238 .Times(kBufferCount) |
| 263 .WillRepeatedly(DoAll(FreeBuffer(), Return(OMX_ErrorNone))); | 239 .WillRepeatedly(DoAll(FreeBuffer(), Return(OMX_ErrorNone))); |
| 264 | 240 |
| 265 // Expect free output buffer. | |
| 266 for (int i = 0; i < kBufferCount; ++i) { | |
| 267 EXPECT_CALL(mock_output_sink_, StopUsingThisBuffer(i)); | |
| 268 } | |
| 269 | |
| 270 EXPECT_CALL(*MockOmx::get(), FreeBuffer(1, NotNull())) | 241 EXPECT_CALL(*MockOmx::get(), FreeBuffer(1, NotNull())) |
| 271 .Times(kBufferCount) | 242 .Times(kBufferCount) |
| 272 .WillRepeatedly(DoAll(FreeBuffer(), Return(OMX_ErrorNone))); | 243 .WillRepeatedly(DoAll(FreeBuffer(), Return(OMX_ErrorNone))); |
| 273 | |
| 274 // Report that the sink don't provide EGL images. | |
| 275 EXPECT_CALL(mock_output_sink_, ProvidesEGLImages()) | |
| 276 .WillOnce(Return(false)); | |
| 277 } | 244 } |
| 278 | 245 |
| 279 void ExpectToEmpty() { | 246 void ExpectToEmpty() { |
| 280 InSequence s; | 247 InSequence s; |
| 281 | 248 |
| 282 EXPECT_CALL(*MockOmx::get(), FreeHandle(MockOmx::get()->component())) | 249 EXPECT_CALL(*MockOmx::get(), FreeHandle(MockOmx::get()->component())) |
| 283 .WillOnce(Return(OMX_ErrorNone)); | 250 .WillOnce(Return(OMX_ErrorNone)); |
| 284 EXPECT_CALL(*MockOmx::get(), Deinit()) | 251 EXPECT_CALL(*MockOmx::get(), Deinit()) |
| 285 .WillOnce(Return(OMX_ErrorNone)); | 252 .WillOnce(Return(OMX_ErrorNone)); |
| 286 } | 253 } |
| 287 | 254 |
| 288 // TODO(hclam): Make a more generic about when to stop. | 255 // TODO(hclam): Make a more generic about when to stop. |
| 289 void ExpectStart() { | 256 void ExpectStart() { |
| 290 ExpectToLoaded(); | 257 ExpectToLoaded(); |
| 291 ExpectLoadedToIdle(); | 258 ExpectLoadedToIdle(); |
| 292 ExpectToExecuting(); | 259 ExpectToExecuting(); |
| 293 } | 260 } |
| 294 | 261 |
| 295 void ExpectStop() { | 262 void ExpectStop() { |
| 296 ExpectToIdle(); | 263 ExpectToIdle(); |
| 297 ExpectIdleToLoaded(); | 264 ExpectIdleToLoaded(); |
| 298 ExpectToEmpty(); | 265 ExpectToEmpty(); |
| 299 } | 266 } |
| 300 | 267 |
| 301 void ReadCallback(int buffer_id, | 268 void ReadCallback(OMX_BUFFERHEADERTYPE* buffer) { |
| 302 OmxOutputSink::BufferUsedCallback* callback) { | 269 output_units_.push_back(buffer); |
| 303 output_units_.push_back(std::make_pair(buffer_id, callback)); | |
| 304 } | 270 } |
| 305 | 271 |
| 306 void MakeReadRequest() { | 272 void MakeReadRequest() { |
| 307 omx_codec_->Read(NewCallback(this, &OmxCodecTest::ReadCallback)); | 273 omx_codec_->Read(NewCallback(this, &OmxCodecTest::ReadCallback)); |
| 308 } | 274 } |
| 309 | 275 |
| 310 void SaveFillThisBuffer(OMX_BUFFERHEADERTYPE* buffer) { | 276 void SaveFillThisBuffer(OMX_BUFFERHEADERTYPE* buffer) { |
| 311 fill_this_buffer_received_.push_back(buffer); | 277 fill_this_buffer_received_.push_back(buffer); |
| 312 } | 278 } |
| 313 | 279 |
| 314 void ExpectAndSaveFillThisBuffer() { | 280 void ExpectAndSaveFillThisBuffer() { |
| 315 EXPECT_CALL(*MockOmx::get(), FillThisBuffer(NotNull())) | 281 EXPECT_CALL(*MockOmx::get(), FillThisBuffer(NotNull())) |
| 316 .WillOnce(DoAll(Invoke(this, &OmxCodecTest::SaveFillThisBuffer), | 282 .WillOnce(DoAll(Invoke(this, &OmxCodecTest::SaveFillThisBuffer), |
| 317 Return(OMX_ErrorNone))) | 283 Return(OMX_ErrorNone))) |
| 318 .RetiresOnSaturation(); | 284 .RetiresOnSaturation(); |
| 319 } | 285 } |
| 320 | 286 |
| 321 typedef std::pair<int, OmxOutputSink::BufferUsedCallback*> OutputUnit; | 287 std::deque<OMX_BUFFERHEADERTYPE*> output_units_; |
| 322 std::deque<OutputUnit> output_units_; | |
| 323 std::deque<OMX_BUFFERHEADERTYPE*> fill_this_buffer_received_; | 288 std::deque<OMX_BUFFERHEADERTYPE*> fill_this_buffer_received_; |
| 324 | 289 |
| 325 MockOmx mock_omx_; | 290 MockOmx mock_omx_; |
| 326 MockOmxConfigurator mock_configurator_; | 291 MockOmxConfigurator mock_configurator_; |
| 327 MockOmxOutputSink mock_output_sink_; | |
| 328 | 292 |
| 329 MessageLoop message_loop_; | 293 MessageLoop message_loop_; |
| 330 scoped_refptr<OmxCodec> omx_codec_; | 294 scoped_refptr<OmxCodec> omx_codec_; |
| 331 | 295 |
| 332 MockFilterCallback stop_callback_; | 296 MockFilterCallback stop_callback_; |
| 333 | 297 |
| 334 private: | 298 private: |
| 335 DISALLOW_COPY_AND_ASSIGN(OmxCodecTest); | 299 DISALLOW_COPY_AND_ASSIGN(OmxCodecTest); |
| 336 }; | 300 }; |
| 337 | 301 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 351 TEST_F(OmxCodecTest, EndOfStream) { | 315 TEST_F(OmxCodecTest, EndOfStream) { |
| 352 ExpectSettings(); | 316 ExpectSettings(); |
| 353 ExpectStart(); | 317 ExpectStart(); |
| 354 omx_codec_->Start(); | 318 omx_codec_->Start(); |
| 355 message_loop_.RunAllPending(); | 319 message_loop_.RunAllPending(); |
| 356 | 320 |
| 357 // Make read requests, OmxCodec should have gotten kBufferCount | 321 // Make read requests, OmxCodec should have gotten kBufferCount |
| 358 // buffers already. | 322 // buffers already. |
| 359 EXPECT_EQ(0u, output_units_.size()); | 323 EXPECT_EQ(0u, output_units_.size()); |
| 360 for (int i = 0; i < kBufferCount; ++i) { | 324 for (int i = 0; i < kBufferCount; ++i) { |
| 325 // Give buffers back to OmxCodec. OmxCodec will make a new |
| 326 // FillThisBuffer() call for each read. |
| 327 EXPECT_CALL(*MockOmx::get(), FillThisBuffer(NotNull())) |
| 328 .WillOnce(DoAll(FillEosBuffer(), Return(OMX_ErrorNone))) |
| 329 .RetiresOnSaturation(); |
| 361 MakeReadRequest(); | 330 MakeReadRequest(); |
| 362 } | 331 } |
| 363 message_loop_.RunAllPending(); | 332 message_loop_.RunAllPending(); |
| 364 CHECK(kBufferCount == static_cast<int>(output_units_.size())); | 333 CHECK(kBufferCount == static_cast<int>(output_units_.size())); |
| 365 | 334 |
| 366 // Make sure buffers received are in order. | 335 // Make sure buffers received are in order. |
| 367 for (int i = 0; i < kBufferCount; ++i) { | 336 for (int i = 0; i < kBufferCount; ++i) { |
| 368 EXPECT_EQ(i, output_units_[i].first); | 337 // TODO(jiesun): How to verify this now? |
| 369 EXPECT_TRUE(output_units_[i].second != NULL); | 338 // EXPECT_EQ(i, output_units_[i].first); |
| 339 EXPECT_TRUE(output_units_[i] != NULL); |
| 370 } | 340 } |
| 371 | 341 |
| 372 // Give buffers back to OmxCodec. OmxCodec will make a new | |
| 373 // FillThisBuffer() call for each read. | |
| 374 for (int i = kBufferCount - 1; i >= 0; --i) { | |
| 375 EXPECT_CALL(*MockOmx::get(), FillThisBuffer(NotNull())) | |
| 376 .WillOnce(DoAll(FillEosBuffer(), Return(OMX_ErrorNone))) | |
| 377 .RetiresOnSaturation(); | |
| 378 output_units_[i].second->Run(output_units_[i].first); | |
| 379 delete output_units_[i].second; | |
| 380 } | |
| 381 output_units_.clear(); | 342 output_units_.clear(); |
| 382 | 343 |
| 383 // Make some read requests and make sure end-of-stream buffer id | 344 // Make some read requests and make sure end-of-stream buffer id |
| 384 // are received. | 345 // are received. |
| 385 EXPECT_EQ(0u, output_units_.size()); | 346 EXPECT_EQ(0u, output_units_.size()); |
| 386 for (int i = 0; i < 2 * kBufferCount; ++i) { | 347 for (int i = 0; i < 2 * kBufferCount; ++i) { |
| 387 MakeReadRequest(); | 348 MakeReadRequest(); |
| 388 } | 349 } |
| 389 message_loop_.RunAllPending(); | 350 message_loop_.RunAllPending(); |
| 390 EXPECT_EQ(2 * kBufferCount, static_cast<int>(output_units_.size())); | 351 EXPECT_EQ(2 * kBufferCount, static_cast<int>(output_units_.size())); |
| 391 | 352 |
| 392 for (size_t i = 0; i <output_units_.size(); ++i) { | 353 for (size_t i = 0; i <output_units_.size(); ++i) { |
| 393 EXPECT_EQ(OmxCodec::kEosBuffer, output_units_[i].first); | 354 EXPECT_EQ(NULL, output_units_[i]); |
| 394 EXPECT_EQ(NULL, output_units_[i].second); | |
| 395 } | 355 } |
| 396 output_units_.clear(); | 356 output_units_.clear(); |
| 397 | 357 |
| 398 // Stop OmxCodec. | 358 // Stop OmxCodec. |
| 399 EXPECT_CALL(stop_callback_, OnFilterCallback()); | 359 EXPECT_CALL(stop_callback_, OnFilterCallback()); |
| 400 EXPECT_CALL(stop_callback_, OnCallbackDestroyed()); | 360 EXPECT_CALL(stop_callback_, OnCallbackDestroyed()); |
| 401 ExpectStop(); | 361 ExpectStop(); |
| 402 omx_codec_->Stop(stop_callback_.NewCallback()); | 362 omx_codec_->Stop(stop_callback_.NewCallback()); |
| 403 message_loop_.RunAllPending(); | 363 message_loop_.RunAllPending(); |
| 404 } | 364 } |
| 405 | 365 |
| 406 TEST_F(OmxCodecTest, OutputFlowControl) { | 366 TEST_F(OmxCodecTest, OutputFlowControl) { |
| 407 ExpectSettings(); | 367 ExpectSettings(); |
| 408 ExpectStart(); | 368 ExpectStart(); |
| 409 omx_codec_->Start(); | 369 omx_codec_->Start(); |
| 410 message_loop_.RunAllPending(); | 370 message_loop_.RunAllPending(); |
| 411 | 371 |
| 412 // Since initial FillThisBuffer() calls are made and fulfilled during | 372 // Since initial FillThisBuffer() calls are made and fulfilled during |
| 413 // start. Reads issued to OmxCodec will be fulfilled now. | 373 // start. Reads issued to OmxCodec will be fulfilled now. |
| 414 EXPECT_EQ(0u, output_units_.size()); | 374 EXPECT_EQ(0u, output_units_.size()); |
| 415 for (int i = 0; i < kBufferCount; ++i) { | 375 for (int i = 0; i < kBufferCount; ++i) { |
| 376 ExpectAndSaveFillThisBuffer(); |
| 416 MakeReadRequest(); | 377 MakeReadRequest(); |
| 417 } | 378 } |
| 418 message_loop_.RunAllPending(); | 379 message_loop_.RunAllPending(); |
| 419 CHECK(kBufferCount == static_cast<int>(output_units_.size())); | 380 CHECK(kBufferCount == static_cast<int>(output_units_.size())); |
| 420 | 381 |
| 421 // Make sure buffers received are in order. | 382 // Make sure buffers received are in order. |
| 422 for (int i = 0; i < kBufferCount; ++i) { | 383 for (int i = 0; i < kBufferCount; ++i) { |
| 423 EXPECT_EQ(i, output_units_[i].first); | 384 EXPECT_TRUE(output_units_[i] != NULL); |
| 424 EXPECT_TRUE(output_units_[i].second != NULL); | |
| 425 } | 385 } |
| 426 | 386 |
| 427 // Give the buffer back in reverse order. | |
| 428 for (int i = kBufferCount - 1; i >= 0; --i) { | |
| 429 ExpectAndSaveFillThisBuffer(); | |
| 430 output_units_[i].second->Run(output_units_[i].first); | |
| 431 delete output_units_[i].second; | |
| 432 } | |
| 433 output_units_.clear(); | 387 output_units_.clear(); |
| 434 | 388 |
| 435 // In each loop, perform the following actions: | 389 // In each loop, perform the following actions: |
| 436 // 1. Make a read request to OmxCodec. | 390 // 1. Make a read request to OmxCodec. |
| 437 // 2. Fake a response for FillBufferDone(). | 391 // 2. Fake a response for FillBufferDone(). |
| 438 // 3. Expect read response received. | 392 // 3. Expect read response received. |
| 439 // 4. Give the buffer read back to OmxCodec. | |
| 440 // 5. Expect a FillThisBuffer() is called to OpenMAX. | |
| 441 for (int i = 0; i < kBufferCount; ++i) { | 393 for (int i = 0; i < kBufferCount; ++i) { |
| 442 // 1. First make a read request. | 394 // 1. First make a read request. |
| 395 // Since a buffer is given back to OmxCodec. A FillThisBuffer() is called |
| 396 // to OmxCodec. |
| 397 EXPECT_CALL(*MockOmx::get(), FillThisBuffer(NotNull())) |
| 398 .WillOnce(Return(OMX_ErrorNone)) |
| 399 .RetiresOnSaturation(); |
| 443 MakeReadRequest(); | 400 MakeReadRequest(); |
| 444 | 401 |
| 445 // 2. Then fake a response from OpenMAX. | 402 // 2. Then fake a response from OpenMAX. |
| 446 OMX_BUFFERHEADERTYPE* buffer = fill_this_buffer_received_.front(); | 403 OMX_BUFFERHEADERTYPE* buffer = fill_this_buffer_received_.front(); |
| 447 fill_this_buffer_received_.pop_front(); | 404 fill_this_buffer_received_.pop_front(); |
| 448 buffer->nFlags = 0; | 405 buffer->nFlags = 0; |
| 449 buffer->nFilledLen = kBufferSize; | 406 buffer->nFilledLen = kBufferSize; |
| 450 (*MockOmx::get()->callbacks()->FillBufferDone)( | 407 (*MockOmx::get()->callbacks()->FillBufferDone)( |
| 451 MockOmx::get()->component(), | 408 MockOmx::get()->component(), |
| 452 MockOmx::get()->component()->pApplicationPrivate, | 409 MockOmx::get()->component()->pApplicationPrivate, |
| 453 buffer); | 410 buffer); |
| 454 | 411 |
| 455 // Make sure actions are completed. | 412 // Make sure actions are completed. |
| 456 message_loop_.RunAllPending(); | 413 message_loop_.RunAllPending(); |
| 457 | 414 |
| 458 // 3. Expect read response received. | 415 // 3. Expect read response received. |
| 459 // The above action will cause a read callback be called and we should | 416 // The above action will cause a read callback be called and we should |
| 460 // receive one buffer now. Also expect the buffer id be received in | 417 // receive one buffer now. Also expect the buffer id be received in |
| 461 // reverse order. | 418 // reverse order. |
| 462 EXPECT_EQ(1u, output_units_.size()); | 419 EXPECT_EQ(1u, output_units_.size()); |
| 463 EXPECT_EQ(kBufferCount - i - 1, output_units_.front().first); | 420 //EXPECT_EQ(kBufferCount - i - 1, output_units_.front().first); |
| 464 | 421 |
| 465 // 4. Since a buffer is given back to OmxCodec. A FillThisBuffer() is called | |
| 466 // to OmxCodec. | |
| 467 EXPECT_CALL(*MockOmx::get(), FillThisBuffer(NotNull())) | |
| 468 .WillOnce(Return(OMX_ErrorNone)) | |
| 469 .RetiresOnSaturation(); | |
| 470 | |
| 471 // 5. Give this buffer back to OmxCodec. | |
| 472 output_units_.front().second->Run(output_units_.front().first); | |
| 473 delete output_units_.front().second; | |
| 474 output_units_.pop_front(); | 422 output_units_.pop_front(); |
| 475 | 423 |
| 476 // Make sure actions are completed. | 424 // Make sure actions are completed. |
| 477 message_loop_.RunAllPending(); | 425 message_loop_.RunAllPending(); |
| 478 } | 426 } |
| 479 | 427 |
| 480 // Now issue kBufferCount reads to OmxCodec. | 428 // Now issue kBufferCount reads to OmxCodec. |
| 481 EXPECT_EQ(0u, output_units_.size()); | 429 EXPECT_EQ(0u, output_units_.size()); |
| 482 | 430 |
| 483 // Stop OmxCodec. | 431 // Stop OmxCodec. |
| 484 EXPECT_CALL(stop_callback_, OnFilterCallback()); | 432 EXPECT_CALL(stop_callback_, OnFilterCallback()); |
| 485 EXPECT_CALL(stop_callback_, OnCallbackDestroyed()); | 433 EXPECT_CALL(stop_callback_, OnCallbackDestroyed()); |
| 486 ExpectStop(); | 434 ExpectStop(); |
| 487 omx_codec_->Stop(stop_callback_.NewCallback()); | 435 omx_codec_->Stop(stop_callback_.NewCallback()); |
| 488 message_loop_.RunAllPending(); | 436 message_loop_.RunAllPending(); |
| 489 } | 437 } |
| 490 | 438 |
| 491 // TODO(hclam): Add test case for dynamic port config. | 439 // TODO(hclam): Add test case for dynamic port config. |
| 492 // TODO(hclam): Create a more complicated test case so that read | 440 // TODO(hclam): Create a more complicated test case so that read |
| 493 // requests and reply from FillThisBuffer() arrives out of order. | 441 // requests and reply from FillThisBuffer() arrives out of order. |
| 494 // TODO(hclam): Add test case for Feed(). | 442 // TODO(hclam): Add test case for Feed(). |
| 495 | 443 |
| 496 } // namespace media | 444 } // namespace media |
| OLD | NEW |