Skip to content

Commit 2771403

Browse files
committed
Replace deprecated Robolectric APIs in tests
1 parent 31adb2f commit 2771403

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/CustomizedRobolectricTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import kotlinx.coroutines.*
55
import kotlinx.coroutines.test.*
66
import org.junit.Test
77
import org.junit.runner.*
8+
import android.os.Looper
89
import org.robolectric.*
910
import org.robolectric.annotation.*
1011
import org.robolectric.shadows.*
@@ -43,7 +44,7 @@ class CustomizedRobolectricTest : TestBase() {
4344

4445

4546
private fun checkComponent(component: TestComponent) {
46-
val mainLooper = ShadowLooper.getShadowMainLooper()
47+
val mainLooper = Shadows.shadowOf(Looper.getMainLooper())
4748
mainLooper.pause()
4849
component.launchSomething()
4950
assertFalse(component.launchCompleted)

ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/FirstRobolectricTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import kotlinx.coroutines.*
44
import kotlinx.coroutines.test.*
55
import org.junit.Test
66
import org.junit.runner.*
7+
import android.os.Looper
78
import org.robolectric.*
89
import org.robolectric.annotation.*
910
import org.robolectric.shadows.*
@@ -32,7 +33,7 @@ open class FirstRobolectricTest {
3233
@Test
3334
fun testDelay() {
3435
val component = TestComponent()
35-
val mainLooper = ShadowLooper.getShadowMainLooper()
36+
val mainLooper = Shadows.shadowOf(Looper.getMainLooper())
3637
mainLooper.pause()
3738
component.launchDelayed()
3839
mainLooper.runToNextTask()
@@ -42,7 +43,7 @@ open class FirstRobolectricTest {
4243
}
4344

4445
private fun checkComponent(component: TestComponent) {
45-
val mainLooper = ShadowLooper.getShadowMainLooper()
46+
val mainLooper = Shadows.shadowOf(Looper.getMainLooper())
4647
mainLooper.pause()
4748
component.launchSomething()
4849
assertFalse(component.launchCompleted)

ui/kotlinx-coroutines-android/test/HandlerDispatcherTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class HandlerDispatcherTest : MainDispatcherTestBase.WithRealTimeDelay() {
8181
}
8282

8383
private fun CoroutineScope.doTestAwaitFrame() {
84-
ShadowChoreographer.setPostFrameCallbackDelay(100)
84+
ShadowLegacyChoreographer.setPostFrameCallbackDelay(100)
8585
val mainLooper = Shadows.shadowOf(Looper.getMainLooper())
8686
mainLooper.pause()
8787
launch(Dispatchers.Main, start = CoroutineStart.UNDISPATCHED) {
@@ -96,7 +96,7 @@ class HandlerDispatcherTest : MainDispatcherTestBase.WithRealTimeDelay() {
9696
}
9797

9898
private fun CoroutineScope.doTestAwaitWithDetectedChoreographer() {
99-
ShadowChoreographer.setPostFrameCallbackDelay(100)
99+
ShadowLegacyChoreographer.setPostFrameCallbackDelay(100)
100100
val mainLooper = Shadows.shadowOf(Looper.getMainLooper())
101101
launch(Dispatchers.Main, start = CoroutineStart.UNDISPATCHED) {
102102
expect(1)

0 commit comments

Comments
 (0)