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

Commit

Permalink
[Espresso] Android Code Inspection and Clean up (#3111)
Browse files Browse the repository at this point in the history
* Remove unchecked  && deprecated Warnings

* Remove settings_aar.gradle

* Update CHANGELOG.md

* Fix Format

* Fix Format

* espresso

* Format

* SuppressWarnings
  • Loading branch information
hamdikahloun authored Dec 4, 2020
1 parent 9fef1c7 commit f9d5525
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 9 deletions.
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")
@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")
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

0 comments on commit f9d5525

Please sign in to comment.