Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[Espresso] Android Code Inspection and Clean up #3111

Merged
merged 11 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all 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: 4 additions & 0 deletions packages/espresso/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.1+8

* Android: Handle deprecation & unchecked warning as error.

## 0.0.1+7

* Update android compileSdkVersion to 29.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public WidgetInteraction check(@Nonnull WidgetAssertion assertion) {
return this;
}

@SuppressWarnings("unchecked")
private <T> T performInternal(FlutterAction<T> flutterAction) {
checkNotNull(
flutterAction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import io.flutter.embedding.android.FlutterView;
import io.flutter.view.FlutterNativeView;
import io.flutter.embedding.engine.FlutterJNI;
import java.net.URI;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
Expand Down Expand Up @@ -105,7 +105,7 @@ public void perform(UiController uiController, View flutterView) {
// 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.
URI dartVmServiceProtocolUrl =
DartVmServiceUtil.getServiceProtocolUri(FlutterNativeView.getObservatoryUri());
DartVmServiceUtil.getServiceProtocolUri(FlutterJNI.getObservatoryUri());
String isolateId = DartVmServiceUtil.getDartIsolateId(flutterView);
final FlutterTestingProtocol flutterTestingProtocol =
new DartVmService(
Expand Down Expand Up @@ -199,6 +199,7 @@ public String getName() {
return FlutterViewRenderedIdlingResource.class.getSimpleName();
}

@SuppressWarnings("deprecation")
Copy link
Member

Choose a reason for hiding this comment

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

put the lint on the specific lines that accesses io.flutter.view.FlutterView

@Override
public boolean isIdleNow() {
boolean isIdle = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -360,10 +359,9 @@ boolean isTestingApiRegistered(JsonRpcResponse isolateInfoResp) {
isolateId, isolateInfoResp.getError()));
return false;
}
Iterator<JsonElement> extensions =
isolateInfoResp.getResult().get(EXTENSION_RPCS_TAG).getAsJsonArray().iterator();
while (extensions.hasNext()) {
String extensionApi = extensions.next().getAsString();
for (JsonElement jsonElement :
isolateInfoResp.getResult().get(EXTENSION_RPCS_TAG).getAsJsonArray()) {
String extensionApi = jsonElement.getAsString();
if (TESTING_EXTENSION_METHOD.equals(extensionApi)) {
Log.d(
TAG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public static String getDartIsolateId(View flutterView) {
}

/** Gets the Dart executor for the given {@code flutterView}. */
@SuppressWarnings("deprecation")
Copy link
Member

Choose a reason for hiding this comment

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

ditto here

Copy link
Member Author

Choose a reason for hiding this comment

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

PR Updated with requested changes . Thank you

public static DartExecutor getDartExecutor(View flutterView) {
checkNotNull(flutterView, "The Flutter View instance cannot be null.");
// Flutter's embedding is in the phase of rewriting/refactoring. Let's be compatible with both
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void describeTo(Description description) {
description.appendText("is a FlutterView");
}

@SuppressWarnings("deprecation")
@Override
public boolean matchesSafely(View flutterView) {
return flutterView instanceof FlutterView
Expand Down
2 changes: 1 addition & 1 deletion packages/espresso/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.espresso_example"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
2 changes: 1 addition & 1 deletion packages/espresso/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: espresso
description: Java classes for testing Flutter apps using Espresso.
version: 0.0.1+7
version: 0.0.1+8
homepage: https://github.com/flutter/plugins/espresso

environment:
Expand Down