Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tests for calls #1654

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions lib/src/voip/call.dart
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ class CallSession {
Logs().d(
'[glare] new call $callId needs to be canceled because the older one ${prevCall.callId} has a smaller lex');
await hangup();
voip.currentCID = prevCall.callId;
return;
} else {
Logs().d(
Expand Down Expand Up @@ -1690,8 +1691,6 @@ class CallSession {
String? txid,
CallCapabilities? capabilities,
SDPStreamMetadata? metadata}) async {
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';

final content = {
'call_id': callId,
'party_id': party_id,
Expand Down Expand Up @@ -1723,8 +1722,6 @@ class CallSession {
Future<String?> sendSelectCallAnswer(
Room room, String callId, String party_id, String selected_party_id,
{String version = voipProtoVersion, String? txid}) async {
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';

final content = {
'call_id': callId,
'party_id': party_id,
Expand All @@ -1748,8 +1745,6 @@ class CallSession {
Future<String?> sendCallReject(
Room room, String callId, String party_id, String? reason,
{String version = voipProtoVersion, String? txid}) async {
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';

final content = {
'call_id': callId,
'party_id': party_id,
Expand Down Expand Up @@ -1778,7 +1773,6 @@ class CallSession {
String? txid,
CallCapabilities? capabilities,
SDPStreamMetadata? metadata}) async {
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
final content = {
'call_id': callId,
'party_id': party_id,
Expand Down Expand Up @@ -1825,7 +1819,6 @@ class CallSession {
String version = voipProtoVersion,
String? txid,
}) async {
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
final content = {
'call_id': callId,
'party_id': party_id,
Expand Down Expand Up @@ -1854,7 +1847,6 @@ class CallSession {
String? txid,
CallCapabilities? capabilities,
SDPStreamMetadata? metadata}) async {
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
final content = {
'call_id': callId,
'party_id': party_id,
Expand All @@ -1879,8 +1871,6 @@ class CallSession {
Future<String?> sendHangupCall(
Room room, String callId, String party_id, String? hangupCause,
{String version = voipProtoVersion, String? txid}) async {
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';

final content = {
'call_id': callId,
'party_id': party_id,
Expand Down Expand Up @@ -1913,7 +1903,6 @@ class CallSession {
Future<String?> sendSDPStreamMetadataChanged(
Room room, String callId, String party_id, SDPStreamMetadata metadata,
{String version = voipProtoVersion, String? txid}) async {
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
final content = {
'call_id': callId,
'party_id': party_id,
Expand All @@ -1938,7 +1927,6 @@ class CallSession {
Future<String?> sendCallReplaces(
Room room, String callId, String party_id, CallReplaces callReplaces,
{String version = voipProtoVersion, String? txid}) async {
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
final content = {
'call_id': callId,
'party_id': party_id,
Expand All @@ -1963,7 +1951,6 @@ class CallSession {
Future<String?> sendAssertedIdentity(Room room, String callId,
String party_id, AssertedIdentity assertedIdentity,
{String version = voipProtoVersion, String? txid}) async {
txid ??= 'txid${DateTime.now().millisecondsSinceEpoch}';
final content = {
'call_id': callId,
'party_id': party_id,
Expand All @@ -1985,7 +1972,7 @@ class CallSession {
Map<String, dynamic> content, {
String? txid,
}) async {
txid ??= client.generateUniqueTransactionId();
txid ??= VoIP.customTxid ?? client.generateUniqueTransactionId();
final mustEncrypt = room.encrypted && client.encryptionEnabled;

// opponentDeviceId is only set for a few events during group calls,
Expand Down
3 changes: 3 additions & 0 deletions lib/src/voip/voip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ abstract class WebRTCDelegate {
}

class VoIP {
// used only for internal tests, all txids for call events will be overwritten to this
static String? customTxid;

TurnServerCredentials? _turnServerCredentials;
Map<String, CallSession> calls = <String, CallSession>{};
Map<String, GroupCall> groupCalls = <String, GroupCall>{};
Expand Down
Loading