From 89475d091914726aed965af0476c644f7e48846f Mon Sep 17 00:00:00 2001 From: Miguel Date: Mon, 8 Aug 2022 21:21:21 -0500 Subject: [PATCH 1/3] 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() + } +} From 49bf4598ff5142a0e0389cb2b6abe5bc8e2c0025 Mon Sep 17 00:00:00 2001 From: Miguel Date: Tue, 11 Oct 2022 19:39:18 -0500 Subject: [PATCH 2/3] Modify the tests to cover subsequent stop issues --- ...rumentedTest.kt => OuinetInstrumentedTest.kt} | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) rename android/kotlin/app/src/androidTest/java/ie/equalit/ouinet_examples/android_kotlin/{ExampleInstrumentedTest.kt => OuinetInstrumentedTest.kt} (76%) 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/OuinetInstrumentedTest.kt similarity index 76% rename from android/kotlin/app/src/androidTest/java/ie/equalit/ouinet_examples/android_kotlin/ExampleInstrumentedTest.kt rename to android/kotlin/app/src/androidTest/java/ie/equalit/ouinet_examples/android_kotlin/OuinetInstrumentedTest.kt index 0edbc29..d5ce84b 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/OuinetInstrumentedTest.kt @@ -17,7 +17,7 @@ import org.junit.Assert.* * See [testing documentation](http://d.android.com/tools/testing). */ @RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { +class OuinetInstrumentedTest { @Test fun useAppContext() { // Context of the app under test. @@ -36,16 +36,24 @@ class ExampleInstrumentedTest { var ouinet = Ouinet(appContext, config) for (i in 1..5) { - ouinet.start() ouinet.start() Thread.sleep(1000); - assertEquals("Starting", ouinet.state.toString()); + assertTrue(ouinet.state.toString().startsWith("Start")) - ouinet.stop() 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()); } } From e42860f73c6f86b14e60697e6d21289675c05c73 Mon Sep 17 00:00:00 2001 From: Miguel Date: Tue, 11 Oct 2022 19:40:12 -0500 Subject: [PATCH 3/3] Upgrade Ouinet to the v0.21.2 --- android/kotlin/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.+'