Skip to content

Commit cd5cbb9

Browse files
committed
Update robolectric to workaround robolectric/robolectric#5456 and then workaround all the update consequences
1 parent c54fb0b commit cd5cbb9

6 files changed

+37
-4
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jna_version=5.9.0
3030
# Android versions
3131
android_version=4.1.1.4
3232
androidx_annotation_version=1.1.0
33-
robolectric_version=4.0.2
33+
robolectric_version=4.4
3434
baksmali_version=2.2.7
3535

3636
# JS

ui/kotlinx-coroutines-android/build.gradle.kts

+32-2
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,46 @@ configurations {
1010

1111
repositories {
1212
mavenCentral()
13-
jcenter() // https://youtrack.jetbrains.com/issue/IDEA-261387
1413
}
14+
15+
val artifactType = Attribute.of("artifactType", String::class.java)
16+
val unpackedAar = Attribute.of("unpackedAar", Boolean::class.javaObjectType)
17+
18+
configurations.configureEach {
19+
afterEvaluate {
20+
if (isCanBeResolved) {
21+
attributes.attribute(unpackedAar, true) // request all AARs to be unpacked
22+
}
23+
}
24+
}
25+
1526
dependencies {
27+
attributesSchema {
28+
attribute(unpackedAar)
29+
}
30+
31+
artifactTypes {
32+
create("aar") {
33+
attributes.attribute(unpackedAar, false)
34+
}
35+
}
36+
37+
registerTransform(UnpackAar::class.java) {
38+
from.attribute(unpackedAar, false).attribute(artifactType, "aar")
39+
to.attribute(unpackedAar, true).attribute(artifactType, "jar")
40+
}
41+
1642
compileOnly("com.google.android:android:${version("android")}")
1743
compileOnly("androidx.annotation:annotation:${version("androidx_annotation")}")
1844

1945
testImplementation("com.google.android:android:${version("android")}")
2046
testImplementation("org.robolectric:robolectric:${version("robolectric")}")
21-
testImplementation("org.smali:baksmali:${version("baksmali")}")
47+
// Required by robolectric
48+
testImplementation("androidx.test:core:1.2.0")
49+
testImplementation("androidx.test:monitor:1.2.0")
50+
2251

52+
testImplementation("org.smali:baksmali:${version("baksmali")}")
2353
"r8"("com.android.tools.build:builder:7.1.0-alpha01")
2454
}
2555

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

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import kotlin.test.*
1313

1414
@RunWith(RobolectricTestRunner::class)
1515
@Config(manifest = Config.NONE, sdk = [27])
16+
@LooperMode(LooperMode.Mode.LEGACY)
1617
class AndroidExceptionPreHandlerTest : TestBase() {
1718
@Test
1819
fun testUnhandledException() = runTest {

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

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import org.robolectric.annotation.*
1313

1414
@RunWith(RobolectricTestRunner::class)
1515
@Config(manifest = Config.NONE, sdk = [28])
16+
@LooperMode(LooperMode.Mode.LEGACY)
1617
class DisabledHandlerTest : TestBase() {
1718

1819
private var delegateToSuper = false

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

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import kotlin.test.*
1818

1919
@RunWith(RobolectricTestRunner::class)
2020
@Config(manifest = Config.NONE, sdk = [28])
21+
@LooperMode(LooperMode.Mode.LEGACY)
2122
class HandlerDispatcherAsyncTest : TestBase() {
2223

2324
/**

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import kotlin.test.*
1616

1717
@RunWith(RobolectricTestRunner::class)
1818
@Config(manifest = Config.NONE, sdk = [28])
19+
@LooperMode(LooperMode.Mode.LEGACY)
1920
class HandlerDispatcherTest : TestBase() {
2021
@Test
2122
fun testImmediateDispatcherYield() = runBlocking(Dispatchers.Main) {
@@ -121,7 +122,6 @@ class HandlerDispatcherTest : TestBase() {
121122
}
122123

123124
private fun CoroutineScope.doTestAwaitWithDetectedChoreographer() {
124-
ShadowChoreographer.reset()
125125
ShadowChoreographer.setPostFrameCallbackDelay(100)
126126
val mainLooper = Shadows.shadowOf(Looper.getMainLooper())
127127
launch(Dispatchers.Main, start = CoroutineStart.UNDISPATCHED) {

0 commit comments

Comments
 (0)