[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert java.util.concurrent.TimeUnit to kotlin.time.Duration #496

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package androidx.paging
import com.google.common.truth.Truth.assertWithMessage
import java.lang.ref.ReferenceQueue
import java.lang.ref.WeakReference
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicBoolean
import kotlin.concurrent.thread
import kotlin.reflect.KClass
import kotlin.time.Duration.Companion.seconds

internal class GarbageCollectionTestHelper {
private val queue = ReferenceQueue<Any>()
Expand All @@ -49,7 +49,7 @@ internal class GarbageCollectionTestHelper {
var collectedItemCount = 0
val expectedItemCount = size - expected.sumOf { it.second }
while (collectedItemCount < expectedItemCount &&
queue.remove(TimeUnit.SECONDS.toMillis(10)) != null
queue.remove(10.seconds.inWholeMilliseconds) != null
) {
collectedItemCount++
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import java.util.Collections
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue
import kotlin.time.Duration.Companion.seconds

@OptIn(ExperimentalCoroutinesApi::class)
@RunWith(JUnit4::class)
Expand Down Expand Up @@ -179,7 +179,7 @@ class SingleRunnerTest {
}
}
runBlocking {
withTimeout(TimeUnit.SECONDS.toMillis(10)) {
withTimeout(10.seconds) {
job2.join()
}
}
Expand Down