@@ -199,6 +199,34 @@ class DefaultActiveCallManagerTest {
199199 }
200200 }
201201
202+ @Test
203+ fun `Decline event - Hangup on a unknown call should send a decline event` () = runTest {
204+ setupShadowPowerManager()
205+ val notificationManagerCompat = mockk<NotificationManagerCompat >(relaxed = true )
206+
207+ val room = mockk<JoinedRoom >(relaxed = true )
208+
209+ val matrixClient = FakeMatrixClient ().apply {
210+ givenGetRoomResult(A_ROOM_ID , room)
211+ }
212+ val clientProvider = FakeMatrixClientProvider ({ Result .success(matrixClient) })
213+
214+ val manager = createActiveCallManager(
215+ matrixClientProvider = clientProvider,
216+ notificationManagerCompat = notificationManagerCompat
217+ )
218+
219+ val notificationData = aCallNotificationData(roomId = A_ROOM_ID )
220+ // Do not register the incoming call, so the manager doesn't know about it
221+ manager.hangUpCall(
222+ callType = CallType .RoomCall (notificationData.sessionId, notificationData.roomId),
223+ notificationData = notificationData,
224+ )
225+ coVerify {
226+ room.declineCall(notificationEventId = notificationData.eventId)
227+ }
228+ }
229+
202230 @OptIn(ExperimentalCoroutinesApi ::class )
203231 @Test
204232 fun `Decline event - Declining from another session should stop ringing` () = runTest {
@@ -282,7 +310,8 @@ class DefaultActiveCallManagerTest {
282310 assertThat(manager.activeCall.value).isNotNull()
283311 assertThat(manager.activeWakeLock?.isHeld).isTrue()
284312
285- verify(exactly = 0 ) { notificationManagerCompat.cancel(notificationId) }
313+ // The notification is always cancelled do not block the user
314+ verify(exactly = 1 ) { notificationManagerCompat.cancel(notificationId) }
286315 }
287316
288317 @OptIn(ExperimentalCoroutinesApi ::class )
0 commit comments