diff --git a/features/call/api/src/main/kotlin/io/element/android/features/call/api/CallType.kt b/features/call/api/src/main/kotlin/io/element/android/features/call/api/CallType.kt index 677b76a825..2c279b7725 100644 --- a/features/call/api/src/main/kotlin/io/element/android/features/call/api/CallType.kt +++ b/features/call/api/src/main/kotlin/io/element/android/features/call/api/CallType.kt @@ -31,10 +31,3 @@ sealed interface CallType : NodeInputs, Parcelable { } } } - -fun CallType.getSessionId(): SessionId? { - return when (this) { - is CallType.ExternalUrl -> null - is CallType.RoomCall -> sessionId - } -} diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallTypeExtension.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallTypeExtension.kt new file mode 100644 index 0000000000..89a9bfeb19 --- /dev/null +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallTypeExtension.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2025 New Vector Ltd. + * + * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial + * Please see LICENSE files in the repository root for full details. + */ + +package io.element.android.features.call.impl.ui + +import io.element.android.features.call.api.CallType +import io.element.android.libraries.matrix.api.core.SessionId + +fun CallType.getSessionId(): SessionId? { + return when (this) { + is CallType.ExternalUrl -> null + is CallType.RoomCall -> sessionId + } +} diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt index 5b35d68755..44c1c92506 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt @@ -36,7 +36,6 @@ import dev.zacsweers.metro.Inject import io.element.android.compound.colors.SemanticColorsLightDark import io.element.android.features.call.api.CallType import io.element.android.features.call.api.CallType.ExternalUrl -import io.element.android.features.call.api.getSessionId import io.element.android.features.call.impl.DefaultElementCallEntryPoint import io.element.android.features.call.impl.di.CallBindings import io.element.android.features.call.impl.pip.PictureInPictureEvents diff --git a/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallTypeTest.kt b/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallTypeTest.kt new file mode 100644 index 0000000000..3b566784f4 --- /dev/null +++ b/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallTypeTest.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2025 New Vector Ltd. + * + * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial + * Please see LICENSE files in the repository root for full details. + */ + +package io.element.android.features.call.ui + +import com.google.common.truth.Truth.assertThat +import io.element.android.features.call.api.CallType +import io.element.android.features.call.impl.ui.getSessionId +import io.element.android.libraries.matrix.test.A_ROOM_ID +import io.element.android.libraries.matrix.test.A_SESSION_ID +import org.junit.Test + +class CallTypeTest { + @Test + fun `getSessionId returns null for ExternalUrl`() { + assertThat(CallType.ExternalUrl("aURL").getSessionId()).isNull() + } + + @Test + fun `getSessionId returns the sessionId for RoomCall`() { + assertThat( + CallType.RoomCall( + sessionId = A_SESSION_ID, + roomId = A_ROOM_ID, + ).getSessionId() + ).isEqualTo(A_SESSION_ID) + } + + @Test + fun `ExternalUrl stringification does not contain the URL`() { + assertThat(CallType.ExternalUrl("aURL").toString()).isEqualTo("ExternalUrl") + } + + @Test + fun `RoomCall stringification does not contain the URL`() { + assertThat(CallType.RoomCall(A_SESSION_ID, A_ROOM_ID).toString()) + .isEqualTo("RoomCall(sessionId=$A_SESSION_ID, roomId=$A_ROOM_ID)") + } +}