Skip to content

Commit

Permalink
fix psi tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Sep 30, 2024
1 parent aa6e361 commit de6ad6b
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions srt/src/test/java/com/pedro/srt/mpeg2ts/PsiManagerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.pedro.srt.mpeg2ts

import com.pedro.srt.mpeg2ts.psi.PsiManager
import com.pedro.srt.mpeg2ts.psi.TableToSend
import com.pedro.srt.mpeg2ts.service.Mpeg2TsService
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
Expand All @@ -30,21 +31,32 @@ class PsiManagerTest {
private val service = Mpeg2TsService()

@Test
fun `GIVEN a psiManager WHEN call should send is key false interval times THEN return psi packets`() {
service.generatePmt()
fun `GIVEN a psiManager WHEN call should send is key false patPeriod times THEN return TableToSend PAT_PMT`() {
val psiManager = PsiManager(service)
val mpegTsPacketizer = MpegTsPacketizer(psiManager)
val result = psiManager.checkSendInfo(false, mpegTsPacketizer)
assertTrue(result.isNotEmpty())
var sendValue = TableToSend.NONE
(0..PsiManager.patPeriod).forEach { _ ->
sendValue = psiManager.shouldSend(false)
}
assertEquals(TableToSend.PAT_PMT, sendValue)
}

@Test
fun `GIVEN a psiManager WHEN call should send is key false sdtPeriod times THEN return TableToSend ALL`() {
val psiManager = PsiManager(service)
var sendValue = TableToSend.NONE
(0..PsiManager.sdtPeriod).forEach { _ ->
sendValue = psiManager.shouldSend(false)
}
assertEquals(TableToSend.ALL, sendValue)
}

@Test
fun `GIVEN a psiManager WHEN update pat and sdt version THEN get version 1`() {
val psiManager = PsiManager(service)
psiManager.upgradePatVersion()
psiManager.upgradeSdtVersion()
assertEquals(0x01.toByte(), psiManager.pat.version)
assertEquals(0x01.toByte(), psiManager.sdt.version)
assertEquals(0x01.toByte(), psiManager.getPat().version)
assertEquals(0x01.toByte(), psiManager.getSdt().version)
}

@Test
Expand All @@ -53,7 +65,7 @@ class PsiManagerTest {
val name = "name updated"
val serviceUpdated = service.copy(name = name)
psiManager.updateService(serviceUpdated)
assertEquals(name, psiManager.pat.service.name)
assertEquals(name, psiManager.sdt.service.name)
assertEquals(name, psiManager.getPat().service.name)
assertEquals(name, psiManager.getSdt().service.name)
}
}

0 comments on commit de6ad6b

Please sign in to comment.