Skip to content

[espresso] Enable warnings as errors #3414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from 12 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
4 changes: 3 additions & 1 deletion packages/espresso/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## NEXT
## 0.3.0

* Aligns Dart and Flutter SDK constraints.
* Changes the severity of `javac` warnings so that they are treated as errors and fixes the violations.
* Migrates uses of the deprecated `@Beta` annotation to the new `@ExperimentalApi` annotation.
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be first, and have the **BREAKING CHANGE** annotation described at https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#changelog-style

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


## 0.2.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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,
Expand All @@ -130,14 +133,15 @@ public WidgetInteraction check(@Nonnull WidgetAssertion assertion) {
return this;
}

@ExperimentalTestApi()
@SuppressWarnings("unchecked")
private <T> T performInternal(FlutterAction<T> flutterAction) {
checkNotNull(
flutterAction,
"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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -136,6 +139,7 @@ public ListenableFuture<Void> apply(Void readyResult) {
}
}

@ExperimentalTestApi
@VisibleForTesting
void perform(
View flutterView, FlutterTestingProtocol flutterTestingProtocol, UiController uiController) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
public final class AmbiguousWidgetMatcherException extends RuntimeException
implements EspressoException {

private static final long serialVersionUID = 0L;

public AmbiguousWidgetMatcherException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions packages/espresso/example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
2 changes: 1 addition & 1 deletion packages/espresso/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down