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

Unified Diff: services/video_capture/test/mock_device_unittest.cc

Issue 2818513003: [Mojo Video Capture] Adapt video_capture service to refactored video capture stack (Closed)
Patch Set: Fix compile errors Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/video_capture/test/mock_device_test.cc ('k') | services/video_capture/test/mock_receiver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/video_capture/test/mock_device_unittest.cc
diff --git a/services/video_capture/test/mock_device_unittest.cc b/services/video_capture/test/mock_device_unittest.cc
index b0f7d427d96dea081714a005cfd7246fb191b0ca..28a5f723631a00cef243f3abe64c6f7f4ba5b049 100644
--- a/services/video_capture/test/mock_device_unittest.cc
+++ b/services/video_capture/test/mock_device_unittest.cc
@@ -16,19 +16,10 @@ using MockVideoCaptureDeviceTest = MockDeviceTest;
// Tests that the service stops the capture device when the client closes the
// connection to the device proxy.
-TEST_F(MockVideoCaptureDeviceTest,
- DISABLED_DeviceIsStoppedWhenDiscardingDeviceProxy) {
+TEST_F(MockVideoCaptureDeviceTest, DeviceIsStoppedWhenDiscardingDeviceProxy) {
base::RunLoop wait_loop;
- // The mock device must hold on to the device client that is passed to it.
- std::unique_ptr<media::VideoCaptureDevice::Client> device_client;
- EXPECT_CALL(mock_device_, DoAllocateAndStart(_, _))
- .WillOnce(Invoke([&device_client](
- const media::VideoCaptureParams& params,
- std::unique_ptr<media::VideoCaptureDevice::Client>* client) {
- device_client.reset(client->release());
- }));
- EXPECT_CALL(mock_device_, StopAndDeAllocate())
+ EXPECT_CALL(mock_device_, DoStopAndDeAllocate())
.WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); }));
device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_));
@@ -39,19 +30,10 @@ TEST_F(MockVideoCaptureDeviceTest,
// Tests that the service stops the capture device when the client closes the
// connection to the client proxy it provided to the service.
-TEST_F(MockVideoCaptureDeviceTest,
- DISABLED_DeviceIsStoppedWhenDiscardingDeviceClient) {
+TEST_F(MockVideoCaptureDeviceTest, DeviceIsStoppedWhenDiscardingDeviceClient) {
base::RunLoop wait_loop;
- // The mock device must hold on to the device client that is passed to it.
- std::unique_ptr<media::VideoCaptureDevice::Client> device_client;
- EXPECT_CALL(mock_device_, DoAllocateAndStart(_, _))
- .WillOnce(Invoke([&device_client](
- const media::VideoCaptureParams& params,
- std::unique_ptr<media::VideoCaptureDevice::Client>* client) {
- device_client.reset(client->release());
- }));
- EXPECT_CALL(mock_device_, StopAndDeAllocate())
+ EXPECT_CALL(mock_device_, DoStopAndDeAllocate())
.WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); }));
device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_));
@@ -60,4 +42,43 @@ TEST_F(MockVideoCaptureDeviceTest,
wait_loop.Run();
}
+// Tests that a utilization reported to a video_capture.mojom.Device via
+// OnReceiverReportingUtilization() arrives at the corresponding
+// media::VideoCaptureDevice.
+TEST_F(MockVideoCaptureDeviceTest, ReceiverUtilizationIsForwardedToDevice) {
+ base::RunLoop run_loop;
+ const media::VideoCaptureFormat stub_frame_format(gfx::Size(320, 200), 25.0f,
+ media::PIXEL_FORMAT_I420);
+ const int arbitrary_rotation = 0;
+ const int arbitrary_frame_feedback_id = 654;
+ const double arbitrary_utilization = 0.12345;
+
+ EXPECT_CALL(*mock_receiver_, DoOnFrameReadyInBuffer(_, _, _, _))
+ .WillOnce(Invoke([this, &arbitrary_utilization](
+ int32_t buffer_id, int32_t frame_feedback_id,
+ mojom::ScopedAccessPermissionPtr*,
+ media::mojom::VideoFrameInfoPtr*) {
+ device_proxy_->OnReceiverReportingUtilization(frame_feedback_id,
+ arbitrary_utilization);
+ }));
+
+ EXPECT_CALL(mock_device_, OnUtilizationReport(arbitrary_frame_feedback_id,
+ arbitrary_utilization))
+ .Times(1);
+
+ device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_));
+ run_loop.RunUntilIdle();
+
+ // Simulate device sending a frame, which should trigger |mock_receiver|
+ // DoOnFrameReadyInBuffer() getting called.
+ base::RunLoop run_loop_2;
+ mock_device_.SendStubFrame(stub_frame_format, arbitrary_rotation,
+ arbitrary_frame_feedback_id);
+ run_loop_2.RunUntilIdle();
+
+ base::RunLoop run_loop_3;
+ mock_receiver_.reset();
+ run_loop_3.RunUntilIdle();
+}
+
} // namespace video_capture
« no previous file with comments | « services/video_capture/test/mock_device_test.cc ('k') | services/video_capture/test/mock_receiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698