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

Side by Side Diff: content/renderer/media/media_stream_video_capture_source_unittest.cc

Issue 263323003: Revert of Refactor video capturing code in the render process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/renderer/media/media_stream_video_capturer_source.h" 7 #include "content/renderer/media/media_stream_video_capturer_source.h"
8 #include "content/renderer/media/media_stream_video_track.h" 8 #include "content/renderer/media/media_stream_video_track.h"
9 #include "content/renderer/media/mock_media_constraint_factory.h" 9 #include "content/renderer/media/mock_media_constraint_factory.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 class MockVideoCapturerDelegate : public VideoCapturerDelegate { 15 class MockVideoCapturerDelegate : public VideoCapturerDelegate {
16 public: 16 public:
17 explicit MockVideoCapturerDelegate(const StreamDeviceInfo& device_info) 17 explicit MockVideoCapturerDelegate(const StreamDeviceInfo& device_info)
18 : VideoCapturerDelegate(device_info) {} 18 : VideoCapturerDelegate(device_info) {}
19 19
20 MOCK_METHOD3(StartCapture, 20 MOCK_METHOD3(StartDeliver,
21 void(const media::VideoCaptureParams& params, 21 void(const media::VideoCaptureParams& params,
22 const VideoCaptureDeliverFrameCB& new_frame_callback, 22 const NewFrameCallback& new_frame_callback,
23 const StartedCallback& started_callback)); 23 const StartedCallback& started_callback));
24 MOCK_METHOD0(StopCapture,void()); 24 MOCK_METHOD0(StopDeliver,void());
25 25
26 private: 26 private:
27 virtual ~MockVideoCapturerDelegate() {} 27 virtual ~MockVideoCapturerDelegate() {}
28 }; 28 };
29 29
30 class MediaStreamVideoCapturerSourceTest : public testing::Test { 30 class MediaStreamVideoCapturerSourceTest : public testing::Test {
31 public: 31 public:
32 void InitWithDeviceInfo(const StreamDeviceInfo& device_info) { 32 void InitWithDeviceInfo(const StreamDeviceInfo& device_info) {
33 delegate_ = new MockVideoCapturerDelegate(device_info); 33 delegate_ = new MockVideoCapturerDelegate(device_info);
34 source_ = new MediaStreamVideoCapturerSource( 34 source_ = new MediaStreamVideoCapturerSource(
(...skipping 26 matching lines...) Expand all
61 blink::WebMediaStreamSource webkit_source_; 61 blink::WebMediaStreamSource webkit_source_;
62 MediaStreamVideoCapturerSource* source_; // owned by webkit_source. 62 MediaStreamVideoCapturerSource* source_; // owned by webkit_source.
63 scoped_refptr<MockVideoCapturerDelegate> delegate_; 63 scoped_refptr<MockVideoCapturerDelegate> delegate_;
64 }; 64 };
65 65
66 TEST_F(MediaStreamVideoCapturerSourceTest, TabCaptureAllowResolutionChange) { 66 TEST_F(MediaStreamVideoCapturerSourceTest, TabCaptureAllowResolutionChange) {
67 StreamDeviceInfo device_info; 67 StreamDeviceInfo device_info;
68 device_info.device.type = MEDIA_TAB_VIDEO_CAPTURE; 68 device_info.device.type = MEDIA_TAB_VIDEO_CAPTURE;
69 InitWithDeviceInfo(device_info); 69 InitWithDeviceInfo(device_info);
70 70
71 EXPECT_CALL(*delegate_, StartCapture( 71 EXPECT_CALL(*delegate_, StartDeliver(
72 testing::Field(&media::VideoCaptureParams::allow_resolution_change, true), 72 testing::Field(&media::VideoCaptureParams::allow_resolution_change, true),
73 testing::_, 73 testing::_,
74 testing::_)).Times(1); 74 testing::_)).Times(1);
75 blink::WebMediaStreamTrack track = StartSource(); 75 blink::WebMediaStreamTrack track = StartSource();
76 // When the track goes out of scope, the source will be stopped. 76 // When the track goes out of scope, the source will be stopped.
77 EXPECT_CALL(*delegate_, StopCapture()); 77 EXPECT_CALL(*delegate_, StopDeliver());
78 } 78 }
79 79
80 TEST_F(MediaStreamVideoCapturerSourceTest, 80 TEST_F(MediaStreamVideoCapturerSourceTest,
81 DesktopCaptureAllowResolutionChange) { 81 DesktopCaptureAllowResolutionChange) {
82 StreamDeviceInfo device_info; 82 StreamDeviceInfo device_info;
83 device_info.device.type = MEDIA_DESKTOP_VIDEO_CAPTURE; 83 device_info.device.type = MEDIA_DESKTOP_VIDEO_CAPTURE;
84 InitWithDeviceInfo(device_info); 84 InitWithDeviceInfo(device_info);
85 85
86 EXPECT_CALL(*delegate_, StartCapture( 86 EXPECT_CALL(*delegate_, StartDeliver(
87 testing::Field(&media::VideoCaptureParams::allow_resolution_change, true), 87 testing::Field(&media::VideoCaptureParams::allow_resolution_change, true),
88 testing::_, 88 testing::_,
89 testing::_)).Times(1); 89 testing::_)).Times(1);
90 blink::WebMediaStreamTrack track = StartSource(); 90 blink::WebMediaStreamTrack track = StartSource();
91 // When the track goes out of scope, the source will be stopped. 91 // When the track goes out of scope, the source will be stopped.
92 EXPECT_CALL(*delegate_, StopCapture()); 92 EXPECT_CALL(*delegate_, StopDeliver());
93 } 93 }
94 94
95 } // namespace content 95 } // namespace content
OLDNEW
« no previous file with comments | « content/common/media/video_capture.h ('k') | content/renderer/media/media_stream_video_capturer_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698