OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 return frame; | 71 return frame; |
72 } | 72 } |
73 | 73 |
74 class FakeScreenCapturer : public DesktopCapturer { | 74 class FakeScreenCapturer : public DesktopCapturer { |
75 public: | 75 public: |
76 FakeScreenCapturer() {} | 76 FakeScreenCapturer() {} |
77 | 77 |
78 void Start(Callback* callback) override { callback_ = callback; } | 78 void Start(Callback* callback) override { callback_ = callback; } |
79 | 79 |
80 void Capture(const DesktopRegion& region) override { | 80 void CaptureFrame() override { |
81 callback_->OnCaptureResult( | 81 callback_->OnCaptureResult( |
82 next_frame_ ? Result::SUCCESS : Result::ERROR_TEMPORARY, | 82 next_frame_ ? Result::SUCCESS : Result::ERROR_TEMPORARY, |
83 std::move(next_frame_)); | 83 std::move(next_frame_)); |
84 } | 84 } |
85 | 85 |
86 void SetNextFrame(std::unique_ptr<DesktopFrame> next_frame) { | 86 void SetNextFrame(std::unique_ptr<DesktopFrame> next_frame) { |
87 next_frame_ = std::move(next_frame); | 87 next_frame_ = std::move(next_frame); |
88 } | 88 } |
89 | 89 |
90 private: | 90 private: |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 // Verify DesktopAndCursorComposer can handle the case when the screen capturer | 187 // Verify DesktopAndCursorComposer can handle the case when the screen capturer |
188 // fails. | 188 // fails. |
189 TEST_F(DesktopAndCursorComposerTest, Error) { | 189 TEST_F(DesktopAndCursorComposerTest, Error) { |
190 blender_.Start(this); | 190 blender_.Start(this); |
191 | 191 |
192 fake_cursor_->SetHotspot(DesktopVector()); | 192 fake_cursor_->SetHotspot(DesktopVector()); |
193 fake_cursor_->SetState(MouseCursorMonitor::INSIDE, DesktopVector()); | 193 fake_cursor_->SetState(MouseCursorMonitor::INSIDE, DesktopVector()); |
194 fake_screen_->SetNextFrame(nullptr); | 194 fake_screen_->SetNextFrame(nullptr); |
195 | 195 |
196 blender_.Capture(DesktopRegion()); | 196 blender_.CaptureFrame(); |
197 | 197 |
198 EXPECT_FALSE(frame_); | 198 EXPECT_FALSE(frame_); |
199 } | 199 } |
200 | 200 |
201 TEST_F(DesktopAndCursorComposerTest, Blend) { | 201 TEST_F(DesktopAndCursorComposerTest, Blend) { |
202 struct { | 202 struct { |
203 int x, y; | 203 int x, y; |
204 int hotspot_x, hotspot_y; | 204 int hotspot_x, hotspot_y; |
205 bool inside; | 205 bool inside; |
206 } tests[] = { | 206 } tests[] = { |
(...skipping 23 matching lines...) Expand all Loading... |
230 MouseCursorMonitor::CursorState state = tests[i].inside | 230 MouseCursorMonitor::CursorState state = tests[i].inside |
231 ? MouseCursorMonitor::INSIDE | 231 ? MouseCursorMonitor::INSIDE |
232 : MouseCursorMonitor::OUTSIDE; | 232 : MouseCursorMonitor::OUTSIDE; |
233 DesktopVector pos(tests[i].x, tests[i].y); | 233 DesktopVector pos(tests[i].x, tests[i].y); |
234 fake_cursor_->SetState(state, pos); | 234 fake_cursor_->SetState(state, pos); |
235 | 235 |
236 std::unique_ptr<SharedDesktopFrame> frame( | 236 std::unique_ptr<SharedDesktopFrame> frame( |
237 SharedDesktopFrame::Wrap(CreateTestFrame())); | 237 SharedDesktopFrame::Wrap(CreateTestFrame())); |
238 fake_screen_->SetNextFrame(frame->Share()); | 238 fake_screen_->SetNextFrame(frame->Share()); |
239 | 239 |
240 blender_.Capture(DesktopRegion()); | 240 blender_.CaptureFrame(); |
241 | 241 |
242 VerifyFrame(*frame_, state, pos); | 242 VerifyFrame(*frame_, state, pos); |
243 | 243 |
244 // Verify that the cursor is erased before the frame buffer is returned to | 244 // Verify that the cursor is erased before the frame buffer is returned to |
245 // the screen capturer. | 245 // the screen capturer. |
246 frame_.reset(); | 246 frame_.reset(); |
247 VerifyFrame(*frame, MouseCursorMonitor::OUTSIDE, DesktopVector()); | 247 VerifyFrame(*frame, MouseCursorMonitor::OUTSIDE, DesktopVector()); |
248 } | 248 } |
249 } | 249 } |
250 | 250 |
251 } // namespace | 251 } // namespace |
252 | 252 |
253 } // namespace webrtc | 253 } // namespace webrtc |
OLD | NEW |