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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 24 matching lines...) Expand all Loading... | |
35 } | 35 } |
36 | 36 |
37 ACTION_P2(AudioError, cb, error) { | 37 ACTION_P2(AudioError, cb, error) { |
38 cb->Run(error); | 38 cb->Run(error); |
39 } | 39 } |
40 | 40 |
41 class RendererImplTest : public ::testing::Test { | 41 class RendererImplTest : public ::testing::Test { |
42 public: | 42 public: |
43 // Used for setting expectations on pipeline callbacks. Using a StrictMock | 43 // Used for setting expectations on pipeline callbacks. Using a StrictMock |
44 // also lets us test for missing callbacks. | 44 // also lets us test for missing callbacks. |
45 class CallbackHelper { | 45 class CallbackHelper : public RendererClient { |
46 public: | 46 public: |
47 CallbackHelper() {} | 47 CallbackHelper() {} |
48 virtual ~CallbackHelper() {} | 48 virtual ~CallbackHelper() {} |
49 | 49 |
50 // RendererClient implementation. | |
51 MOCK_METHOD1(OnError, void(PipelineStatus status)); | |
52 MOCK_METHOD0(OnEnded, void()); | |
53 MOCK_METHOD1(OnStatistics, void(const PipelineStatistics&)); | |
54 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); | |
55 MOCK_METHOD0(OnWaitingForDecryptionKey, void()); | |
xhwang
2016/05/09 18:13:23
Can you use the new MockRendererClient with Strict
alokp
2016/05/09 21:31:44
Do you mean derive from MockRendererClient instead
xhwang
2016/05/12 20:51:18
The reason we use CallbackHelper is that we can us
| |
56 | |
57 // Completion callbacks. | |
50 MOCK_METHOD1(OnInitialize, void(PipelineStatus)); | 58 MOCK_METHOD1(OnInitialize, void(PipelineStatus)); |
51 MOCK_METHOD0(OnFlushed, void()); | 59 MOCK_METHOD0(OnFlushed, void()); |
52 MOCK_METHOD0(OnEnded, void()); | |
53 MOCK_METHOD1(OnError, void(PipelineStatus)); | |
54 MOCK_METHOD1(OnUpdateStatistics, void(const PipelineStatistics&)); | |
55 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); | |
56 MOCK_METHOD0(OnWaitingForDecryptionKey, void()); | |
57 MOCK_METHOD1(OnCdmAttached, void(bool)); | 60 MOCK_METHOD1(OnCdmAttached, void(bool)); |
58 | 61 |
59 private: | 62 private: |
60 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); | 63 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); |
61 }; | 64 }; |
62 | 65 |
63 RendererImplTest() | 66 RendererImplTest() |
64 : demuxer_(new StrictMock<MockDemuxer>()), | 67 : demuxer_(new StrictMock<MockDemuxer>()), |
65 video_renderer_(new StrictMock<MockVideoRenderer>()), | 68 video_renderer_(new StrictMock<MockVideoRenderer>()), |
66 audio_renderer_(new StrictMock<MockAudioRenderer>()), | 69 audio_renderer_(new StrictMock<MockAudioRenderer>()), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 void SetAudioRendererInitializeExpectations(PipelineStatus status) { | 101 void SetAudioRendererInitializeExpectations(PipelineStatus status) { |
99 EXPECT_CALL(*audio_renderer_, | 102 EXPECT_CALL(*audio_renderer_, |
100 Initialize(audio_stream_.get(), _, _, _, _, _, _, _)) | 103 Initialize(audio_stream_.get(), _, _, _, _, _, _, _)) |
101 .WillOnce(DoAll(SaveArg<4>(&audio_buffering_state_cb_), | 104 .WillOnce(DoAll(SaveArg<4>(&audio_buffering_state_cb_), |
102 SaveArg<5>(&audio_ended_cb_), | 105 SaveArg<5>(&audio_ended_cb_), |
103 SaveArg<6>(&audio_error_cb_), RunCallback<1>(status))); | 106 SaveArg<6>(&audio_error_cb_), RunCallback<1>(status))); |
104 } | 107 } |
105 | 108 |
106 // Sets up expectations to allow the video renderer to initialize. | 109 // Sets up expectations to allow the video renderer to initialize. |
107 void SetVideoRendererInitializeExpectations(PipelineStatus status) { | 110 void SetVideoRendererInitializeExpectations(PipelineStatus status) { |
108 EXPECT_CALL(*video_renderer_, | 111 EXPECT_CALL(*video_renderer_, Initialize(_, video_stream_.get(), _, _, _)) |
109 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _)) | |
110 .WillOnce(DoAll(SaveArg<4>(&video_buffering_state_cb_), | 112 .WillOnce(DoAll(SaveArg<4>(&video_buffering_state_cb_), |
111 SaveArg<5>(&video_ended_cb_), RunCallback<1>(status))); | 113 SaveArg<5>(&video_ended_cb_), RunCallback<1>(status))); |
112 } | 114 } |
113 | 115 |
114 void InitializeAndExpect(PipelineStatus start_status) { | 116 void InitializeAndExpect(PipelineStatus start_status) { |
115 EXPECT_CALL(callbacks_, OnInitialize(start_status)) | 117 EXPECT_CALL(callbacks_, OnInitialize(start_status)) |
116 .WillOnce(SaveArg<0>(&initialization_status_)); | 118 .WillOnce(SaveArg<0>(&initialization_status_)); |
117 EXPECT_CALL(callbacks_, OnWaitingForDecryptionKey()).Times(0); | 119 EXPECT_CALL(callbacks_, OnWaitingForDecryptionKey()).Times(0); |
118 | 120 |
119 if (start_status == PIPELINE_OK && audio_stream_) { | 121 if (start_status == PIPELINE_OK && audio_stream_) { |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
719 .WillOnce( | 721 .WillOnce( |
720 SetBufferingState(&audio_buffering_state_cb_, BUFFERING_HAVE_ENOUGH)); | 722 SetBufferingState(&audio_buffering_state_cb_, BUFFERING_HAVE_ENOUGH)); |
721 EXPECT_CALL(*video_renderer_, StartPlayingFrom(kStartTime)); | 723 EXPECT_CALL(*video_renderer_, StartPlayingFrom(kStartTime)); |
722 renderer_impl_->StartPlayingFrom(kStartTime); | 724 renderer_impl_->StartPlayingFrom(kStartTime); |
723 | 725 |
724 // Nothing else should primed on the message loop. | 726 // Nothing else should primed on the message loop. |
725 base::RunLoop().RunUntilIdle(); | 727 base::RunLoop().RunUntilIdle(); |
726 } | 728 } |
727 | 729 |
728 } // namespace media | 730 } // namespace media |
OLD | NEW |