Skip to content

Commit

Permalink
more test cleanups and fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahwilliams committed Nov 25, 2024
1 parent 8e525ba commit ec0f7b1
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,8 @@ public void attachToFlutterEngine(@NonNull FlutterEngine flutterEngine) {
this,
this.flutterEngine.getTextInputChannel(),
this.flutterEngine.getScribeChannel(),
this.flutterEngine.getPlatformViewsController());
this.flutterEngine.getPlatformViewsController(),
this.flutterEngine.getPlatformViewsController2());

try {
textServicesManager =
Expand Down Expand Up @@ -1226,9 +1227,11 @@ public void detachFromFlutterEngine() {
getContext().getContentResolver().unregisterContentObserver(systemSettingsObserver);

flutterEngine.getPlatformViewsController().detachFromView();
flutterEngine.getPlatformViewsController2().detachFromView();

// Disconnect the FlutterEngine's PlatformViewsController from the AccessibilityBridge.
flutterEngine.getPlatformViewsController().detachAccessibilityBridge();
flutterEngine.getPlatformViewsController2().detachAccessibilityBridge();

// Disconnect and clean up the AccessibilityBridge.
accessibilityBridge.release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import io.flutter.embedding.engine.systemchannels.TextInputChannel;
import io.flutter.embedding.engine.systemchannels.TextInputChannel.TextEditState;
import io.flutter.plugin.platform.PlatformViewsController;
import io.flutter.plugin.platform.PlatformViewsController2;
import java.util.ArrayList;
import java.util.HashMap;

Expand All @@ -52,6 +53,7 @@ public class TextInputPlugin implements ListenableEditingState.EditingStateWatch
private boolean mRestartInputPending;
@Nullable private InputConnection lastInputConnection;
@NonNull private PlatformViewsController platformViewsController;
@NonNull private PlatformViewsController2 platformViewsController2;
@Nullable private Rect lastClientRect;
private ImeSyncDeferringInsetsCallback imeSyncCallback;

Expand All @@ -69,7 +71,8 @@ public TextInputPlugin(
@NonNull View view,
@NonNull TextInputChannel textInputChannel,
@NonNull ScribeChannel scribeChannel,
@NonNull PlatformViewsController platformViewsController) {
@NonNull PlatformViewsController platformViewsController,
@NonNull PlatformViewsController2 platformViewsController2) {
mView = view;
// Create a default object.
mEditable = new ListenableEditingState(null, mView);
Expand Down Expand Up @@ -160,6 +163,8 @@ public void sendAppPrivateCommand(String action, Bundle data) {

this.platformViewsController = platformViewsController;
this.platformViewsController.attachTextInputPlugin(this);
this.platformViewsController2 = platformViewsController2;
this.platformViewsController2.attachTextInputPlugin(this);
}

@NonNull
Expand Down Expand Up @@ -215,6 +220,7 @@ public void unlockPlatformViewInputConnection() {
@SuppressLint("NewApi")
public void destroy() {
platformViewsController.detachTextInputPlugin();
platformViewsController2.detachTextInputPlugin();
textInputChannel.setTextInputMethodHandler(null);
notifyViewExited();
mEditable.removeEditingStateListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,10 @@ public FlutterOverlaySurface createOverlaySurface() {
}

public void destroyOverlaySurface() {
overlayerSurface.release();
overlayerSurface = null;
if (overlayerSurface != null) {
overlayerSurface.release();
overlayerSurface = null;
}
}

//// Message Handler ///////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import io.flutter.embedding.engine.systemchannels.TextInputChannel;
import io.flutter.plugin.localization.LocalizationPlugin;
import io.flutter.plugin.platform.PlatformViewsController;
import io.flutter.plugin.platform.PlatformViewsController2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -1475,6 +1476,7 @@ private FlutterEngine mockFlutterEngine() {
when(engine.getNavigationChannel()).thenReturn(mock(NavigationChannel.class));
when(engine.getBackGestureChannel()).thenReturn(mock(BackGestureChannel.class));
when(engine.getPlatformViewsController()).thenReturn(mock(PlatformViewsController.class));
when(engine.getPlatformViewsController2()).thenReturn(mock(PlatformViewsController2.class));

FlutterRenderer renderer = mock(FlutterRenderer.class);
when(engine.getRenderer()).thenReturn(renderer);
Expand Down
Loading

0 comments on commit ec0f7b1

Please sign in to comment.