@Test
public void testOnCharacteristicWriteNextChunk() throws IOException {
when(gatt.getService(eq(serviceUUID))).thenReturn(gattService);
when(gattService.getCharacteristic(characteristicUUID)).thenReturn(gattCharacteristic);
when(gatt.writeCharacteristic(eq(gattCharacteristic))).thenReturn(true);
InputSource inputSource = Mockito.mock(InputSource.class);
when(inputSource.nextChunk()).thenReturn(new byte[]{12, 21});
writeCommand = new WriteCommand(
serviceUUID,
characteristicUUID,
BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT,
inputSource,
commandObserver);
writeCommand.execute(device, operationCommandObserver, gatt);
writeCommand.onCharacteristicWrite(gatt, gattCharacteristic, BluetoothGatt.GATT_SUCCESS);
verify(commandObserver, times(0)).finished(any(Command.class), any(CommandResult.class));
verify(operationCommandObserver, times(0)).finished(any(Command.class), any(CommandResult.class));
}
WriteCommandTest.java 文件源码
java
阅读 35
收藏 0
点赞 0
评论 0
项目:neatle
作者:
评论列表
文章目录