0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 12:02:16 +02:00

fix(test): shorten time and use greaterThanOrEqualTo for sleep test

This commit is contained in:
Mike Hardy 2022-05-12 08:41:17 -05:00
parent 6f40e0211c
commit f731c47c5b

View File

@ -18,7 +18,7 @@ package com.ichi2.utils
import android.annotation.SuppressLint
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.greaterThan
import org.hamcrest.Matchers.greaterThanOrEqualTo
import org.junit.Test
class ThreadUtilTest {
@ -28,10 +28,10 @@ class ThreadUtilTest {
fun sleepTest() {
val start: Long = System.currentTimeMillis()
ThreadUtil.sleep(1000) // makes the thread sleep for 1 second
ThreadUtil.sleep(100) // makes the thread sleep for a short while
val end: Long = System.currentTimeMillis()
assertThat(end - start, greaterThan(1000)) // checking if the time difference between "end" and "start" is greater than the time thread has been put to sleep
assertThat(end - start, greaterThanOrEqualTo(100)) // checking if the time difference between "end" and "start" indicates we actually slept
}
}