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(session_, &host_stub_)); | 103 connection_.reset(new MockConnectionToClient( |
| 104 session_, &host_stub_, &event_executor_)); |
104 connection_->SetEventHandler(&handler_); | 105 connection_->SetEventHandler(&handler_); |
105 | 106 |
106 record_ = new ScreenRecorder( | 107 record_ = new ScreenRecorder( |
107 message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), | 108 message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), |
108 message_loop_.message_loop_proxy(), &capturer_, encoder_); | 109 message_loop_.message_loop_proxy(), &capturer_, encoder_); |
109 } | 110 } |
110 | 111 |
111 virtual void TearDown() OVERRIDE { | 112 virtual void TearDown() OVERRIDE { |
112 connection_.reset(); | 113 connection_.reset(); |
113 // Run message loop before destroying because protocol::Session is | 114 // Run message loop before destroying because protocol::Session is |
114 // destroyed asynchronously. | 115 // destroyed asynchronously. |
115 message_loop_.RunAllPending(); | 116 message_loop_.RunAllPending(); |
116 } | 117 } |
117 | 118 |
118 protected: | 119 protected: |
119 MessageLoop message_loop_; | 120 MessageLoop message_loop_; |
120 scoped_refptr<ScreenRecorder> record_; | 121 scoped_refptr<ScreenRecorder> record_; |
121 | 122 |
122 MockConnectionToClientEventHandler handler_; | 123 MockConnectionToClientEventHandler handler_; |
123 MockHostStub host_stub_; | 124 MockHostStub host_stub_; |
| 125 MockEventExecutor event_executor_; |
124 MockSession* session_; // Owned by |connection_|. | 126 MockSession* session_; // Owned by |connection_|. |
125 scoped_ptr<MockConnectionToClient> connection_; | 127 scoped_ptr<MockConnectionToClient> connection_; |
126 | 128 |
127 // The following mock objects are owned by ScreenRecorder. | 129 // The following mock objects are owned by ScreenRecorder. |
128 MockVideoFrameCapturer capturer_; | 130 MockVideoFrameCapturer capturer_; |
129 MockVideoEncoder* encoder_; | 131 MockVideoEncoder* encoder_; |
130 | 132 |
131 private: | 133 private: |
132 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); | 134 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); |
133 }; | 135 }; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 message_loop_.Run(); | 193 message_loop_.Run(); |
192 } | 194 } |
193 | 195 |
194 TEST_F(ScreenRecorderTest, StopWithoutStart) { | 196 TEST_F(ScreenRecorderTest, StopWithoutStart) { |
195 EXPECT_CALL(capturer_, Stop()); | 197 EXPECT_CALL(capturer_, Stop()); |
196 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); | 198 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); |
197 message_loop_.Run(); | 199 message_loop_.Run(); |
198 } | 200 } |
199 | 201 |
200 } // namespace remoting | 202 } // namespace remoting |
OLD | NEW |