From 89475d091914726aed965af0476c644f7e48846f Mon Sep 17 00:00:00 2001 From: Miguel Date: Mon, 8 Aug 2022 21:21:21 -0500 Subject: [PATCH] Add a test for Ouinet start/stop service --- .../android_kotlin/ExampleInstrumentedTest.kt | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/android/kotlin/app/src/androidTest/java/ie/equalit/ouinet_examples/android_kotlin/ExampleInstrumentedTest.kt b/android/kotlin/app/src/androidTest/java/ie/equalit/ouinet_examples/android_kotlin/ExampleInstrumentedTest.kt index 6f93fd4..0edbc29 100644 --- a/android/kotlin/app/src/androidTest/java/ie/equalit/ouinet_examples/android_kotlin/ExampleInstrumentedTest.kt +++ b/android/kotlin/app/src/androidTest/java/ie/equalit/ouinet_examples/android_kotlin/ExampleInstrumentedTest.kt @@ -1,5 +1,8 @@ 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.ext.junit.runners.AndroidJUnit4 @@ -21,4 +24,28 @@ class ExampleInstrumentedTest { val appContext = InstrumentationRegistry.getInstrumentation().targetContext assertEquals("ie.equalit.ouinet_examples.android_kotlin", appContext.packageName) } -} \ No newline at end of file + + @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() + } +}