RemoteParticipantTest.kt
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package io.livekit.android.room.participant
import io.livekit.android.room.RTCClient
import livekit.LivekitModels
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Before
import org.junit.Test
import org.mockito.Mockito
class RemoteParticipantTest {
lateinit var participant: RemoteParticipant
@Before
fun setup() {
val rtcClient = Mockito.mock(RTCClient::class.java)
participant = RemoteParticipant(rtcClient, "sid")
}
@Test
fun updateFromInfoAddsTrack() {
val newTrackInfo = LivekitModels.ParticipantInfo.newBuilder(INFO)
.addTracks(TRACK_INFO)
.build()
participant.updateFromInfo(newTrackInfo)
assertEquals(1, participant.tracks.values.size)
assertNotNull(participant.getTrackPublication(TRACK_INFO.sid))
}
companion object {
val INFO = LivekitModels.ParticipantInfo.newBuilder()
.setSid("sid")
.setIdentity("identity")
.setMetadata("metadata")
.build()
val TRACK_INFO = LivekitModels.TrackInfo.newBuilder()
.setSid("sid")
.setName("name")
.setType(LivekitModels.TrackType.AUDIO)
.setMuted(false)
.build()
}
}