mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 15:26:15 +00:00
Add unit test on ProgressWatcherWrapper
This commit is contained in:
committed by
Benoit Marty
parent
25fd71cb2c
commit
021d7297e5
+33
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
* Please see LICENSE in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.libraries.matrix.impl.core
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.libraries.matrix.api.core.ProgressCallback
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.junit.Test
|
||||||
|
import org.matrix.rustcomponents.sdk.TransmissionProgress
|
||||||
|
import kotlin.coroutines.resume
|
||||||
|
import kotlin.coroutines.suspendCoroutine
|
||||||
|
|
||||||
|
class ProgressWatcherWrapperKtTest {
|
||||||
|
@Test
|
||||||
|
fun testToProgressWatcher() = runTest {
|
||||||
|
suspendCoroutine { continuation ->
|
||||||
|
val callback = object : ProgressCallback {
|
||||||
|
override fun onProgress(current: Long, total: Long) {
|
||||||
|
assertThat(current).isEqualTo(1)
|
||||||
|
assertThat(total).isEqualTo(2)
|
||||||
|
continuation.resume(Unit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val result = callback.toProgressWatcher()
|
||||||
|
result.transmissionProgress(TransmissionProgress(1.toULong(), 2.toULong()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user