Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion shell/platform/android/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ integration tests in other repos.
`FlutterTestSuite.java`. This makes sure the test is actually executed at
run time.
4. Write your test.
5. Build and run with `testing/run_tests.py [--type=java] [--java-filter=<test_class_name>]`.
5. Build and run with `testing/run_tests.py [--type=java] [--java-filter=<test_class_name>] [--ignore-android-deprecations]`.

## Q&A

Expand Down
9 changes: 9 additions & 0 deletions shell/platform/android/test_runner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ apply plugin: "com.android.library"

rootProject.buildDir = project.property("build_dir")

// Shows warnings for usage of deprecated API usages unless otherwise specified.
def ignoreDeprecations = project.findProperty('ignore-deprecations')
gradle.projectsEvaluated {
if (!ignoreDeprecations.toBoolean()) {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
}

android {
compileSdkVersion 31
Expand Down
8 changes: 6 additions & 2 deletions testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def JavaBin():
return os.path.join(JavaHome(), 'bin', 'java.exe' if IsWindows() else 'java')


def RunJavaTests(filter, android_variant='android_debug_unopt'):
def RunJavaTests(filter, android_variant='android_debug_unopt', ignore_android_deprecations=False):
"""Runs the Java JUnit unit tests for the Android embedding"""
test_runner_dir = os.path.join(buildroot_dir, 'flutter', 'shell', 'platform', 'android', 'test_runner')
gradle_bin = os.path.join(buildroot_dir, 'gradle', 'bin', 'gradle.bat' if IsWindows() else 'gradle')
Expand All @@ -336,10 +336,12 @@ def RunJavaTests(filter, android_variant='android_debug_unopt'):
gradle_cache_dir = os.path.join(out_dir, android_variant, 'robolectric_tests', '.gradle')

test_class = filter if filter else 'io.flutter.FlutterTestSuite'

command = [
gradle_bin,
'-Pflutter_jar=%s' % flutter_jar,
'-Pbuild_dir=%s' % build_dir,
'-Pignore-deprecations=%s' % ignore_android_deprecations,
'testDebugUnitTest',
'--tests=%s' % test_class,
'--rerun-tasks',
Expand Down Expand Up @@ -567,6 +569,8 @@ def main():
default=False, help='Provide the sanitizer suppressions lists to the via environment to the tests.')
parser.add_argument('--adb-path', dest='adb_path', action='store',
default=None, help='Provide the path of adb used for android tests. By default it looks on $PATH.')
parser.add_argument('--ignore-android-deprecations', dest='ignore_android_deprecations', help='Hide warnings concerning usage of deprecated APIs when running Android tests',
action="store_true", default=False)

args = parser.parse_args()

Expand Down Expand Up @@ -613,7 +617,7 @@ def main():
if ',' in java_filter or '*' in java_filter:
print('Can only filter JUnit4 tests by single entire class name, eg "io.flutter.SmokeTest". Ignoring filter=' + java_filter)
java_filter = None
RunJavaTests(java_filter, args.android_variant)
RunJavaTests(java_filter, args.android_variant, args.ignore_android_deprecations)

if 'android' in types:
assert not IsWindows(), "Android engine files can't be compiled on Windows."
Expand Down