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);
|
||||
});
|
||||
}
|
||||
@@ -238,6 +238,11 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_driver:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@@ -296,6 +301,11 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
fuchsia_remote_debug_protocol:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
hooks:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -328,6 +338,11 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.1.2"
|
||||
integration_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
jni:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -544,6 +559,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.8"
|
||||
process:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: process
|
||||
sha256: "4242ba3508d37e01808bdf71ad1d5bb93a8d671bf2e7450e6b1b353fb0808891"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.6"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -669,6 +692,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.1"
|
||||
sync_http:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sync_http
|
||||
sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.1"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -853,6 +884,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
webdriver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webdriver
|
||||
sha256: "28b82ec894fed45dd71c23ba62d1af973ed97dd59a4f5790a4d38b0b13e5657e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.0"
|
||||
webview_flutter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
@@ -52,6 +52,8 @@ dependencies:
|
||||
bonsoir: ^7.1.5
|
||||
|
||||
dev_dependencies:
|
||||
integration_test:
|
||||
sdk: flutter
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
|
||||
@@ -308,8 +308,10 @@ def build_apk_native(app, cache, flutter, sdk, arguments, runner=subprocess.run,
|
||||
code = built // 60
|
||||
signing = signing_dir()
|
||||
env = {**os.environ, "ANDROID_HOME": sdk, "ANDROID_SDK_ROOT": sdk,
|
||||
# The Android Gradle plugin reads debug.keystore from the user home it is given.
|
||||
"ANDROID_USER_HOME": str(signing), "ANDROID_SDK_HOME": str(signing)}
|
||||
# The Android Gradle plugin reads debug.keystore from this user home.
|
||||
# ANDROID_SDK_HOME must not also be set: AGP rejects conflicting homes.
|
||||
"ANDROID_USER_HOME": str(signing)}
|
||||
env.pop("ANDROID_SDK_HOME", None)
|
||||
command = [flutter, "build", "apk", "--release", *arguments,
|
||||
f"--build-number={code}", f"--build-name=0.1.{code}"]
|
||||
result = runner(command, cwd=str(app), env=env, capture_output=True, text=True)
|
||||
|
||||
Reference in New Issue
Block a user