Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: media/filters/renderer_impl_unittest.cc

Issue 870693002: Require Renderer::Initialize() to return a status code via callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Fix comments. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698