package com.mogo.functions.test import androidx.test.core.app.ActivityScenario import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import androidx.test.platform.app.InstrumentationRegistry import com.mogo.eagle.core.function.call.chat.CallerChatManager import com.mogo.eagle.core.function.main.MainLauncherActivity import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import java.util.concurrent.TimeUnit @RunWith(AndroidJUnit4::class) @LargeTest class ChatTest { lateinit var launch: ActivityScenario @Before fun before() { launch = ActivityScenario.launch(MainLauncherActivity::class.java) } @Test fun testChat() = runBlocking { val arguments = InstrumentationRegistry.getArguments() val delay = arguments.getString("delay", "0") val sn = arguments.getString("sn", "") val delayLong = delay.toLong() if (delayLong <= 0 || sn.isNullOrEmpty()) { throw AssertionError("illegal state ..") } delay(delayLong) launch.onActivity { activity -> CallerChatManager.call(activity, sn) } delay(TimeUnit.MINUTES.toMillis(10)) } }