fix(client): 补提交 stats-overhaul 漏掉的 account_api/kernel_process WIP
同 device_usage:account_api.dart(deviceUsage/usage 方法)、kernel_process.dart 及对应测试一直未提交,本地有→analyze/test 过,但不在 git→Windows 构建报 「deviceUsage isn't defined」。补齐使提交树自洽可构建。 孤儿组件 device_stat_row/metric_card 已无人引用,不提交。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -240,6 +240,53 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
// ── URLTest 延迟/组名提取 ─────────────────────────────────────
|
||||
group('URLTest extraction', () {
|
||||
final proxies = <String, dynamic>{
|
||||
'proxies': {
|
||||
'auto': {
|
||||
'type': 'URLTest',
|
||||
'all': ['reality-out', 'hy2-out'],
|
||||
},
|
||||
'reality-out': {
|
||||
'type': 'Vless',
|
||||
'history': [
|
||||
{'time': 't1', 'delay': 30},
|
||||
{'time': 't2', 'delay': 42},
|
||||
],
|
||||
},
|
||||
'hy2-out': {
|
||||
'type': 'Hysteria2',
|
||||
'history': [
|
||||
{'time': 't1', 'delay': 88},
|
||||
],
|
||||
},
|
||||
'direct': {'type': 'Direct'},
|
||||
},
|
||||
};
|
||||
|
||||
test('extractUrltestGroups 返回 URLTest/Fallback 组名', () {
|
||||
expect(ClashApiClient.extractUrltestGroups(proxies), ['auto']);
|
||||
});
|
||||
|
||||
test('extractUrltestResults 取成员最新 history delay', () {
|
||||
final r = ClashApiClient.extractUrltestResults(proxies);
|
||||
final byTag = {for (final e in r) e.tag: e.delayMs};
|
||||
expect(byTag['reality-out'], 42); // history.last
|
||||
expect(byTag['hy2-out'], 88);
|
||||
});
|
||||
|
||||
test('无 URLTest 组时返回空', () {
|
||||
final empty = {
|
||||
'proxies': {
|
||||
'direct': {'type': 'Direct'},
|
||||
},
|
||||
};
|
||||
expect(ClashApiClient.extractUrltestGroups(empty), isEmpty);
|
||||
expect(ClashApiClient.extractUrltestResults(empty), isEmpty);
|
||||
});
|
||||
});
|
||||
|
||||
// ── 2. 随机生成工具函数 ───────────────────────────────────────
|
||||
group('Port and secret generators', () {
|
||||
test('generateClashApiPort is in range 49152–65535', () {
|
||||
|
||||
Reference in New Issue
Block a user