Merge branch 'dev_robotaxi-d-app-module_251_220125_2.5.1' into dev_MogoAP_eagle-220_211207_8.0.17_merge
# Conflicts: # app/build.gradle
This commit is contained in:
13
app/src/androidTest/AndroidManifest.xml
Normal file
13
app/src/androidTest/AndroidManifest.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.mogo.launcher.f.test"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<instrumentation android:targetPackage="com.mogo.launcher.f"
|
||||
android:name="androidx.test.runner.AndroidJUnitRunner"/>
|
||||
|
||||
<application tools:replace="label" android:label="AutoPilotTest" />
|
||||
|
||||
</manifest>
|
||||
@@ -39,14 +39,14 @@ class AutoPilotBadCaseTest {
|
||||
.onEach {
|
||||
delay(TimeUnit.SECONDS.toMillis(5))
|
||||
f.onAutopilotRecordResult(AutoPilotRecordResult().also {
|
||||
it.diskFree = 100 + index
|
||||
it.diskFree = (100 + index).toLong()
|
||||
it.duration = 60.0
|
||||
it.fileName = "/user/general/record_$index.log"
|
||||
it.id = 10 + index
|
||||
it.key = "yyy_$index"
|
||||
it.stat = 100
|
||||
it.type = 1
|
||||
it.timestamp = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Date())
|
||||
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
index++
|
||||
})
|
||||
}
|
||||
@@ -70,14 +70,14 @@ class AutoPilotBadCaseTest {
|
||||
delay(Random(20).nextLong())
|
||||
}
|
||||
f.onAutopilotRecordResult(AutoPilotRecordResult().also {
|
||||
it.diskFree = 100 + index
|
||||
it.diskFree = (100 + index).toLong()
|
||||
it.duration = 60.0
|
||||
it.fileName = "/user/general/record_$index.log"
|
||||
it.id = 10 + index
|
||||
it.key = "yyy_$index"
|
||||
it.stat = 100
|
||||
it.type = 1
|
||||
it.timestamp = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Date())
|
||||
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
index++
|
||||
})
|
||||
|
||||
@@ -101,14 +101,14 @@ class AutoPilotBadCaseTest {
|
||||
.onEach {
|
||||
delay(TimeUnit.SECONDS.toMillis(20))
|
||||
f.onAutopilotRecordResult(AutoPilotRecordResult().also {
|
||||
it.diskFree = 100 + index
|
||||
it.diskFree = (100 + index).toLong()
|
||||
it.duration = 60.0
|
||||
it.fileName = "/user/general/record_$index.log"
|
||||
it.id = 10 + index
|
||||
it.key = "yyy_$index"
|
||||
it.stat = 100
|
||||
it.type = 1
|
||||
it.timestamp = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Date())
|
||||
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
index++
|
||||
})
|
||||
}
|
||||
|
||||
390
app/src/androidTest/java/com/mogo/functions/test/ReminderTest.kt
Normal file
390
app/src/androidTest/java/com/mogo/functions/test/ReminderTest.kt
Normal file
@@ -0,0 +1,390 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import android.animation.Animator
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.text.TextUtils
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.view.animation.OvershootInterpolator
|
||||
import android.widget.PopupWindow
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.commons.voice.AIAssist
|
||||
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.function.hmi.notification.enums.SidePattern
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.V2XNotificationView
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import com.mogo.eagle.core.utilcode.kotlin.shape
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.reminder.Reminder
|
||||
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 com.mogo.module.common.enums.EventTypeEnum
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.lang.Integer.min
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class ReminderTest {
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testViewReminderNotOverride() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
val reminder = WindowManagerViewUnOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
reminder.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
return@runBlocking
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testViewReminderOverride() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenCreated {
|
||||
for (i in 1..10) {
|
||||
val reminder = WindowManagerViewOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
return@runBlocking
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testViewReminderWhenActivityDestroyed() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenCreated {
|
||||
for (i in 1..10) {
|
||||
val reminder = WindowManagerViewOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
|
||||
if (i == 8) {
|
||||
it.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWarningFloat() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenCreated {
|
||||
for (i in 1..10) {
|
||||
val v = View(it).also {
|
||||
it.background = shape(solid = color(i))
|
||||
it.layoutParams = WindowManager.LayoutParams().also { itx ->
|
||||
itx.width = 300
|
||||
itx.height = 400
|
||||
}
|
||||
}
|
||||
val builder = WarningFloat.with(it).setTag("test${i}").setLayout(v).setSidePattern(SidePattern.RESULT_TOP).setCountDownTime(TimeUnit.SECONDS.toMillis(10)).setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110).setImmersionStatusBar(true).addWarningStatusListener(object :
|
||||
IMoGoWarningStatusListener {
|
||||
override fun onShow() {
|
||||
|
||||
}
|
||||
}).setAnimator(object : DefaultAnimator() {
|
||||
override fun enterAnim(view: View, params: WindowManager.LayoutParams, windowManager: WindowManager, sidePattern: SidePattern): Animator? = super.enterAnim(view, params, windowManager, sidePattern)?.apply {
|
||||
interpolator = OvershootInterpolator()
|
||||
}
|
||||
|
||||
override fun exitAnim(view: View, params: WindowManager.LayoutParams, windowManager: WindowManager, sidePattern: SidePattern): Animator? = super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
|
||||
})
|
||||
Reminder.enqueue(it, WarningFloatReminder(builder))
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testActivityReminder() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
val reminder = ActivityNameReminder(it, "com.mogo.launcher.TestActivity")
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(6))
|
||||
reminder.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testActivityReminderOverride() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
val reminder = ActivityNameOverrideReminder(it, "com.mogo.launcher.TestActivity")
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(6))
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testPopupWindowReminder() = runBlocking {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
|
||||
val reminder = TestPopupWindowReminder(it.findViewById(android.R.id.content), PopupWindow(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT).also { itx ->
|
||||
itx.contentView = View(it).also {
|
||||
xx -> xx.background = shape(solid = color(i))
|
||||
xx.layoutParams = ViewGroup.LayoutParams(300, 400)
|
||||
}
|
||||
})
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
reminder.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPopupWindowReminderOverride() = runBlocking {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
|
||||
val reminder = TestPopupWindowReminderOverride(it.findViewById(android.R.id.content), PopupWindow(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT).also { itx ->
|
||||
itx.contentView = View(it).also {
|
||||
xx -> xx.background = shape(solid = color(i))
|
||||
xx.layoutParams = ViewGroup.LayoutParams(300, 400)
|
||||
}
|
||||
})
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWarningFloatForProject() = runBlocking {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
val notificationView = V2XNotificationView(it)
|
||||
notificationView.setWarningIcon(EventTypeEnum.getWarningIcon("10003"))
|
||||
notificationView.setWarningContent("XXXXXX${i}")
|
||||
WarningFloat.with(it)
|
||||
.setTag("tag")
|
||||
.setLayout(notificationView)
|
||||
.setSidePattern(SidePattern.RESULT_TOP)
|
||||
.setCountDownTime(5000)
|
||||
.setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110)
|
||||
.setImmersionStatusBar(true)
|
||||
.addWarningStatusListener(object : IMoGoWarningStatusListener {
|
||||
override fun onShow() {
|
||||
}
|
||||
})
|
||||
.setAnimator(object : DefaultAnimator() {
|
||||
override fun enterAnim(
|
||||
view: View,
|
||||
params: WindowManager.LayoutParams,
|
||||
windowManager: WindowManager,
|
||||
sidePattern: SidePattern
|
||||
): Animator? =
|
||||
super.enterAnim(view, params, windowManager, sidePattern)?.apply {
|
||||
interpolator = OvershootInterpolator()
|
||||
}
|
||||
|
||||
override fun exitAnim(
|
||||
view: View,
|
||||
params: WindowManager.LayoutParams,
|
||||
windowManager: WindowManager,
|
||||
sidePattern: SidePattern
|
||||
): Animator? =
|
||||
super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
|
||||
})
|
||||
.show()
|
||||
delay(2000)
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
|
||||
class WarningFloatReminder(private val builder: WarningFloat.Builder) : ViewReminder(builder.config.layoutView!!) {
|
||||
|
||||
override fun show() {
|
||||
builder.show()
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
WarningFloat.dismiss(builder.config.floatTag, false)
|
||||
}
|
||||
|
||||
override fun isOverride(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class WindowManagerViewUnOverrideReminder(private val content: View, private val width: Int, private val height: Int) : ViewReminder(content) {
|
||||
|
||||
private val wm by lazy {
|
||||
content.context.getSystemService(Activity.WINDOW_SERVICE) as WindowManager
|
||||
}
|
||||
|
||||
private var isAdd = false
|
||||
|
||||
override fun show() {
|
||||
if (!isAdd) {
|
||||
val params = WindowManager.LayoutParams().also {
|
||||
it.width = width
|
||||
it.height = height
|
||||
}
|
||||
params.gravity = Gravity.CENTER
|
||||
wm.addView(content, params)
|
||||
isAdd = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
if (isAdd && ViewCompat.isAttachedToWindow(content)) {
|
||||
wm.removeView(content)
|
||||
isAdd = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class WindowManagerViewOverrideReminder(private val content: View, private val width: Int, private val height: Int) : ViewReminder(content) {
|
||||
|
||||
private val wm by lazy {
|
||||
content.context.getSystemService(Activity.WINDOW_SERVICE) as WindowManager
|
||||
}
|
||||
|
||||
private var isAdd = false
|
||||
|
||||
override fun show() {
|
||||
if (!isAdd) {
|
||||
val params = WindowManager.LayoutParams().also {
|
||||
it.width = width
|
||||
it.height = height
|
||||
}
|
||||
params.gravity = Gravity.CENTER
|
||||
wm.addView(content, params)
|
||||
isAdd = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
if (isAdd && ViewCompat.isAttachedToWindow(content)) {
|
||||
wm.removeView(content)
|
||||
isAdd = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun isOverride(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ActivityNameReminder(private val context: Context, private val className: String): ActivityReminder(className) {
|
||||
|
||||
override fun show() {
|
||||
Intent(context, Class.forName(className)).also {
|
||||
context.startActivity(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
AppStateManager.currentActivity()?.takeIf { it.javaClass.name == className }?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
class ActivityNameOverrideReminder(private val context: Context, private val className: String): ActivityReminder(className) {
|
||||
|
||||
override fun show() {
|
||||
Intent(context, Class.forName(className)).also {
|
||||
context.startActivity(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
AppStateManager.currentActivity()?.takeIf { it.javaClass.name == className }?.finish()
|
||||
}
|
||||
|
||||
override fun isOverride(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
class TestPopupWindowReminder(private val anchor: View, private 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) {
|
||||
|
||||
override fun show() {
|
||||
popupWindow.showAtLocation(anchor, Gravity.CENTER, 0, 0)
|
||||
}
|
||||
|
||||
override fun isOverride(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
private fun color(index: Int): Int {
|
||||
if (index > 10) {
|
||||
return Color.BLACK
|
||||
}
|
||||
val alpha = min(255, 255 - index * 20)
|
||||
return Color.argb(alpha, Color.red(Color.RED), Color.green(Color.RED), Color.blue(Color.RED))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user