[espresso] Enable warnings as errors (#3414)
[espresso] Enable warnings as errors
diff --git a/packages/espresso/CHANGELOG.md b/packages/espresso/CHANGELOG.md
index 5fb6e30..5ef1319 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 3ba1762..f8644a8 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 @@
* @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 @@
* @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 @@
return this;
}
+ @ExperimentalTestApi()
@SuppressWarnings("unchecked")
private <T> T performInternal(FlutterAction<T> flutterAction) {
checkNotNull(
@@ -137,7 +141,7 @@
"The action cannot be null. You must specify an action to perform on the matched"
+ " Flutter widget.");
FlutterViewAction<T> 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 2f0c171..1bc41f0 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 @@
* 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 7031915..6f6bc74 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 @@
* <p>This class acts as a bridge to perform {@code WidgetAction} on a Flutter widget on the given
* {@code FlutterView}.
*/
-@Beta
public final class FlutterViewAction<T> implements ViewAction {
private static final String FLUTTER_IDLE_TASK_NAME = "flutterIdlingResource";
@@ -96,6 +95,7 @@
"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 @@
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 @@
}
}
+ @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 fa238cb..270d4e4 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 @@
* <p>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<Void> 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 c0f1a06..01fedba 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 d2d3286..39f442a 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 756710f..93da4d2 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 26865a3..2ad61cf 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 10fc8d9..39a84da 100644
--- a/packages/espresso/example/android/build.gradle
+++ b/packages/espresso/example/android/build.gradle
@@ -35,9 +35,9 @@
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 fb2cbfc..c7fcbd3 100644
--- a/packages/espresso/pubspec.yaml
+++ b/packages/espresso/pubspec.yaml
@@ -3,7 +3,7 @@
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"