You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
2.1 KiB
52 lines
2.1 KiB
import 'package:device_plugin_interface/device_plugin_interface.dart';
|
|
import 'package:eaimar/devices/bes/bes_device_plugin.dart';
|
|
import 'package:eaimar/devices/bes/bes_protocol.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
/// feature key → 发给恒玄耳机的字节,**冻结**。
|
|
///
|
|
/// 业务层只认 feature key,这张表是它与线上固件之间唯一的翻译;改一个字节
|
|
/// 等于改协议。表里的每一条都对应已量产固件的真实行为。
|
|
void main() {
|
|
test('通用 feature 到字节的映射逐条固定', () {
|
|
const expected = <String, List<int>>{
|
|
DeviceFeatures.recordStart: [0xAA, 0x59],
|
|
DeviceFeatures.recordStop: [0xAA, 0x5A],
|
|
DeviceFeatures.callStart: [0xAA, 0x51],
|
|
DeviceFeatures.callStop: [0xAA, 0x52],
|
|
DeviceFeatures.callQuery: [0xAA, 0x0E],
|
|
DeviceFeatures.asrStarted: [0xAA, 0x57],
|
|
DeviceFeatures.asrStopped: [0xAA, 0x58],
|
|
DeviceFeatures.aiAccept: [0xAA, 0x6A],
|
|
DeviceFeatures.aiExit: [0xAA, 0x65],
|
|
DeviceFeatures.f2fStart: [0xAA, 0x66],
|
|
DeviceFeatures.f2fStop: [0xAA, 0x67],
|
|
DeviceFeatures.batteryQuery: [0xAA, 0x09],
|
|
'bes.firmware.query': [0xAA, 0x06],
|
|
};
|
|
for (final e in expected.entries) {
|
|
final cmd = BesDeviceSession.featureCommands[e.key];
|
|
expect(cmd, isNotNull, reason: '${e.key} 没有映射');
|
|
expect(BesCmd.frame(cmd!), e.value, reason: e.key);
|
|
}
|
|
expect(BesDeviceSession.featureCommands.length, expected.length,
|
|
reason: '多出来的映射也要在这里登记');
|
|
});
|
|
|
|
test('恒玄会话声明的能力集:只增不删', () {
|
|
const must = {
|
|
DeviceCapability.battery,
|
|
DeviceCapability.macAddress,
|
|
DeviceCapability.micUplink,
|
|
DeviceCapability.speakerDownlink,
|
|
DeviceCapability.micRecording,
|
|
DeviceCapability.callAudioTap,
|
|
DeviceCapability.callState,
|
|
DeviceCapability.aiWake,
|
|
DeviceCapability.translationDownlink,
|
|
DeviceCapability.faceToFace,
|
|
DeviceCapability.ota,
|
|
};
|
|
expect(BesDeviceSession.caps.containsAll(must), isTrue);
|
|
});
|
|
}
|
|
|