diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java index 80718cf363..2c6439737c 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java @@ -6,6 +6,7 @@ import android.view.View; import android.view.inputmethod.EditorInfo; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import io.flutter.Log; import io.flutter.embedding.engine.dart.DartExecutor; import io.flutter.plugin.common.JSONMethodCodec; @@ -41,7 +42,8 @@ public class TextInputChannel { @NonNull public final MethodChannel channel; @Nullable private TextInputMethodHandler textInputMethodHandler; - private final MethodChannel.MethodCallHandler parsingMethodHandler = + @NonNull @VisibleForTesting + final MethodChannel.MethodCallHandler parsingMethodHandler = new MethodChannel.MethodCallHandler() { @Override public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) { @@ -114,6 +116,7 @@ public class TextInputChannel { } textInputMethodHandler.setEditableSizeAndTransform(width, height, matrix); + result.success(null); } catch (JSONException exception) { result.error("error", exception.getMessage(), null); } diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/FlutterTestSuite.java b/engine/src/flutter/shell/platform/android/test/io/flutter/FlutterTestSuite.java index 3fadfb2e85..8d5fb3391a 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/FlutterTestSuite.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/FlutterTestSuite.java @@ -31,6 +31,7 @@ import io.flutter.embedding.engine.systemchannels.DeferredComponentChannelTest; import io.flutter.embedding.engine.systemchannels.KeyEventChannelTest; import io.flutter.embedding.engine.systemchannels.PlatformChannelTest; import io.flutter.embedding.engine.systemchannels.RestorationChannelTest; +import io.flutter.embedding.engine.systemchannels.TextInputChannelTest; import io.flutter.external.FlutterLaunchTests; import io.flutter.plugin.common.BinaryCodecTest; import io.flutter.plugin.common.StandardMessageCodecTest; @@ -98,6 +99,7 @@ import test.io.flutter.embedding.engine.PluginComponentTest; SmokeTest.class, StandardMessageCodecTest.class, StandardMethodCodecTest.class, + TextInputChannelTest.class, TextInputPluginTest.class, }) /** Runs all of the unit tests listed in the {@code @SuiteClasses} annotation. */ diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/engine/systemchannels/TextInputChannelTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/engine/systemchannels/TextInputChannelTest.java new file mode 100644 index 0000000000..007afcda4f --- /dev/null +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/engine/systemchannels/TextInputChannelTest.java @@ -0,0 +1,37 @@ +package io.flutter.embedding.engine.systemchannels; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +import android.annotation.TargetApi; +import io.flutter.embedding.engine.dart.DartExecutor; +import io.flutter.plugin.common.MethodCall; +import io.flutter.plugin.common.MethodChannel; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; + +@Config( + manifest = Config.NONE, + shadows = {}) +@RunWith(RobolectricTestRunner.class) +@TargetApi(24) +public class TextInputChannelTest { + @Test + public void setEditableSizeAndTransformCompletes() throws JSONException { + TextInputChannel textInputChannel = new TextInputChannel(mock(DartExecutor.class)); + textInputChannel.setTextInputMethodHandler(mock(TextInputChannel.TextInputMethodHandler.class)); + JSONObject arguments = new JSONObject(); + arguments.put("width", 100.0); + arguments.put("height", 20.0); + arguments.put("transform", new JSONArray(new double[16])); + MethodCall call = new MethodCall("TextInput.setEditableSizeAndTransform", arguments); + MethodChannel.Result result = mock(MethodChannel.Result.class); + textInputChannel.parsingMethodHandler.onMethodCall(call, result); + verify(result).success(null); + } +} diff --git a/engine/src/flutter/tools/android_lint/project.xml b/engine/src/flutter/tools/android_lint/project.xml index 2b450c5304..35ec5b92ed 100644 --- a/engine/src/flutter/tools/android_lint/project.xml +++ b/engine/src/flutter/tools/android_lint/project.xml @@ -36,6 +36,7 @@ +