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

Side by Side Diff: content/browser/renderer_host/media/video_capture_controller_unittest.cc

Issue 2738763002: [Mojo Video Capture] Introduce abstraction BuildableVideoCaptureDevice (Closed)
Patch Set: Incorporated suggestions from Patch Set 8 Created 3 years, 9 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 (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 "content/browser/renderer_host/media/video_capture_controller.h" 5 #include "content/browser/renderer_host/media/video_capture_controller.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 bool enable_auto_return_buffer_on_buffer_ready_ = true; 114 bool enable_auto_return_buffer_on_buffer_ready_ = true;
115 }; 115 };
116 116
117 class MockConsumerFeedbackObserver 117 class MockConsumerFeedbackObserver
118 : public media::VideoFrameConsumerFeedbackObserver { 118 : public media::VideoFrameConsumerFeedbackObserver {
119 public: 119 public:
120 MOCK_METHOD2(OnUtilizationReport, 120 MOCK_METHOD2(OnUtilizationReport,
121 void(int frame_feedback_id, double utilization)); 121 void(int frame_feedback_id, double utilization));
122 }; 122 };
123 123
124 class MockBuildableVideoCaptureDevice : public BuildableVideoCaptureDevice {
125 public:
126 void CreateAndStartDeviceAsync(
127 VideoCaptureController* controller,
128 const media::VideoCaptureParams& params,
129 BuildableVideoCaptureDevice::Callbacks* callbacks,
130 base::OnceClosure done_cb) override {}
131 void ReleaseDeviceAsync(VideoCaptureController* controller,
132 base::OnceClosure done_cb) override {}
133 bool IsDeviceAlive() const override { return false; }
134 void GetPhotoCapabilities(
135 media::VideoCaptureDevice::GetPhotoCapabilitiesCallback callback)
136 const override {}
137 void SetPhotoOptions(
138 media::mojom::PhotoSettingsPtr settings,
139 media::VideoCaptureDevice::SetPhotoOptionsCallback callback) override {}
140 void TakePhoto(
141 media::VideoCaptureDevice::TakePhotoCallback callback) override {}
142 void MaybeSuspendDevice() override {}
143 void ResumeDevice() override {}
144 void RequestRefreshFrame() override {}
145 void SetDesktopCaptureWindowIdAsync(gfx::NativeViewId window_id,
146 base::OnceClosure done_cb) override {}
147 };
148
124 // Test fixture for testing a unit consisting of an instance of 149 // Test fixture for testing a unit consisting of an instance of
125 // VideoCaptureController connected to an instance of VideoCaptureDeviceClient, 150 // VideoCaptureController connected to an instance of VideoCaptureDeviceClient,
126 // an instance of VideoCaptureBufferPoolImpl, as well as related threading glue 151 // an instance of VideoCaptureBufferPoolImpl, as well as related threading glue
127 // that replicates how it is used in production. 152 // that replicates how it is used in production.
128 class VideoCaptureControllerTest 153 class VideoCaptureControllerTest
129 : public testing::Test, 154 : public testing::Test,
130 public testing::WithParamInterface<media::VideoPixelFormat> { 155 public testing::WithParamInterface<media::VideoPixelFormat> {
131 public: 156 public:
132 VideoCaptureControllerTest() 157 VideoCaptureControllerTest()
133 : arbitrary_format_(gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420), 158 : arbitrary_format_(gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420),
134 arbitrary_route_id_(0x99), 159 arbitrary_route_id_(0x99),
135 arbitrary_session_id_(100) {} 160 arbitrary_session_id_(100) {}
136 ~VideoCaptureControllerTest() override {} 161 ~VideoCaptureControllerTest() override {}
137 162
138 protected: 163 protected:
139 static const int kPoolSize = 3; 164 static const int kPoolSize = 3;
140 165
141 void SetUp() override { 166 void SetUp() override {
142 controller_.reset(new VideoCaptureController()); 167 const std::string arbitrary_device_id = "arbitrary_device_id";
168 const MediaStreamType arbitrary_stream_type =
169 content::MEDIA_DEVICE_VIDEO_CAPTURE;
170 const media::VideoCaptureParams arbitrary_params;
171 auto buildable_device = base::MakeUnique<MockBuildableVideoCaptureDevice>();
172 controller_ = new VideoCaptureController(
173 arbitrary_device_id, arbitrary_stream_type, arbitrary_params,
174 std::move(buildable_device));
143 InitializeNewDeviceClientAndBufferPoolInstances(); 175 InitializeNewDeviceClientAndBufferPoolInstances();
144 auto consumer_feedback_observer = 176 auto consumer_feedback_observer =
145 base::MakeUnique<MockConsumerFeedbackObserver>(); 177 base::MakeUnique<MockConsumerFeedbackObserver>();
146 mock_consumer_feedback_observer_ = consumer_feedback_observer.get(); 178 mock_consumer_feedback_observer_ = consumer_feedback_observer.get();
147 controller_->SetConsumerFeedbackObserver( 179 controller_->SetConsumerFeedbackObserver(
148 std::move(consumer_feedback_observer)); 180 std::move(consumer_feedback_observer));
149 client_a_.reset( 181 client_a_.reset(
150 new MockVideoCaptureControllerEventHandler(controller_.get())); 182 new MockVideoCaptureControllerEventHandler(controller_.get()));
151 client_b_.reset( 183 client_b_.reset(
152 new MockVideoCaptureControllerEventHandler(controller_.get())); 184 new MockVideoCaptureControllerEventHandler(controller_.get()));
(...skipping 26 matching lines...) Expand all
179 media::VideoFrame::AllocationSize(stub_frame->format(), 211 media::VideoFrame::AllocationSize(stub_frame->format(),
180 stub_frame->coded_size()), 212 stub_frame->coded_size()),
181 format, rotation, base::TimeTicks(), base::TimeDelta(), 213 format, rotation, base::TimeTicks(), base::TimeDelta(),
182 frame_feedback_id); 214 frame_feedback_id);
183 } 215 }
184 216
185 TestBrowserThreadBundle bundle_; 217 TestBrowserThreadBundle bundle_;
186 scoped_refptr<media::VideoCaptureBufferPool> buffer_pool_; 218 scoped_refptr<media::VideoCaptureBufferPool> buffer_pool_;
187 std::unique_ptr<MockVideoCaptureControllerEventHandler> client_a_; 219 std::unique_ptr<MockVideoCaptureControllerEventHandler> client_a_;
188 std::unique_ptr<MockVideoCaptureControllerEventHandler> client_b_; 220 std::unique_ptr<MockVideoCaptureControllerEventHandler> client_b_;
189 std::unique_ptr<VideoCaptureController> controller_; 221 scoped_refptr<VideoCaptureController> controller_;
190 std::unique_ptr<media::VideoCaptureDevice::Client> device_client_; 222 std::unique_ptr<media::VideoCaptureDevice::Client> device_client_;
191 MockConsumerFeedbackObserver* mock_consumer_feedback_observer_; 223 MockConsumerFeedbackObserver* mock_consumer_feedback_observer_;
192 const float arbitrary_frame_rate_ = 10.0f; 224 const float arbitrary_frame_rate_ = 10.0f;
193 const base::TimeTicks arbitrary_reference_time_ = base::TimeTicks(); 225 const base::TimeTicks arbitrary_reference_time_ = base::TimeTicks();
194 const base::TimeDelta arbitrary_timestamp_ = base::TimeDelta(); 226 const base::TimeDelta arbitrary_timestamp_ = base::TimeDelta();
195 const media::VideoCaptureFormat arbitrary_format_; 227 const media::VideoCaptureFormat arbitrary_format_;
196 const VideoCaptureControllerID arbitrary_route_id_; 228 const VideoCaptureControllerID arbitrary_route_id_;
197 const media::VideoCaptureSessionId arbitrary_session_id_; 229 const media::VideoCaptureSessionId arbitrary_session_id_;
198 230
199 private: 231 private:
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 EXPECT_CALL(*client_b_, OnStarted(_)); 861 EXPECT_CALL(*client_b_, OnStarted(_));
830 device_client_->OnStarted(); 862 device_client_->OnStarted();
831 863
832 // VideoCaptureController will take care of the OnStarted event for the 864 // VideoCaptureController will take care of the OnStarted event for the
833 // clients who join later. 865 // clients who join later.
834 EXPECT_CALL(*client_a_, OnStarted(_)); 866 EXPECT_CALL(*client_a_, OnStarted(_));
835 controller_->AddClient(client_a_route_2, client_a_.get(), 200, session_200); 867 controller_->AddClient(client_a_route_2, client_a_.get(), 200, session_200);
836 } 868 }
837 } 869 }
838 } // namespace content 870 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698