OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/screen_recorder.h" | 5 #include "remoting/host/screen_recorder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "remoting/base/capture_data.h" | 9 #include "remoting/base/capture_data.h" |
10 #include "remoting/codec/video_encoder.h" | 10 #include "remoting/codec/video_encoder.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 | 94 |
95 virtual void SetUp() OVERRIDE { | 95 virtual void SetUp() OVERRIDE { |
96 // VideoFrameCapturer and VideoEncoder are owned by ScreenRecorder. | 96 // VideoFrameCapturer and VideoEncoder are owned by ScreenRecorder. |
97 encoder_ = new MockVideoEncoder(); | 97 encoder_ = new MockVideoEncoder(); |
98 | 98 |
99 session_ = new MockSession(); | 99 session_ = new MockSession(); |
100 EXPECT_CALL(*session_, SetEventHandler(_)); | 100 EXPECT_CALL(*session_, SetEventHandler(_)); |
101 EXPECT_CALL(*session_, Close()) | 101 EXPECT_CALL(*session_, Close()) |
102 .Times(AnyNumber()); | 102 .Times(AnyNumber()); |
103 connection_.reset(new MockConnectionToClient( | 103 connection_.reset(new MockConnectionToClient(session_, &host_stub_)); |
104 session_, &host_stub_, &event_executor_)); | |
105 connection_->SetEventHandler(&handler_); | 104 connection_->SetEventHandler(&handler_); |
106 | 105 |
107 record_ = new ScreenRecorder( | 106 record_ = new ScreenRecorder( |
108 message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), | 107 message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), |
109 message_loop_.message_loop_proxy(), &capturer_, encoder_); | 108 message_loop_.message_loop_proxy(), &capturer_, encoder_); |
110 } | 109 } |
111 | 110 |
112 virtual void TearDown() OVERRIDE { | 111 virtual void TearDown() OVERRIDE { |
113 connection_.reset(); | 112 connection_.reset(); |
114 // Run message loop before destroying because protocol::Session is | 113 // Run message loop before destroying because protocol::Session is |
115 // destroyed asynchronously. | 114 // destroyed asynchronously. |
116 message_loop_.RunAllPending(); | 115 message_loop_.RunAllPending(); |
117 } | 116 } |
118 | 117 |
119 protected: | 118 protected: |
120 MessageLoop message_loop_; | 119 MessageLoop message_loop_; |
121 scoped_refptr<ScreenRecorder> record_; | 120 scoped_refptr<ScreenRecorder> record_; |
122 | 121 |
123 MockConnectionToClientEventHandler handler_; | 122 MockConnectionToClientEventHandler handler_; |
124 MockHostStub host_stub_; | 123 MockHostStub host_stub_; |
125 MockEventExecutor event_executor_; | |
126 MockSession* session_; // Owned by |connection_|. | 124 MockSession* session_; // Owned by |connection_|. |
127 scoped_ptr<MockConnectionToClient> connection_; | 125 scoped_ptr<MockConnectionToClient> connection_; |
128 | 126 |
129 // The following mock objects are owned by ScreenRecorder. | 127 // The following mock objects are owned by ScreenRecorder. |
130 MockVideoFrameCapturer capturer_; | 128 MockVideoFrameCapturer capturer_; |
131 MockVideoEncoder* encoder_; | 129 MockVideoEncoder* encoder_; |
132 | 130 |
133 private: | 131 private: |
134 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); | 132 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); |
135 }; | 133 }; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 message_loop_.Run(); | 191 message_loop_.Run(); |
194 } | 192 } |
195 | 193 |
196 TEST_F(ScreenRecorderTest, StopWithoutStart) { | 194 TEST_F(ScreenRecorderTest, StopWithoutStart) { |
197 EXPECT_CALL(capturer_, Stop()); | 195 EXPECT_CALL(capturer_, Stop()); |
198 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); | 196 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); |
199 message_loop_.Run(); | 197 message_loop_.Run(); |
200 } | 198 } |
201 | 199 |
202 } // namespace remoting | 200 } // namespace remoting |
OLD | NEW |