feat: M2.1 客户端骨架、BLE 修复、仓库整理与现状板
- BLE: 修复 BlueZ LocalName 与 Includes 冲突,串行注册与退避 - HTTP: 语音对话补 Live2D talking 标志与 session;Web 补 X-Session-Id - Flutter: 角色/对话/模型页 + API,Gradle/依赖升级,麦克风权限 - 文档: 新增 docs/STATUS.md,校准 CLAUDE/PROGRESS/README - 清理: 移除根目录截图与临时模型,运维脚本迁入 scripts/device
This commit is contained in:
90
clients/flutter/test/models/m2_models_test.dart
Normal file
90
clients/flutter/test/models/m2_models_test.dart
Normal file
@@ -0,0 +1,90 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:showen_v2_flutter/models/ai_model.dart';
|
||||
import 'package:showen_v2_flutter/models/character_pack.dart';
|
||||
import 'package:showen_v2_flutter/models/chat_models.dart';
|
||||
|
||||
void main() {
|
||||
group('CharacterPack / AvailableConfigs', () {
|
||||
test('parses M2.1 config available payload', () {
|
||||
final snapshot = AvailableConfigs.fromJson({
|
||||
'active': 'dog_state_machine.json',
|
||||
'configs': [
|
||||
{
|
||||
'filename': 'dog_state_machine.json',
|
||||
'character': {
|
||||
'name': '小狗',
|
||||
'character_type': 'pet',
|
||||
'render_type': 'video',
|
||||
},
|
||||
},
|
||||
{
|
||||
'filename': 'live2d_demo.json',
|
||||
'character': {
|
||||
'name': 'Live2D',
|
||||
'character_type': 'live2d',
|
||||
'render_type': 'live2d',
|
||||
'live2d_model': 'Hiyori',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(snapshot.active, 'dog_state_machine.json');
|
||||
expect(snapshot.configs, hasLength(2));
|
||||
expect(snapshot.configs.first.name, '小狗');
|
||||
expect(snapshot.configs.first.typeLabel, '宠物');
|
||||
expect(snapshot.configs.last.isLive2d, isTrue);
|
||||
});
|
||||
});
|
||||
|
||||
group('ChatTurnResponse', () {
|
||||
test('parses success and error responses', () {
|
||||
final ok = ChatTurnResponse.fromJson({
|
||||
'session_id': 'app_1',
|
||||
'transcription': '你好',
|
||||
'reply_text': '汪!',
|
||||
'reply_audio_path': '/tmp/tts.wav',
|
||||
'error': null,
|
||||
});
|
||||
expect(ok.isOk, isTrue);
|
||||
expect(ok.replyText, '汪!');
|
||||
expect(ok.replyAudioPath, '/tmp/tts.wav');
|
||||
|
||||
final err = ChatTurnResponse.fromJson({
|
||||
'session_id': '',
|
||||
'reply_text': '',
|
||||
'error': 'AI 插件未就绪',
|
||||
});
|
||||
expect(err.isOk, isFalse);
|
||||
expect(err.error, 'AI 插件未就绪');
|
||||
});
|
||||
});
|
||||
|
||||
group('ModelsSnapshot', () {
|
||||
test('parses model list and active map', () {
|
||||
final snapshot = ModelsSnapshot.fromJson({
|
||||
'models': [
|
||||
{
|
||||
'id': 'qwen2.5-0.5b-q4_k_m',
|
||||
'kind': 'llm',
|
||||
'name': 'Qwen2.5 0.5B',
|
||||
'version': '1',
|
||||
'size': 400000000,
|
||||
'memory_required': 1000000000,
|
||||
'recommended_tier': '4G',
|
||||
'downloaded': true,
|
||||
'download_progress': 100,
|
||||
},
|
||||
],
|
||||
'active': {'llm': 'qwen2.5-0.5b-q4_k_m', 'asr': 'whisper-tiny'},
|
||||
'used_space': 500000000,
|
||||
'quota': 4000000000,
|
||||
});
|
||||
|
||||
expect(snapshot.models, hasLength(1));
|
||||
expect(snapshot.isActive(snapshot.models.first), isTrue);
|
||||
expect(snapshot.usageRatio, closeTo(0.125, 0.001));
|
||||
expect(snapshot.models.first.kindLabel, 'LLM');
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user