Add a test for Ouinet start/stop service
This commit is contained in:
parent
9dba1219bc
commit
89475d0919
|
@ -1,5 +1,8 @@
|
||||||
package ie.equalit.ouinet_examples.android_kotlin
|
package ie.equalit.ouinet_examples.android_kotlin
|
||||||
|
|
||||||
|
import ie.equalit.ouinet.Config
|
||||||
|
import ie.equalit.ouinet.Ouinet
|
||||||
|
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
|
||||||
|
@ -21,4 +24,28 @@ class ExampleInstrumentedTest {
|
||||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||||
assertEquals("ie.equalit.ouinet_examples.android_kotlin", appContext.packageName)
|
assertEquals("ie.equalit.ouinet_examples.android_kotlin", appContext.packageName)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
|
fun testStartStop() {
|
||||||
|
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||||
|
var config = Config.ConfigBuilder(appContext)
|
||||||
|
.setCacheType("bep5-http")
|
||||||
|
.setCacheHttpPubKey(BuildConfig.CACHE_PUB_KEY)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
var ouinet = Ouinet(appContext, config)
|
||||||
|
|
||||||
|
for (i in 1..5) {
|
||||||
|
ouinet.start()
|
||||||
|
ouinet.start()
|
||||||
|
Thread.sleep(1000);
|
||||||
|
assertEquals("Starting", ouinet.state.toString());
|
||||||
|
|
||||||
|
ouinet.stop()
|
||||||
|
ouinet.stop()
|
||||||
|
assertEquals("Stopped", ouinet.state.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
ouinet.stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user