Fix native APK homes; add a native discovery probe
The native APK build no longer sets ANDROID_SDK_HOME beside ANDROID_USER_HOME (AGP rejects the conflict). integration_test/ discovery_probe_test.dart runs the real Bonsoir discovery on a desktop host and prints what the platform delivers.
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
// Runs the app's real native discovery on this machine and prints what the
|
||||
// platform reports, so a server that the OS sees but the app does not can be
|
||||
// explained. Run from app/:
|
||||
// flutter test integration_test/discovery_probe_test.dart -d macos
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:bonsoir/bonsoir.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
import 'package:pipelines_app/features/onboarding/discovery/bonsoir_server_discovery.dart';
|
||||
import 'package:pipelines_app/features/onboarding/discovery/discovered_server.dart';
|
||||
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
testWidgets('native discovery reports what the platform delivers', (
|
||||
tester,
|
||||
) async {
|
||||
final raw = BonsoirDiscovery(type: pipelinesServiceType, printLogs: true);
|
||||
await raw.initialize();
|
||||
final events = <String>[];
|
||||
final sub = raw.eventStream!.listen((event) {
|
||||
final s = switch (event) {
|
||||
BonsoirDiscoveryServiceFoundEvent(:final service) => 'found ${service?.name}',
|
||||
BonsoirDiscoveryServiceResolvedEvent(:final service) =>
|
||||
'resolved ${service?.name} host=${service?.hostname} addrs=${service?.hostAddresses} port=${service?.port} txt=${service?.attributes}',
|
||||
BonsoirDiscoveryServiceResolveFailedEvent(:final service) =>
|
||||
'RESOLVE FAILED ${service?.name}',
|
||||
BonsoirDiscoveryServiceLostEvent(:final service) => 'lost ${service?.name}',
|
||||
_ => 'event ${event.runtimeType}',
|
||||
};
|
||||
events.add(s);
|
||||
// ignore: avoid_print
|
||||
print('[raw] $s');
|
||||
if (event is BonsoirDiscoveryServiceFoundEvent) {
|
||||
unawaited(event.service?.resolve(raw.serviceResolver));
|
||||
}
|
||||
}, onError: (Object e) {
|
||||
events.add('ERROR $e');
|
||||
// ignore: avoid_print
|
||||
print('[raw] ERROR $e');
|
||||
});
|
||||
await raw.start();
|
||||
await Future<void>.delayed(const Duration(seconds: 8));
|
||||
await sub.cancel();
|
||||
await raw.stop();
|
||||
|
||||
// ignore: avoid_print
|
||||
print('--- app layer');
|
||||
final seen = <List<DiscoveredServer>>[];
|
||||
final appSub = BonsoirServerDiscovery().scan().listen(
|
||||
seen.add,
|
||||
onError: (Object e) => print('[app] ERROR $e'), // ignore: avoid_print
|
||||
);
|
||||
await Future<void>.delayed(const Duration(seconds: 8));
|
||||
await appSub.cancel();
|
||||
for (final list in seen) {
|
||||
// ignore: avoid_print
|
||||
print('[app] ${list.map((s) => '${s.name} ${s.endpoints}').join(' | ')}');
|
||||
}
|
||||
// ignore: avoid_print
|
||||
print('RAW_EVENTS=${events.length} APP_LAST=${seen.isEmpty ? 'none' : seen.last.map((s) => s.name).toList()}');
|
||||
expect(events, isNotEmpty);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user