Add missing result for the TextInput.setEditableSizeAndTransform method handler on Android (flutter/engine#28376)

This commit is contained in:
Jason Simmons
2021-08-31 14:56:02 -07:00
committed by GitHub
parent c5ca2fdb88
commit 426d5baac8
4 changed files with 44 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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. */

View File

@@ -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);
}
}

View File

@@ -36,6 +36,7 @@
<src file="../../../flutter/shell/platform/android/test/io/flutter/embedding/engine/loader/FlutterLoaderTest.java" />
<src file="../../../flutter/shell/platform/android/test/io/flutter/embedding/engine/loader/ApplicationInfoLoaderTest.java" />
<src file="../../../flutter/shell/platform/android/test/io/flutter/embedding/engine/FlutterEngineGroupComponentTest.java" />
<src file="../../../flutter/shell/platform/android/test/io/flutter/embedding/engine/systemchannels/TextInputChannelTest.java" />
<src file="../../../flutter/shell/platform/android/test/io/flutter/embedding/engine/systemchannels/DeferredComponentChannelTest.java" />
<src file="../../../flutter/shell/platform/android/test/io/flutter/embedding/engine/systemchannels/PlatformChannelTest.java" />
<src file="../../../flutter/shell/platform/android/test/io/flutter/embedding/engine/systemchannels/KeyEventChannelTest.java" />