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 4 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>] [--show-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 if specified.
def showDeprecations = project.findProperty('show-deprecations')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to turn it on by default? Btw, how is the output different when this flag is passed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I can turn it on by default, but just FYI there are 100 deprecation warnings right now! Those print out before the tests are executed and the results are printed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems fine, if we don't turn it on, we will never migrate off of the deprecated API haha. If it prints before, we can still see test results easily at bottom of the output.

gradle.projectsEvaluated {
if (showDeprecations) {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
}

android {
compileSdkVersion 31
Expand Down
9 changes: 7 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', show_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,13 @@ 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'
show_deprecations = 'true' if show_deprecations else ''

command = [
gradle_bin,
'-Pflutter_jar=%s' % flutter_jar,
'-Pbuild_dir=%s' % build_dir,
'-Pshow-deprecations=%s' % show_deprecations,
'testDebugUnitTest',
'--tests=%s' % test_class,
'--rerun-tasks',
Expand Down Expand Up @@ -567,6 +570,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('--show-deprecations', dest='show_deprecations', help='Show warnings concerning usage of deprecated APIs when running Android tests',
action="store_true")

args = parser.parse_args()

Expand Down Expand Up @@ -613,7 +618,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.show_deprecations)

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