Modify the tests to cover subsequent stop issues

This commit is contained in:
Miguel 2022-10-11 19:39:18 -05:00
parent 89475d0919
commit 49bf4598ff

View File

@ -17,7 +17,7 @@ import org.junit.Assert.*
* See [testing documentation](http://d.android.com/tools/testing). * See [testing documentation](http://d.android.com/tools/testing).
*/ */
@RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest { class OuinetInstrumentedTest {
@Test @Test
fun useAppContext() { fun useAppContext() {
// Context of the app under test. // Context of the app under test.
@ -36,16 +36,24 @@ class ExampleInstrumentedTest {
var ouinet = Ouinet(appContext, config) var ouinet = Ouinet(appContext, config)
for (i in 1..5) { for (i in 1..5) {
ouinet.start()
ouinet.start() ouinet.start()
Thread.sleep(1000); Thread.sleep(1000);
assertEquals("Starting", ouinet.state.toString()); assertTrue(ouinet.state.toString().startsWith("Start"))
ouinet.stop()
ouinet.stop() ouinet.stop()
assertEquals("Stopped", ouinet.state.toString()); 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() ouinet.stop()
assertEquals("Stopped", ouinet.state.toString());
} }
} }