未验证 提交 40167b68 编写于 作者: X xster 提交者: GitHub

Make robolectric tests run against SDK 29 by default (#17996)

上级 2ab918c1
......@@ -138,7 +138,7 @@ allowed_hosts = [
]
deps = {
'src': 'https://github.com/flutter/buildroot.git' + '@' + '71c54fdf2bcb63c70217c0beb8deec73787439b4',
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'e32b5c320d36bdb7a21ecfc7a2f86787f63e8dd6',
# Fuchsia compatibility
#
......
......@@ -782,6 +782,7 @@ FILE: ../../../flutter/shell/platform/android/platform_view_android.cc
FILE: ../../../flutter/shell/platform/android/platform_view_android.h
FILE: ../../../flutter/shell/platform/android/platform_view_android_jni.cc
FILE: ../../../flutter/shell/platform/android/platform_view_android_jni.h
FILE: ../../../flutter/shell/platform/android/robolectric.properties
FILE: ../../../flutter/shell/platform/android/vsync_waiter_android.cc
FILE: ../../../flutter/shell/platform/android/vsync_waiter_android.h
FILE: ../../../flutter/shell/platform/common/cpp/client_wrapper/basic_message_channel_unittests.cc
......
......@@ -455,6 +455,8 @@ action("robolectric_tests") {
jar_path + ".md5.stamp",
]
additional_jar_files = [ "robolectric.properties" ]
_jar_dependencies = [
android_sdk_jar,
embedding_jar_path,
......@@ -462,16 +464,20 @@ action("robolectric_tests") {
inputs = _jar_dependencies
_rebased_current_path = rebase_path(".")
_rebased_jar_path = rebase_path(jar_path, root_build_dir)
_rebased_depfile = rebase_path(depfile, root_build_dir)
_rebased_classpath = rebase_path(_jar_dependencies, root_build_dir)
_rebased_srcjars = rebase_path(_jar_dependencies, root_build_dir)
_rebased_additional_files = rebase_path(additional_jar_files, root_build_dir)
args = [
"--depfile=$_rebased_depfile",
"--jar-path=$_rebased_jar_path",
"--classpath=$_rebased_classpath",
"--jar-source-base-dir=$_rebased_current_path",
"--java-srcjars=$_rebased_srcjars",
"--additional-jar-files=$_rebased_additional_files",
]
args += rebase_path(sources, root_build_dir)
......
......@@ -14,9 +14,11 @@ Once you have updated the dependencies, you can upload a new version by running
`cipd create --pkg-def cipd.yaml`. For more, see the Chromium instructions on ["Updating a CIPD
dependency"](https://chromium.googlesource.com/chromium/src/+/master/docs/cipd.md#Updating-a-CIPD-dependency) for how to upload a package update to CIPD.
Once you've uploaded the new version, also make sure to tag it with the updated
timestamp and robolectric version (most likely still 3.8, unless you've migrated
all the packages to 4+).
On successful upload, you will receive a hash for the upload such as
`cipd: successfully uploaded and verified flutter/android/embedding_bundle:NZvE-rL3E66nHQZb5Vyl9-1Y_1MWEX7KURgOHqX2cYcC`
Let's further annotate the new upload with the current timestamp.
$ cipd set-tag flutter/android/embedding_bundle --version=<new_version_hash> -tag=last_updated:<timestamp>
......
......@@ -33,7 +33,7 @@ configurations {
embedding
// Use any of these configurations for dependencies required for testing the embedding.
embeddingTesting
embeddingTesting_duplicated
embeddingTesting_v16
}
android {
......@@ -49,9 +49,13 @@ android {
embedding "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
// Testing
// TODO(xster): remove these android-all compile time dependencies.
// Use https://github.com/robolectric/robolectric/blob/master/robolectric/src/main/java/org/robolectric/plugins/LegacyDependencyResolver.java#L24
// and specify them as runtime dependencies.
embeddingTesting "org.robolectric:android-all:8.1.0-robolectric-4611349"
// This is required by the robolectric test.
embeddingTesting_duplicated "org.robolectric:android-all:4.1.2_r1-robolectric-r1"
// Get robolectric shadows for SDK=16 used by PlatformPluginTest.
embeddingTesting_v16 "org.robolectric:android-all:4.1.2_r1-robolectric-r1"
embeddingTesting "androidx.fragment:fragment-testing:1.1.0"
embeddingTesting "org.mockito:mockito-all:1.10.19"
embeddingTesting ("org.robolectric:robolectric:4.3") {
// org.hamcrest is added by org.mockito:mockito-all
......@@ -71,7 +75,7 @@ task updateDependencies() {
copy {
from configurations.embedding
from configurations.embeddingTesting
from configurations.embeddingTesting_duplicated
from configurations.embeddingTesting_v16
into destinationDir
}
doLast {
......
# Match the value at shell/platform/android/embedding_bundle/build.gradle.
sdk=29
......@@ -22,14 +22,6 @@ integration tests in other repos.
## Q&A
### Why are we using Robolectric 3.8 when Robolectric 4+ is current?
Robolectric 4+ uses the AndroidX libraries, and the engine sources use the
deprecated android.support ones. See
[flutter/flutter#23586](https://github.com/flutter/flutter/issues/23586). If
this is an issue we could use Jetifier on `flutter.jar` first and _then_ run
the tests, but it would add an extra point of failure.
### My new test won't run. There's a "ClassNotFoundException".
See [Updating Embedding Dependencies](../embedding_bundle).
......
......@@ -37,13 +37,9 @@ import org.robolectric.annotation.Config;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
// TODO(xster): we have 2 versions of robolectric Android shadows in
// shell/platform/android/embedding_bundle/build.gradle. Remove the older
// org.robolectric:android-all:4.1.2_r1-robolectric-r1 which doesn't have the right shadow
// behaviors.
@Config(manifest = Config.NONE, sdk = 27)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
@TargetApi(27)
@TargetApi(29)
public class FlutterViewTest {
@Mock FlutterJNI mockFlutterJni;
@Mock FlutterLoader mockFlutterLoader;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册