SDK: - Add build_config/migrate_config, mesh_cidrs, route_generation, health and start_bridged; expose abi_info (capability revision 2). - Add wait_routes long-poll; stop wakes waiters, and context_free now stops the network immediately instead of waiting for waiters to time out. Hosts: - Dart: waitRoutes(), MeshProxySession route watcher, ABI capability check. - Android: fix a deadlock where every VPN request waited on its own single-thread worker; requests are now async, status is served from a snapshot, and combined mode reports Partial when the mesh stops. - macOS helper: mesh-only unified mode stops when the mesh is lost; installed_subnet_routes excludes the overlay. - Lab: restore Partial sessions, write migrated profiles back, remove the unreachable TOML import dialog; native test now connects via the form. Docs updated accordingly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
95 lines
3.2 KiB
Dart
95 lines
3.2 KiB
Dart
import 'dart:io';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:meshport_client_core/meshport_client_core.dart';
|
|
import 'package:meshport_flutter/meshport_flutter.dart';
|
|
import 'package:meshport_lab/features/configuration_pages.dart';
|
|
|
|
void main() {
|
|
testWidgets('DNS saves FakeIP draft and keeps mesh exclusions', (
|
|
tester,
|
|
) async {
|
|
final p = ProxyProfile()
|
|
..meshDns = [
|
|
{'suffix': 'mesh.test', 'server': '10.77.0.2'},
|
|
];
|
|
bool changed = false;
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: DnsPage(profile: p, changed: () => changed = true),
|
|
),
|
|
);
|
|
await tester.tap(find.text('FakeIP'));
|
|
await tester.pumpAndSettle();
|
|
expect(p.fakeIP, isFalse);
|
|
await tester.tap(find.text('保存草稿'));
|
|
await tester.pumpAndSettle();
|
|
expect(p.fakeIP, isTrue);
|
|
expect(changed, isTrue);
|
|
expect(p.runtime()['mesh_dns'], isNotEmpty);
|
|
p.feature = 'proxy';
|
|
expect(p.runtime()['mesh_dns'], isEmpty);
|
|
});
|
|
testWidgets('P2P disable pauses punching without losing values', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: NetworkConfigPage(
|
|
section: '连接与打洞',
|
|
initial: {
|
|
'flags': {'disable_p2p': true, 'disable_udp_hole_punching': true},
|
|
},
|
|
save: (_) async {},
|
|
),
|
|
),
|
|
);
|
|
final switches = tester
|
|
.widgetList<SwitchListTile>(find.byType(SwitchListTile))
|
|
.toList();
|
|
expect(switches[1].onChanged, isNull);
|
|
expect(switches[1].value, isTrue);
|
|
await tester.tap(find.text('禁用 P2P'));
|
|
await tester.pumpAndSettle();
|
|
final next = tester
|
|
.widgetList<SwitchListTile>(find.byType(SwitchListTile))
|
|
.toList();
|
|
expect(next[1].onChanged, isNotNull);
|
|
expect(next[1].value, isTrue);
|
|
});
|
|
testWidgets('rule editor rejects wildcard domains', (tester) async {
|
|
await tester.pumpWidget(const MaterialApp(home: RuleEditor()));
|
|
await tester.enterText(find.byType(TextField), '*.example.com');
|
|
await tester.tap(find.text('保存规则'));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('请输入有效域名或 CIDR,不接受星号语法'), findsOneWidget);
|
|
});
|
|
final library = Platform.environment['MESHPORT_LIBRARY'];
|
|
test(
|
|
'network draft preserves supported options and forces encrypted single-stack host',
|
|
() async {
|
|
final draft = NetworkProfile({
|
|
'runtime_mode': 'unified_vpn',
|
|
'ipv4': '10.77.0.11/24',
|
|
'network_name': 'test',
|
|
'network_secret': 'test-only',
|
|
'flags': {'disable_p2p': true},
|
|
'listeners': ['udp://0.0.0.0:11010'],
|
|
'stun_servers': [],
|
|
'optimization': {'mode': 'direct'},
|
|
});
|
|
final client = await MeshPortClient.open(libraryPath: library);
|
|
try {
|
|
final toml = await draft.toToml(client);
|
|
expect(toml, contains('no_tun = true'));
|
|
expect(toml, contains('disable_p2p = true'));
|
|
expect(toml, contains('enable_encryption = true'));
|
|
expect(toml, contains('stun_servers = []'));
|
|
} finally {
|
|
await client.close();
|
|
}
|
|
},
|
|
skip: library == null ? 'Requires native Rust library' : false,
|
|
);
|
|
}
|