Address 'getCurrentIconData returns enabled icon' flakiness

NOJIRA
This commit is contained in:
Niccolò Forlini
2026-04-30 10:38:09 +02:00
committed by MargeBot
parent 120c56f578
commit 1e854fe0c3
2 changed files with 3 additions and 4 deletions
@@ -38,7 +38,7 @@ internal class AppIconManager @Inject constructor(
private val notificationManagerCompatProxy: NotificationManagerCompatProxy
) {
val currentIconData by lazy { MutableStateFlow(getCurrentIconData()) }
private val currentIconState by lazy { MutableStateFlow(getCurrentIconData()) }
fun setNewAppIcon(desiredAppIcon: AppIconData) {
// Dismiss all notifications
@@ -62,7 +62,7 @@ internal class AppIconManager @Inject constructor(
PackageManager.DONT_KILL_APP
)
currentIconData.value = desiredAppIcon
currentIconState.value = desiredAppIcon
createLaunchIntent.invalidateCache()
}
@@ -29,7 +29,6 @@ import io.mockk.just
import io.mockk.mockk
import io.mockk.runs
import io.mockk.verify
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.runTest
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@@ -88,7 +87,7 @@ internal class AppIconManagerTest {
appIconManager.setNewAppIcon(NEW_ICON)
// Then
val updatedIcon = appIconManager.currentIconData.first()
val updatedIcon = appIconManager.getCurrentIconData()
assert(updatedIcon == NEW_ICON)
verify { mockNotificationManager.dismissAllNotifications() }
verify { mockCreateLaunchIntent.invalidateCache() }