Skip to content

Commit eb2fe26

Browse files
[espresso] Enable warnings as errors (flutter#3414)
[espresso] Enable warnings as errors
1 parent 3b29183 commit eb2fe26

File tree

11 files changed

+28
-10
lines changed

11 files changed

+28
-10
lines changed

packages/espresso/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
## NEXT
1+
## 0.3.0
22

3+
* **BREAKING CHANGE**: Migrates uses of the deprecated `@Beta` annotation to the new `@ExperimentalApi` annotation.
4+
* Changes the severity of `javac` warnings so that they are treated as errors and fixes the violations.
35
* Aligns Dart and Flutter SDK constraints.
46

57
## 0.2.1

packages/espresso/android/src/main/java/androidx/test/espresso/flutter/EspressoFlutter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import android.util.Log;
1414
import android.view.View;
15+
import androidx.test.annotation.ExperimentalTestApi;
1516
import androidx.test.espresso.UiController;
1617
import androidx.test.espresso.ViewAction;
1718
import androidx.test.espresso.flutter.action.FlutterViewAction;
@@ -99,6 +100,7 @@ private WidgetInteraction(
99100
* @param widgetActions one or more actions that shall be performed. Cannot be {@code null}.
100101
* @return this interaction for further perform/verification calls.
101102
*/
103+
@ExperimentalTestApi()
102104
public WidgetInteraction perform(@Nonnull final WidgetAction... widgetActions) {
103105
checkNotNull(widgetActions);
104106
for (WidgetAction widgetAction : widgetActions) {
@@ -115,6 +117,7 @@ public WidgetInteraction perform(@Nonnull final WidgetAction... widgetActions) {
115117
* @param assertion a widget assertion that shall be made on the matched Flutter widget. Cannot
116118
* be {@code null}.
117119
*/
120+
@ExperimentalTestApi()
118121
public WidgetInteraction check(@Nonnull WidgetAssertion assertion) {
119122
checkNotNull(
120123
assertion,
@@ -130,14 +133,15 @@ public WidgetInteraction check(@Nonnull WidgetAssertion assertion) {
130133
return this;
131134
}
132135

136+
@ExperimentalTestApi()
133137
@SuppressWarnings("unchecked")
134138
private <T> T performInternal(FlutterAction<T> flutterAction) {
135139
checkNotNull(
136140
flutterAction,
137141
"The action cannot be null. You must specify an action to perform on the matched"
138142
+ " Flutter widget.");
139143
FlutterViewAction<T> flutterViewAction =
140-
new FlutterViewAction(
144+
new FlutterViewAction<>(
141145
widgetMatcher, flutterAction, okHttpClient, idGenerator, taskExecutor);
142146
onView(flutterViewMatcher).perform(flutterViewAction);
143147
T result;

packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/FlutterActions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package androidx.test.espresso.flutter.action;
66

7+
import androidx.test.annotation.ExperimentalTestApi;
78
import androidx.test.espresso.flutter.api.WidgetAction;
89
import java.util.concurrent.ExecutorService;
910
import java.util.concurrent.Executors;
@@ -43,6 +44,7 @@ public static WidgetAction click() {
4344
* by directly injecting key events to the Android system. Uses this {@link #syntheticClick()}
4445
* only when there are special cases that {@link #click()} cannot handle properly.
4546
*/
47+
@ExperimentalTestApi()
4648
public static WidgetAction syntheticClick() {
4749
return new SyntheticClickAction();
4850
}

packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/FlutterViewAction.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import android.os.Looper;
1515
import android.view.View;
16-
import androidx.test.annotation.Beta;
16+
import androidx.test.annotation.ExperimentalTestApi;
1717
import androidx.test.espresso.IdlingRegistry;
1818
import androidx.test.espresso.IdlingResource;
1919
import androidx.test.espresso.UiController;
@@ -47,7 +47,6 @@
4747
* <p>This class acts as a bridge to perform {@code WidgetAction} on a Flutter widget on the given
4848
* {@code FlutterView}.
4949
*/
50-
@Beta
5150
public final class FlutterViewAction<T> implements ViewAction {
5251

5352
private static final String FLUTTER_IDLE_TASK_NAME = "flutterIdlingResource";
@@ -96,6 +95,7 @@ public String getDescription() {
9695
"Perform a %s action on the Flutter widget matched %s.", widgetAction, widgetMatcher);
9796
}
9897

98+
@ExperimentalTestApi
9999
@Override
100100
public void perform(UiController uiController, View flutterView) {
101101
// 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) {
104104
loopUntilFlutterViewRendered(flutterView, uiController);
105105
// The url {@code FlutterNativeView} returns is the http url that the Dart VM Observatory http
106106
// server serves at. Need to convert to the one that the WebSocket uses.
107+
108+
// TODO(stuartmorgan): migrate to getVMServiceUri() once that is available on stable.
109+
@SuppressWarnings("deprecation")
107110
URI dartVmServiceProtocolUrl =
108111
DartVmServiceUtil.getServiceProtocolUri(FlutterJNI.getObservatoryUri());
109112
String isolateId = DartVmServiceUtil.getDartIsolateId(flutterView);
@@ -136,6 +139,7 @@ public ListenableFuture<Void> apply(Void readyResult) {
136139
}
137140
}
138141

142+
@ExperimentalTestApi
139143
@VisibleForTesting
140144
void perform(
141145
View flutterView, FlutterTestingProtocol flutterTestingProtocol, UiController uiController) {

packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/SyntheticClickAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package androidx.test.espresso.flutter.action;
66

77
import android.view.View;
8-
import androidx.test.annotation.Beta;
8+
import androidx.test.annotation.ExperimentalTestApi;
99
import androidx.test.espresso.UiController;
1010
import androidx.test.espresso.flutter.api.FlutterTestingProtocol;
1111
import androidx.test.espresso.flutter.api.SyntheticAction;
@@ -21,9 +21,9 @@
2121
* <p>Note, this is not a real click gesture event issued from Android system. Espresso delegates to
2222
* Flutter engine to perform the {@link SyntheticClick} action.
2323
*/
24-
@Beta
2524
public final class SyntheticClickAction implements WidgetAction {
2625

26+
@ExperimentalTestApi
2727
@Override
2828
public Future<Void> perform(
2929
@Nullable WidgetMatcher targetWidget,

packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/AmbiguousWidgetMatcherException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
public final class AmbiguousWidgetMatcherException extends RuntimeException
1414
implements EspressoException {
1515

16+
private static final long serialVersionUID = 0L;
17+
1618
public AmbiguousWidgetMatcherException(String message) {
1719
super(message);
1820
}

packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/InvalidFlutterViewException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
public final class InvalidFlutterViewException extends RuntimeException
1111
implements EspressoException {
1212

13+
private static final long serialVersionUID = 0L;
14+
1315
/** Constructs with an error message. */
1416
public InvalidFlutterViewException(String message) {
1517
super(message);

packages/espresso/android/src/main/java/androidx/test/espresso/flutter/exception/NoMatchingWidgetException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* hierarchy.
1212
*/
1313
public final class NoMatchingWidgetException extends RuntimeException implements EspressoException {
14+
private static final long serialVersionUID = 0L;
1415

1516
public NoMatchingWidgetException(String message) {
1617
super(message);

packages/espresso/android/src/main/java/androidx/test/espresso/flutter/internal/protocol/impl/FlutterProtocolException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
/** Represents an exception/error relevant to Dart VM service. */
88
public final class FlutterProtocolException extends RuntimeException {
9+
private static final long serialVersionUID = 0L;
910

1011
public FlutterProtocolException(String message) {
1112
super(message);

packages/espresso/example/android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ task clean(type: Delete) {
3535
gradle.projectsEvaluated {
3636
project(":espresso") {
3737
tasks.withType(JavaCompile) {
38-
// TODO(stuartmorgan): Enable this. See
39-
// https://github.com/flutter/flutter/issues/91868
40-
//options.compilerArgs << "-Xlint:all" << "-Werror"
38+
// Ignore classfile warnings due to https://bugs.openjdk.org/browse/JDK-8190452
39+
// TODO(stuartmorgan): Remove that ignore once the build uses Java 11+.
40+
options.compilerArgs << "-Xlint:all" << "-Werror" << "-Xlint:-classfile"
4141
}
4242
}
4343
}

0 commit comments

Comments
 (0)