mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Avoid tryEmit(), use emit()
This commit is contained in:
committed by
Benoit Marty
parent
a83952814f
commit
74048cca8f
+5
-5
@@ -48,30 +48,30 @@ class FakeNotificationTroubleshootTest(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset() {
|
override suspend fun reset() {
|
||||||
updateState(
|
updateState(
|
||||||
name = defaultName,
|
name = defaultName,
|
||||||
description = defaultDescription,
|
description = defaultDescription,
|
||||||
status = firstStatus,
|
status = firstStatus,
|
||||||
)
|
)
|
||||||
resetAction()?.let {
|
resetAction()?.let {
|
||||||
_state.tryEmit(it)
|
_state.emit(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun quickFix(coroutineScope: CoroutineScope) {
|
override suspend fun quickFix(coroutineScope: CoroutineScope) {
|
||||||
updateState(NotificationTroubleshootTestState.Status.InProgress)
|
updateState(NotificationTroubleshootTestState.Status.InProgress)
|
||||||
quickFixAction()?.let {
|
quickFixAction()?.let {
|
||||||
_state.tryEmit(it)
|
_state.emit(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateState(
|
suspend fun updateState(
|
||||||
status: NotificationTroubleshootTestState.Status,
|
status: NotificationTroubleshootTestState.Status,
|
||||||
name: String = defaultName,
|
name: String = defaultName,
|
||||||
description: String = defaultDescription,
|
description: String = defaultDescription,
|
||||||
) {
|
) {
|
||||||
_state.tryEmit(
|
_state.emit(
|
||||||
NotificationTroubleshootTestState(
|
NotificationTroubleshootTestState(
|
||||||
name = name,
|
name = name,
|
||||||
description = description,
|
description = description,
|
||||||
|
|||||||
+4
-2
@@ -24,6 +24,8 @@ interface NotificationTroubleshootTest {
|
|||||||
val state: StateFlow<NotificationTroubleshootTestState>
|
val state: StateFlow<NotificationTroubleshootTestState>
|
||||||
fun isRelevant(data: TestFilterData): Boolean = true
|
fun isRelevant(data: TestFilterData): Boolean = true
|
||||||
suspend fun run(coroutineScope: CoroutineScope)
|
suspend fun run(coroutineScope: CoroutineScope)
|
||||||
fun reset()
|
suspend fun reset()
|
||||||
suspend fun quickFix(coroutineScope: CoroutineScope) {}
|
suspend fun quickFix(coroutineScope: CoroutineScope) {
|
||||||
|
error("Quick fix not implemented, you need to override this method in your test")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -41,12 +41,12 @@ class NotificationTroubleshootTestDelegate(
|
|||||||
|
|
||||||
val state: StateFlow<NotificationTroubleshootTestState> = _state.asStateFlow()
|
val state: StateFlow<NotificationTroubleshootTestState> = _state.asStateFlow()
|
||||||
|
|
||||||
fun updateState(
|
suspend fun updateState(
|
||||||
status: NotificationTroubleshootTestState.Status,
|
status: NotificationTroubleshootTestState.Status,
|
||||||
name: String = defaultName,
|
name: String = defaultName,
|
||||||
description: String = defaultDescription,
|
description: String = defaultDescription,
|
||||||
) {
|
) {
|
||||||
_state.tryEmit(
|
_state.emit(
|
||||||
NotificationTroubleshootTestState(
|
NotificationTroubleshootTestState(
|
||||||
name = name,
|
name = name,
|
||||||
description = description,
|
description = description,
|
||||||
@@ -55,7 +55,7 @@ class NotificationTroubleshootTestDelegate(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reset() {
|
suspend fun reset() {
|
||||||
updateState(NotificationTroubleshootTestState.Status.Idle(visibleWhenIdle))
|
updateState(NotificationTroubleshootTestState.Status.Idle(visibleWhenIdle))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ class NotificationTroubleshootTestDelegate(
|
|||||||
delay(fakeDelay)
|
delay(fakeDelay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun done(isSuccess: Boolean = true) {
|
suspend fun done(isSuccess: Boolean = true) {
|
||||||
updateState(
|
updateState(
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
NotificationTroubleshootTestState.Status.Success
|
NotificationTroubleshootTestState.Status.Success
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ class NotificationTroubleshootCheckPermissionTest @Inject constructor(
|
|||||||
delegate.done(result)
|
delegate.done(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset() = delegate.reset()
|
override suspend fun reset() = delegate.reset()
|
||||||
|
|
||||||
override suspend fun quickFix(coroutineScope: CoroutineScope) {
|
override suspend fun quickFix(coroutineScope: CoroutineScope) {
|
||||||
// Do not bother about asking the permission inline, just lead the user to the settings
|
// Do not bother about asking the permission inline, just lead the user to the settings
|
||||||
|
|||||||
+1
-1
@@ -54,5 +54,5 @@ class CurrentPushProviderTest @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset() = delegate.reset()
|
override suspend fun reset() = delegate.reset()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -90,5 +90,5 @@ class NotificationTest @Inject constructor(
|
|||||||
notificationDisplayer.dismissDiagnosticNotification()
|
notificationDisplayer.dismissDiagnosticNotification()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset() = delegate.reset()
|
override suspend fun reset() = delegate.reset()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -98,5 +98,5 @@ class PushLoopbackTest @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset() = delegate.reset()
|
override suspend fun reset() = delegate.reset()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -55,5 +55,5 @@ class PushProvidersTest @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset() = delegate.reset()
|
override suspend fun reset() = delegate.reset()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -61,5 +61,5 @@ class FirebaseAvailabilityTest @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset() = delegate.reset()
|
override suspend fun reset() = delegate.reset()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ class FirebaseTokenTest @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset() = delegate.reset()
|
override suspend fun reset() = delegate.reset()
|
||||||
|
|
||||||
override suspend fun quickFix(coroutineScope: CoroutineScope) {
|
override suspend fun quickFix(coroutineScope: CoroutineScope) {
|
||||||
delegate.start()
|
delegate.start()
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ class UnifiedPushTest @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset() = delegate.reset()
|
override suspend fun reset() = delegate.reset()
|
||||||
|
|
||||||
override suspend fun quickFix(coroutineScope: CoroutineScope) {
|
override suspend fun quickFix(coroutineScope: CoroutineScope) {
|
||||||
openDistributorWebPageAction.execute()
|
openDistributorWebPageAction.execute()
|
||||||
|
|||||||
Reference in New Issue
Block a user