diff --git a/packages/espresso/CHANGELOG.md b/packages/espresso/CHANGELOG.md index 5fb6e300f0f..5ef1319e9c2 100644 --- a/packages/espresso/CHANGELOG.md +++ b/packages/espresso/CHANGELOG.md @@ -1,5 +1,7 @@ -## NEXT +## 0.3.0 +* **BREAKING CHANGE**: Migrates uses of the deprecated `@Beta` annotation to the new `@ExperimentalApi` annotation. +* Changes the severity of `javac` warnings so that they are treated as errors and fixes the violations. * Aligns Dart and Flutter SDK constraints. ## 0.2.1 diff --git a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/EspressoFlutter.java b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/EspressoFlutter.java index 3ba1762117c..f8644a8e548 100644 --- a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/EspressoFlutter.java +++ b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/EspressoFlutter.java @@ -12,6 +12,7 @@ import android.util.Log; import android.view.View; +import androidx.test.annotation.ExperimentalTestApi; import androidx.test.espresso.UiController; import androidx.test.espresso.ViewAction; import androidx.test.espresso.flutter.action.FlutterViewAction; @@ -99,6 +100,7 @@ private WidgetInteraction( * @param widgetActions one or more actions that shall be performed. Cannot be {@code null}. * @return this interaction for further perform/verification calls. */ + @ExperimentalTestApi() public WidgetInteraction perform(@Nonnull final WidgetAction... widgetActions) { checkNotNull(widgetActions); for (WidgetAction widgetAction : widgetActions) { @@ -115,6 +117,7 @@ public WidgetInteraction perform(@Nonnull final WidgetAction... widgetActions) { * @param assertion a widget assertion that shall be made on the matched Flutter widget. Cannot * be {@code null}. */ + @ExperimentalTestApi() public WidgetInteraction check(@Nonnull WidgetAssertion assertion) { checkNotNull( assertion, @@ -130,6 +133,7 @@ public WidgetInteraction check(@Nonnull WidgetAssertion assertion) { return this; } + @ExperimentalTestApi() @SuppressWarnings("unchecked") private T performInternal(FlutterAction flutterAction) { checkNotNull( @@ -137,7 +141,7 @@ private T performInternal(FlutterAction flutterAction) { "The action cannot be null. You must specify an action to perform on the matched" + " Flutter widget."); FlutterViewAction flutterViewAction = - new FlutterViewAction( + new FlutterViewAction<>( widgetMatcher, flutterAction, okHttpClient, idGenerator, taskExecutor); onView(flutterViewMatcher).perform(flutterViewAction); T result; diff --git a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/FlutterActions.java b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/FlutterActions.java index 2f0c171e780..1bc41f01fa6 100644 --- a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/FlutterActions.java +++ b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/FlutterActions.java @@ -4,6 +4,7 @@ package androidx.test.espresso.flutter.action; +import androidx.test.annotation.ExperimentalTestApi; import androidx.test.espresso.flutter.api.WidgetAction; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -43,6 +44,7 @@ public static WidgetAction click() { * by directly injecting key events to the Android system. Uses this {@link #syntheticClick()} * only when there are special cases that {@link #click()} cannot handle properly. */ + @ExperimentalTestApi() public static WidgetAction syntheticClick() { return new SyntheticClickAction(); } diff --git a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/FlutterViewAction.java b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/FlutterViewAction.java index 7031915f1ca..6f6bc74caf7 100644 --- a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/FlutterViewAction.java +++ b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/FlutterViewAction.java @@ -13,7 +13,7 @@ import android.os.Looper; import android.view.View; -import androidx.test.annotation.Beta; +import androidx.test.annotation.ExperimentalTestApi; import androidx.test.espresso.IdlingRegistry; import androidx.test.espresso.IdlingResource; import androidx.test.espresso.UiController; @@ -47,7 +47,6 @@ *

