public void S3_EUSB_OperateIo_GetCurrentFrameNumber()
{
LogComment("S3_EUSB_OperateIo_GetCurrentFrameNumber");
LogComment("1. Creates the control virtual channel, exchanges capabilities then notifies that the channel is created.");
context.ControlChannel = CreateVirtualChannel();
LogComment("2. Receives an add virtual channel request.");
rdpeusbAdapter.ExpectAddVirtualChannel(context.ControlChannel);
LogComment("3. Creates a new virtual channel for the device.");
DynamicVirtualChannel channel = CreateVirtualChannel();
LogComment("4. Receives an add device request.");
EusbDeviceContext device = rdpeusbAdapter.ExpectAddDevice(channel);
LogComment("5. Registers a callback to provide the Request Completion Interface to the client.");
uint interfaceId = IdGenerator.NewId();
rdpeusbAdapter.RegisterCallback(device, 1, interfaceId);
LogComment("6. Sends TS_URB_GET_CURRENT_FRAME_NUMBER request.");
const uint frameNumberSize = 0;
uint requestId = IdGenerator.NewId();
TS_URB_GET_CURRENT_FRAME_NUMBER req = new TS_URB_GET_CURRENT_FRAME_NUMBER(
requestId,
0);
rdpeusbAdapter.TransferInRequest(device, req, frameNumberSize);
LogComment("7. Receives TS_URB_GET_CURRENT_FRAME_NUMBER_RESULT in the URB_COMPLETION_NO_DATA message.");
// Waits for the result.
EusbPdu pdu = rdpeusbAdapter.ExpectCompletion(device.VirtualChannel);
Site.Assert.IsInstanceOfType(
pdu,
typeof(EusbUrbCompletionNoDataPdu),
"The result must be type of EusbUrbCompletionNoDataPdu.");
EusbUrbCompletionNoDataPdu pduRes = (EusbUrbCompletionNoDataPdu)pdu;
Site.Assert.IsSuccess((int)pduRes.HResult, "The EusbUrbCompletionNoDataPdu must indicate successful.");
ReqCapturer.VerifyUrbCompletionNoData(pduRes, req, true, interfaceId);
TS_URB_GET_CURRENT_FRAME_NUMBER_RESULT res = new TS_URB_GET_CURRENT_FRAME_NUMBER_RESULT();
Site.Assert.IsTrue(
PduMarshaler.Unmarshal(pduRes.TsUrbResult, res),
"The TS_URB_GET_CURRENT_FRAME_NUMBER_RESULT structure is sent via the URB_COMPLETION_NO_DATA message"
);
LogComment("The current frame number is {0}(0x{0:x4}).", res.FrameNumber);
LogComment("8. Sends retract device request and the channel for the device is expected to be closed.");
rdpeusbAdapter.RetractDevice(device, USB_RETRACT_REASON.UsbRetractReason_BlockedByPolicy);
}