Skip to content

Commit 6d17b57

Browse files
authored
[various] Update Robolectric to 4.17 (flutter#13041)
Updates test dependencies to Robolectric 4.17. Added a bunch of flags because JDK 17+ blocks reflective access to JDK internals by default. Starting with 4.17, Robolectric's test environment setup reflects into jdk.internal.access, so these are required. This is the flag set recommended by Robolectric, see https://robolectric.org/getting-started/#running-with-java-17-and-higher. Partially Addresses flutter#193404 ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent ea212a2 commit 6d17b57

33 files changed

Lines changed: 204 additions & 29 deletions

File tree

‎packages/camera/camera_android/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.10.12+1
2+
3+
* Updates Robolectric to 4.17 and adds the JVM arguments it requires for unit tests.
4+
15
## 0.10.12
26

37
* Adds support for custom video output path in video recording.

‎packages/camera/camera_android/android/build.gradle.kts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ android {
6666
// sets the heap size to a size large enough to run the robolectric tests across
6767
// multiple SDK levels.
6868
it.jvmArgs("-Xmx4G")
69+
// Recommended flag set starting Robolectric 4.17 for JDK 17+, see
70+
// https://robolectric.org/getting-started/#running-with-java-17-and-higher
71+
it.jvmArgs(
72+
"--add-opens=java.base/java.lang=ALL-UNNAMED",
73+
"--add-opens=java.base/java.util=ALL-UNNAMED",
74+
"--add-opens=java.base/java.io=ALL-UNNAMED",
75+
"--add-opens=java.base/java.net=ALL-UNNAMED",
76+
"--add-opens=java.base/java.security=ALL-UNNAMED",
77+
"--add-opens=java.base/java.text=ALL-UNNAMED",
78+
"--add-opens=java.base/jdk.internal.access=ALL-UNNAMED",
79+
"--add-opens=java.desktop/java.awt.font=ALL-UNNAMED",
80+
"--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
81+
)
6982
}
7083
}
7184
}
@@ -76,5 +89,5 @@ dependencies {
7689
testImplementation("junit:junit:4.13.2")
7790
testImplementation("org.mockito:mockito-core:5.23.0")
7891
testImplementation("androidx.test:core:1.7.0")
79-
testImplementation("org.robolectric:robolectric:4.16")
92+
testImplementation("org.robolectric:robolectric:4.17")
8093
}

‎packages/camera/camera_android/pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Android implementation of the camera plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
55

6-
version: 0.10.12
6+
version: 0.10.12+1
77

88
environment:
99
sdk: ^3.11.0

‎packages/camera/camera_android_camerax/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.7.5+2
2+
3+
* Updates Robolectric to 4.17 and adds the JVM arguments it requires for unit tests.
4+
15
## 0.7.5+1
26

37
* Fix exposure offset slider freezing camera preview and fix setExposureOffset return value.

‎packages/camera/camera_android_camerax/android/build.gradle.kts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ android {
6262
// sets the heap size to a size large enough to run the robolectric tests across
6363
// multiple SDK levels.
6464
it.jvmArgs("-Xmx1G")
65+
// Recommended flag set starting Robolectric 4.17 for JDK 17+, see
66+
// https://robolectric.org/getting-started/#running-with-java-17-and-higher
67+
it.jvmArgs(
68+
"--add-opens=java.base/java.lang=ALL-UNNAMED",
69+
"--add-opens=java.base/java.util=ALL-UNNAMED",
70+
"--add-opens=java.base/java.io=ALL-UNNAMED",
71+
"--add-opens=java.base/java.net=ALL-UNNAMED",
72+
"--add-opens=java.base/java.security=ALL-UNNAMED",
73+
"--add-opens=java.base/java.text=ALL-UNNAMED",
74+
"--add-opens=java.base/jdk.internal.access=ALL-UNNAMED",
75+
"--add-opens=java.desktop/java.awt.font=ALL-UNNAMED",
76+
"--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
77+
)
6578
}
6679
}
6780
}
@@ -86,5 +99,5 @@ dependencies {
8699
testImplementation("org.mockito:mockito-core:5.23.0")
87100
testImplementation("org.mockito:mockito-inline:5.2.0")
88101
testImplementation("androidx.test:core:1.7.0")
89-
testImplementation("org.robolectric:robolectric:4.16")
102+
testImplementation("org.robolectric:robolectric:4.17")
90103
}

‎packages/camera/camera_android_camerax/pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_android_camerax
22
description: Android implementation of the camera plugin using the CameraX library.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.7.5+1
5+
version: 0.7.5+2
66

77
environment:
88
sdk: ^3.12.0

‎packages/file_selector/file_selector_android/CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 0.5.2+12
22

3+
* Updates Robolectric to 4.17 and adds the JVM arguments it requires for unit tests.
34
* Updates minimum supported SDK version to Flutter 3.41/Dart 3.11.
45

56
## 0.5.2+11

‎packages/file_selector/file_selector_android/android/build.gradle.kts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ android {
4949
testImplementation("junit:junit:4.13.2")
5050
testImplementation("org.mockito:mockito-core:5.23.0")
5151
testImplementation("androidx.test:core:1.7.0")
52-
testImplementation("org.robolectric:robolectric:4.16")
52+
testImplementation("org.robolectric:robolectric:4.17")
5353
}
5454

5555
lint {
@@ -68,6 +68,19 @@ android {
6868
events("passed", "skipped", "failed", "standardOut", "standardError")
6969
showStandardStreams = true
7070
}
71+
// Recommended flag set starting Robolectric 4.17 for JDK 17+, see
72+
// https://robolectric.org/getting-started/#running-with-java-17-and-higher
73+
it.jvmArgs(
74+
"--add-opens=java.base/java.lang=ALL-UNNAMED",
75+
"--add-opens=java.base/java.util=ALL-UNNAMED",
76+
"--add-opens=java.base/java.io=ALL-UNNAMED",
77+
"--add-opens=java.base/java.net=ALL-UNNAMED",
78+
"--add-opens=java.base/java.security=ALL-UNNAMED",
79+
"--add-opens=java.base/java.text=ALL-UNNAMED",
80+
"--add-opens=java.base/jdk.internal.access=ALL-UNNAMED",
81+
"--add-opens=java.desktop/java.awt.font=ALL-UNNAMED",
82+
"--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
83+
)
7184
}
7285
}
7386
}

‎packages/file_selector/file_selector_android/pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: file_selector_android
22
description: Android implementation of the file_selector package.
33
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
5-
version: 0.5.2+11
5+
version: 0.5.2+12
66

77
environment:
88
sdk: ^3.12.0

‎packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.21.1
2+
3+
* Updates Robolectric to 4.17 and adds the JVM arguments it requires for unit tests.
4+
15
## 2.21.0
26

37
* Switches to Pigeon's new 'suspend' support for platform communication.

0 commit comments

Comments
 (0)