diff --git a/android/kotlin/app/build.gradle b/android/kotlin/app/build.gradle index db2d412..83d9020 100644 --- a/android/kotlin/app/build.gradle +++ b/android/kotlin/app/build.gradle @@ -44,7 +44,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'com.google.android.material:material:1.6.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'ie.equalit.ouinet:ouinet-arm64-v8a:0.20.0' + implementation 'ie.equalit.ouinet:ouinet-arm64-v8a:0.21.2' implementation 'com.getkeepsafe.relinker:relinker:1.4.4' implementation 'com.squareup.okhttp3:okhttp:4.9.3' testImplementation 'junit:junit:4.+' 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 deleted file mode 100644 index 6f93fd4..0000000 --- a/android/kotlin/app/src/androidTest/java/ie/equalit/ouinet_examples/android_kotlin/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package ie.equalit.ouinet_examples.android_kotlin - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("ie.equalit.ouinet_examples.android_kotlin", appContext.packageName) - } -} \ No newline at end of file diff --git a/android/kotlin/app/src/androidTest/java/ie/equalit/ouinet_examples/android_kotlin/OuinetInstrumentedTest.kt b/android/kotlin/app/src/androidTest/java/ie/equalit/ouinet_examples/android_kotlin/OuinetInstrumentedTest.kt new file mode 100644 index 0000000..d5ce84b --- /dev/null +++ b/android/kotlin/app/src/androidTest/java/ie/equalit/ouinet_examples/android_kotlin/OuinetInstrumentedTest.kt @@ -0,0 +1,59 @@ +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 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class OuinetInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + 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() + Thread.sleep(1000); + assertTrue(ouinet.state.toString().startsWith("Start")) + + ouinet.stop() + assertEquals("Stopped", ouinet.state.toString()); + } + + for (i in 1..3) { + Thread.sleep(100); + ouinet.stop() + assertEquals("Stopped", ouinet.state.toString()); + } + + ouinet.start() + Thread.sleep(1000); + assertTrue(ouinet.state.toString().startsWith("Start")) + ouinet.stop() + assertEquals("Stopped", ouinet.state.toString()); + } +}