using ::testing::AtLeast;
using ::testing::InvokeWithoutArgs;
using ::testing::Return;
+using ::testing::SaveArg;
using media::MockVideoCaptureEventHandler;
namespace content {
DeviceReceiveEmptyBuffer)
IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceSupportedFormats,
DeviceGetSupportedFormats)
+ IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceFormatsInUse,
+ DeviceGetFormatsInUse)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
EXPECT_TRUE(handled);
OnDeviceSupportedFormatsEnumerated(
media::VideoCaptureFormats());
}
+
+ void DeviceGetFormatsInUse(int device_id,
+ media::VideoCaptureSessionId session_id) {
+ OnDeviceFormatsInUseReceived(media::VideoCaptureFormats());
+ }
};
VideoCaptureImplTest() {
run_loop_.Run();
}
+// Check that a request to GetDeviceFormatsInUse() ends up eventually in the
+// provided callback.
+TEST_F(VideoCaptureImplTest, GetDeviceFormatsInUse) {
+ scoped_ptr<MockVideoCaptureEventHandler> client(
+ new MockVideoCaptureEventHandler);
+
+ media::VideoCaptureFormats formats_in_use;
+ EXPECT_CALL(*client, OnDeviceFormatsInUseReceived(_))
+ .WillOnce(SaveArg<0>(&formats_in_use));
+
+ const base::Callback<void(const media::VideoCaptureFormats&)> callback =
+ base::Bind(&MockVideoCaptureEventHandler::OnDeviceFormatsInUseReceived,
+ base::Unretained(client.get()));
+ video_capture_impl_->GetDeviceFormatsInUse(callback);
+ video_capture_impl_->DeInit(
+ media::BindToCurrentLoop(run_loop_.QuitClosure()));
+ run_loop_.Run();
+
+ EXPECT_TRUE(formats_in_use.empty());
+}
+
} // namespace content