This class acts as a bridge to perform {@code WidgetAction} on a Flutter widget on the given * {@code FlutterView}. */ -@Beta public final class FlutterViewAction implements ViewAction { private static final String FLUTTER_IDLE_TASK_NAME = "flutterIdlingResource"; @@ -96,6 +95,7 @@ public String getDescription() { "Perform a %s action on the Flutter widget matched %s.", widgetAction, widgetMatcher); } + @ExperimentalTestApi @Override public void perform(UiController uiController, View flutterView) { // There could be a gap between when the Flutter view is available in the view hierarchy and the @@ -104,6 +104,9 @@ public void perform(UiController uiController, View flutterView) { loopUntilFlutterViewRendered(flutterView, uiController); // The url {@code FlutterNativeView} returns is the http url that the Dart VM Observatory http // server serves at. Need to convert to the one that the WebSocket uses. + + // TODO(stuartmorgan): migrate to getVMServiceUri() once that is available on stable. + @SuppressWarnings("deprecation") URI dartVmServiceProtocolUrl = DartVmServiceUtil.getServiceProtocolUri(FlutterJNI.getObservatoryUri()); String isolateId = DartVmServiceUtil.getDartIsolateId(flutterView); @@ -136,6 +139,7 @@ public ListenableFuture apply(Void readyResult) { } } + @ExperimentalTestApi @VisibleForTesting void perform( View flutterView, FlutterTestingProtocol flutterTestingProtocol, UiController uiController) { diff --git a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/SyntheticClickAction.java b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/SyntheticClickAction.java index fa238cbe76c..270d4e43b88 100644 --- a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/SyntheticClickAction.java +++ b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/SyntheticClickAction.java @@ -5,7 +5,7 @@ package androidx.test.espresso.flutter.action; import android.view.View; -import androidx.test.annotation.Beta; +import androidx.test.annotation.ExperimentalTestApi; import androidx.test.espresso.UiController; import androidx.test.espresso.flutter.api.FlutterTestingProtocol; import androidx.test.espresso.flutter.api.SyntheticAction; @@ -21,9 +21,9 @@ *

Note, this is not a real click gesture event issued from Android system. Espresso delegates to * Flutter engine to perform the {@link SyntheticClick} action. */ -@Beta public final class SyntheticClickAction implements WidgetAction { + @ExperimentalTestApi @Override public Future perform( @Nullable WidgetMatcher targetWidget, diff --git a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/AmbiguousWidgetMatcherException.java b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/AmbiguousWidgetMatcherException.java index c0f1a06f573..01fedba7de4 100644 --- a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/AmbiguousWidgetMatcherException.java +++ b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/AmbiguousWidgetMatcherException.java @@ -13,6 +13,8 @@ public final class AmbiguousWidgetMatcherException extends RuntimeException implements EspressoException { + private static final long serialVersionUID = 0L; + public AmbiguousWidgetMatcherException(String message) { super(message); } diff --git a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/InvalidFlutterViewException.java b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/InvalidFlutterViewException.java index d2d32869dd6..39f442ad314 100644 --- a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/InvalidFlutterViewException.java +++ b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/InvalidFlutterViewException.java @@ -10,6 +10,8 @@ public final class InvalidFlutterViewException extends RuntimeException implements EspressoException { + private static final long serialVersionUID = 0L; + /** Constructs with an error message. */ public InvalidFlutterViewException(String message) { super(message); diff --git a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/NoMatchingWidgetException.java b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/NoMatchingWidgetException.java index 756710f790c..93da4d29ee9 100644 --- a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/NoMatchingWidgetException.java +++ b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/NoMatchingWidgetException.java @@ -11,6 +11,7 @@ * hierarchy. */ public final class NoMatchingWidgetException extends RuntimeException implements EspressoException { + private static final long serialVersionUID = 0L; public NoMatchingWidgetException(String message) { super(message); diff --git a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/internal/protocol/impl/FlutterProtocolException.java b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/internal/protocol/impl/FlutterProtocolException.java index 26865a31098..2ad61cff2ec 100644 --- a/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/internal/protocol/impl/FlutterProtocolException.java +++ b/packages/espresso/android/src/main/java/androidx/test/espresso/flutter/internal/protocol/impl/FlutterProtocolException.java @@ -6,6 +6,7 @@ /** Represents an exception/error relevant to Dart VM service. */ public final class FlutterProtocolException extends RuntimeException { + private static final long serialVersionUID = 0L; public FlutterProtocolException(String message) { super(message); diff --git a/packages/espresso/example/android/build.gradle b/packages/espresso/example/android/build.gradle index 10fc8d91f5f..39a84da55e8 100644 --- a/packages/espresso/example/android/build.gradle +++ b/packages/espresso/example/android/build.gradle @@ -35,9 +35,9 @@ task clean(type: Delete) { gradle.projectsEvaluated { project(":espresso") { tasks.withType(JavaCompile) { - // TODO(stuartmorgan): Enable this. See - // https://github.com/flutter/flutter/issues/91868 - //options.compilerArgs << "-Xlint:all" << "-Werror" + // Ignore classfile warnings due to https://bugs.openjdk.org/browse/JDK-8190452 + // TODO(stuartmorgan): Remove that ignore once the build uses Java 11+. + options.compilerArgs << "-Xlint:all" << "-Werror" << "-Xlint:-classfile" } } } diff --git a/packages/espresso/pubspec.yaml b/packages/espresso/pubspec.yaml index fb2cbfcd648..c7fcbd3ae44 100644 --- a/packages/espresso/pubspec.yaml +++ b/packages/espresso/pubspec.yaml @@ -3,7 +3,7 @@ description: Java classes for testing Flutter apps using Espresso. Allows driving Flutter widgets from a native Espresso test. repository: https://github.com/flutter/packages/tree/main/packages/espresso issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+espresso%22 -version: 0.2.1 +version: 0.3.0 environment: sdk: ">=2.17.0 <3.0.0"