OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 class RendererImplTest : public ::testing::Test { | 37 class RendererImplTest : public ::testing::Test { |
38 public: | 38 public: |
39 // Used for setting expectations on pipeline callbacks. Using a StrictMock | 39 // Used for setting expectations on pipeline callbacks. Using a StrictMock |
40 // also lets us test for missing callbacks. | 40 // also lets us test for missing callbacks. |
41 class CallbackHelper { | 41 class CallbackHelper { |
42 public: | 42 public: |
43 CallbackHelper() {} | 43 CallbackHelper() {} |
44 virtual ~CallbackHelper() {} | 44 virtual ~CallbackHelper() {} |
45 | 45 |
46 MOCK_METHOD0(OnInitialize, void()); | 46 MOCK_METHOD1(OnInitialize, void(PipelineStatus)); |
47 MOCK_METHOD0(OnFlushed, void()); | 47 MOCK_METHOD0(OnFlushed, void()); |
48 MOCK_METHOD0(OnEnded, void()); | 48 MOCK_METHOD0(OnEnded, void()); |
49 MOCK_METHOD1(OnError, void(PipelineStatus)); | 49 MOCK_METHOD1(OnError, void(PipelineStatus)); |
50 MOCK_METHOD1(OnUpdateStatistics, void(const PipelineStatistics&)); | 50 MOCK_METHOD1(OnUpdateStatistics, void(const PipelineStatistics&)); |
51 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); | 51 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); |
52 MOCK_METHOD1(OnVideoFramePaint, void(const scoped_refptr<VideoFrame>&)); | 52 MOCK_METHOD1(OnVideoFramePaint, void(const scoped_refptr<VideoFrame>&)); |
53 | 53 |
54 private: | 54 private: |
55 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); | 55 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); |
56 }; | 56 }; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 // Sets up expectations to allow the video renderer to initialize. | 97 // Sets up expectations to allow the video renderer to initialize. |
98 void SetVideoRendererInitializeExpectations(PipelineStatus status) { | 98 void SetVideoRendererInitializeExpectations(PipelineStatus status) { |
99 EXPECT_CALL(*video_renderer_, | 99 EXPECT_CALL(*video_renderer_, |
100 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _)) | 100 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _)) |
101 .WillOnce(DoAll(SaveArg<4>(&video_buffering_state_cb_), | 101 .WillOnce(DoAll(SaveArg<4>(&video_buffering_state_cb_), |
102 SaveArg<6>(&video_ended_cb_), RunCallback<1>(status))); | 102 SaveArg<6>(&video_ended_cb_), RunCallback<1>(status))); |
103 } | 103 } |
104 | 104 |
105 void InitializeAndExpect(PipelineStatus start_status) { | 105 void InitializeAndExpect(PipelineStatus start_status) { |
106 if (start_status != PIPELINE_OK) | 106 EXPECT_CALL(callbacks_, OnInitialize(start_status)); |
107 EXPECT_CALL(callbacks_, OnError(start_status)); | |
108 | |
109 EXPECT_CALL(callbacks_, OnInitialize()); | |
110 | 107 |
111 if (start_status == PIPELINE_OK && audio_stream_) { | 108 if (start_status == PIPELINE_OK && audio_stream_) { |
112 EXPECT_CALL(*audio_renderer_, GetTimeSource()) | 109 EXPECT_CALL(*audio_renderer_, GetTimeSource()) |
113 .WillOnce(Return(&time_source_)); | 110 .WillOnce(Return(&time_source_)); |
114 } | 111 } |
115 | 112 |
116 renderer_impl_->Initialize( | 113 renderer_impl_->Initialize( |
117 demuxer_.get(), | 114 demuxer_.get(), |
118 base::Bind(&CallbackHelper::OnInitialize, | 115 base::Bind(&CallbackHelper::OnInitialize, |
119 base::Unretained(&callbacks_)), | 116 base::Unretained(&callbacks_)), |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _)) | 436 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _)) |
440 .WillOnce(DoAll(AudioError(&audio_error_cb_, PIPELINE_ERROR_DECODE), | 437 .WillOnce(DoAll(AudioError(&audio_error_cb_, PIPELINE_ERROR_DECODE), |
441 SaveArg<4>(&video_buffering_state_cb_), | 438 SaveArg<4>(&video_buffering_state_cb_), |
442 SaveArg<6>(&video_ended_cb_), | 439 SaveArg<6>(&video_ended_cb_), |
443 RunCallback<1>(PIPELINE_OK))); | 440 RunCallback<1>(PIPELINE_OK))); |
444 | 441 |
445 InitializeAndExpect(PIPELINE_ERROR_DECODE); | 442 InitializeAndExpect(PIPELINE_ERROR_DECODE); |
446 } | 443 } |
447 | 444 |
448 } // namespace media | 445 } // namespace media |
OLD | NEW |