Tests / test (push) Canceled after 0s
Build Android (FCM) / build-android-fcm (push) Canceled after 0s
Build Android / build-android (push) Canceled after 0s
Build iOS / build-ios (push) Canceled after 0s
Build Linux / build-linux (push) Canceled after 0s
Build macOS / build-macos (push) Canceled after 0s
Build Windows / build-windows (push) Canceled after 0s
Native crypto / native-crypto (push) Canceled after 0s
Release (main) / android (oneme) (push) Canceled after 0s
Release (main) / android (qlyra) (push) Canceled after 0s
Release (main) / windows (push) Canceled after 0s
Release (main) / linux (push) Canceled after 0s
Release (main) / macos (push) Canceled after 0s
Release (main) / ios (push) Canceled after 0s
Release (main) / release (push) Canceled after 0s
66 lines
2.0 KiB
Dart
66 lines
2.0 KiB
Dart
import 'dart:async';
|
|
import 'dart:io';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:flutter_webrtc/flutter_webrtc.dart';
|
|
import 'package:ikar/core/calls/call_session.dart';
|
|
import 'package:ikar/core/calls/ws2_signaling.dart';
|
|
|
|
final config = Ws2Config(
|
|
userId: 1,
|
|
uri: Uri(scheme: 'wss', host: 'calls.invalid'),
|
|
);
|
|
|
|
class BrokenSignaling extends Ws2Signaling {
|
|
BrokenSignaling() : super(config);
|
|
int sent = 0;
|
|
@override
|
|
Future<void> transmitCandidate({
|
|
required int participantId,
|
|
required String candidate,
|
|
required String sdpMid,
|
|
required int sdpMLineIndex,
|
|
String participantType = 'USER',
|
|
int deviceIdx = 0,
|
|
}) async {
|
|
sent++;
|
|
throw const SocketException('mobile network disconnected');
|
|
}
|
|
|
|
@override
|
|
Future<void> hangup({String reason = 'HUNGUP'}) async {}
|
|
@override
|
|
Future<void> close() async {}
|
|
}
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
test(
|
|
'ICE send failure is handled and late candidates are ignored after hangup',
|
|
() async {
|
|
final signaling = BrokenSignaling();
|
|
final session = CallSession(ws2Config: config, role: CallRole.caller);
|
|
session.bindCandidateSignalingForTesting(signaling, 2);
|
|
final errors = <Object>[];
|
|
runZonedGuarded(() {
|
|
session.receiveLocalCandidateForTesting(
|
|
RTCIceCandidate('candidate:mobile', '0', 0),
|
|
);
|
|
}, (error, stack) => errors.add(error));
|
|
await Future<void>.delayed(Duration.zero);
|
|
final reconnecting = session.isReconnecting;
|
|
await session.hangup();
|
|
runZonedGuarded(() {
|
|
session.receiveLocalCandidateForTesting(
|
|
RTCIceCandidate('candidate:late', '0', 0),
|
|
);
|
|
}, (error, stack) => errors.add(error));
|
|
await Future<void>.delayed(Duration.zero);
|
|
expect(reconnecting, isTrue);
|
|
expect(signaling.sent, 1);
|
|
expect(errors, isEmpty);
|
|
expect(session.currentState, CallSessionState.ended);
|
|
await Future<void>.delayed(const Duration(milliseconds: 1100));
|
|
},
|
|
);
|
|
}
|