[V2X]优化V2X弹窗在子线程调用的逻辑

This commit is contained in:
renwj
2022-08-03 19:47:55 +08:00
parent 7a59119888
commit e7f57c1cfc
5 changed files with 86 additions and 35 deletions

View File

@@ -52,7 +52,7 @@ class AutoPilotBadCaseTest {
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
index++
}
CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
// CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
}
.flowOn(Dispatchers.Default)
.collect()
@@ -86,7 +86,7 @@ class AutoPilotBadCaseTest {
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
index++
}
CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
// CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
}
.flowOn(Dispatchers.Default)
.collect()
@@ -114,7 +114,7 @@ class AutoPilotBadCaseTest {
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
index++
}
CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
// CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
}
.flowOn(Dispatchers.Default)
.collect()

View File

@@ -20,6 +20,7 @@ import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.hmi.notification.WarningFloat
import com.mogo.eagle.core.function.hmi.notification.anim.DefaultAnimator
import com.mogo.eagle.core.data.enums.SidePattern
import com.mogo.eagle.core.function.hmi.ui.*
import com.mogo.eagle.core.function.main.MainLauncherActivity
import com.mogo.eagle.core.utilcode.kotlin.shape
import com.mogo.eagle.core.utilcode.reminder.Reminder
@@ -27,14 +28,14 @@ import com.mogo.eagle.core.utilcode.reminder.api.impl.ActivityReminder
import com.mogo.eagle.core.utilcode.reminder.api.impl.PopupWindowReminder
import com.mogo.eagle.core.utilcode.reminder.api.impl.ViewReminder
import com.mogo.eagle.core.utilcode.util.AppStateManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import java.lang.Integer.min
import java.util.concurrent.TimeUnit
import java.util.concurrent.*
import java.util.concurrent.TimeUnit.MILLISECONDS
@RunWith(AndroidJUnit4::class)
@@ -64,6 +65,46 @@ class ReminderTest {
return@runBlocking
}
@Test
fun testShowWarningV2x() = runBlocking {
val f = ensureMoGoHmiFragmentShow()
delay(5000)
(1 until 20).map {
it
}.asFlow()
.onEach {
f.showWarningV2X("10006", "test", "测试$it", "$it", null, true, 5000)
}
.flowOn(Dispatchers.Default)
.collect()
delay(3000000)
}
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiFragment = suspendCancellableCoroutine {
launch.onActivity { itx ->
val executor = Executors.newSingleThreadScheduledExecutor()
executor.scheduleAtFixedRate({
var find =
itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
while (find == null) {
find =
itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
}
while (!find.isResumed) {
Thread.sleep(500)
}
it.resumeWith(Result.success(find))
try {
Thread.sleep(500)
executor.shutdownNow()
} catch (e: Throwable) {
e.printStackTrace()
}
}, 50, 500, MILLISECONDS)
}
}
@Test
fun testViewReminderOverride() = runBlocking(Dispatchers.Main) {
launch.onActivity {
@@ -357,14 +398,14 @@ class ReminderTest {
}
}
class TestPopupWindowReminder(private val anchor: View, private val popupWindow: PopupWindow): PopupWindowReminder(popupWindow) {
class TestPopupWindowReminder(private val anchor: View, override val popupWindow: PopupWindow): PopupWindowReminder(popupWindow) {
override fun show() {
popupWindow.showAtLocation(anchor, Gravity.CENTER, 0, 0)
}
}
class TestPopupWindowReminderOverride(private val anchor: View, private val popupWindow: PopupWindow): PopupWindowReminder(popupWindow) {
class TestPopupWindowReminderOverride(private val anchor: View, override val popupWindow: PopupWindow): PopupWindowReminder(popupWindow) {
override fun show() {
popupWindow.showAtLocation(anchor, Gravity.CENTER, 0, 0)