Compare commits

...

5 Commits

Author SHA1 Message Date
Miguel
401338d566 Update Ouinet to v0.21.3 and change the default ABI to omni 2022-10-18 20:39:02 -05:00
Miguel
0a009f7f4b
Merge pull request #1 from equalitie/instrumented-tests
Instrumented tests
2022-10-12 11:23:31 -05:00
Miguel
e42860f73c Upgrade Ouinet to the v0.21.2 2022-10-11 19:40:26 -05:00
Miguel
49bf4598ff Modify the tests to cover subsequent stop issues 2022-10-11 19:39:18 -05:00
Miguel
89475d0919 Add a test for Ouinet start/stop service 2022-08-08 21:21:21 -05:00
4 changed files with 63 additions and 28 deletions

View File

@ -39,10 +39,10 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0' implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'ie.equalit.ouinet:ouinet-arm64-v8a:0.20.0' implementation 'ie.equalit.ouinet:ouinet-omni:0.21.3'
implementation 'com.getkeepsafe.relinker:relinker:1.4.4' implementation 'com.getkeepsafe.relinker:relinker:1.4.4'
implementation 'com.squareup.okhttp3:okhttp:4.9.3' implementation 'com.squareup.okhttp3:okhttp:4.9.3'
testImplementation 'junit:junit:4.+' testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
} }

View File

@ -44,10 +44,10 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0' implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'ie.equalit.ouinet:ouinet-arm64-v8a:0.20.0' implementation 'ie.equalit.ouinet:ouinet-omni:0.21.3'
implementation 'com.getkeepsafe.relinker:relinker:1.4.4' implementation 'com.getkeepsafe.relinker:relinker:1.4.4'
implementation 'com.squareup.okhttp3:okhttp:4.9.3' implementation 'com.squareup.okhttp3:okhttp:4.9.3'
testImplementation 'junit:junit:4.+' testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
} }

View File

@ -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)
}
}

View File

@ -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());
}
}