1d7108c9d0
- Updated autogenerated files to reflect changes from Pigeon v26.3.4. - Added new classes for UniversalBlePeripheralConfig, UniversalBlePeripheralService, UniversalBlePeripheralCharacteristic, UniversalBlePeripheralDescriptor, and UniversalBlePeripheralWriteEvent to handle peripheral configurations and events. - Modified UniversalBlePlugin to implement methods for peripheral support, including StartPeripheral, StopPeripheral, UpdatePeripheralCharacteristicValue, and NotifyPeripheralCharacteristic, returning appropriate error messages for unsupported features on Windows. - Updated HasPermissions method to include an additional parameter for Bluetooth advertising permissions. - Adjusted method signatures and implementations across the plugin to accommodate new peripheral functionality. Signed-off-by: Tony <tonylu@tony-cloud.com>
46 lines
1.3 KiB
Dart
46 lines
1.3 KiB
Dart
import 'dart:typed_data';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:universal_ble/universal_ble.dart';
|
|
|
|
void main() {
|
|
group('BlePeripheral models', () {
|
|
test('normalizes UUIDs and defensively copies characteristic values', () {
|
|
final initialValue = Uint8List.fromList([1, 2, 3]);
|
|
|
|
final characteristic = BlePeripheralCharacteristic(
|
|
uuid: 'fff1',
|
|
properties: const [CharacteristicProperty.read],
|
|
permissions: const [BlePeripheralCharacteristicPermission.read],
|
|
initialValue: initialValue,
|
|
);
|
|
|
|
initialValue[0] = 9;
|
|
|
|
expect(
|
|
BleUuidParser.compareStrings(characteristic.uuid, '0000fff1-0000-1000-8000-00805f9b34fb'),
|
|
isTrue,
|
|
);
|
|
expect(characteristic.initialValue, [1, 2, 3]);
|
|
});
|
|
|
|
test('normalizes write event UUIDs and defensively copies payloads', () {
|
|
final value = Uint8List.fromList([4, 5, 6]);
|
|
|
|
final event = BlePeripheralWriteEvent(
|
|
deviceId: 'client-1',
|
|
service: 'fff0',
|
|
characteristic: 'fff1',
|
|
value: value,
|
|
);
|
|
|
|
value[0] = 8;
|
|
|
|
expect(event.deviceId, 'client-1');
|
|
expect(BleUuidParser.compareStrings(event.service, 'fff0'), isTrue);
|
|
expect(BleUuidParser.compareStrings(event.characteristic, 'fff1'), isTrue);
|
|
expect(event.value, [4, 5, 6]);
|
|
});
|
|
});
|
|
}
|