Skip to content

Commit

Permalink
Revert "Make FlutterFragment usable without requiring it to be attach…
Browse files Browse the repository at this point in the history
…ed to an Android Activity. (flutter#27332)" (flutter#27382)

This reverts commit 317166d.
  • Loading branch information
zanderso authored Jul 14, 2021
1 parent 317166d commit 093c4ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,23 +276,23 @@ View onCreateView(
if (host.getRenderMode() == RenderMode.surface) {
FlutterSurfaceView flutterSurfaceView =
new FlutterSurfaceView(
host.getContext(), host.getTransparencyMode() == TransparencyMode.transparent);
host.getActivity(), host.getTransparencyMode() == TransparencyMode.transparent);

// Allow our host to customize FlutterSurfaceView, if desired.
host.onFlutterSurfaceViewCreated(flutterSurfaceView);

// Create the FlutterView that owns the FlutterSurfaceView.
flutterView = new FlutterView(host.getContext(), flutterSurfaceView);
flutterView = new FlutterView(host.getActivity(), flutterSurfaceView);
} else {
FlutterTextureView flutterTextureView = new FlutterTextureView(host.getContext());
FlutterTextureView flutterTextureView = new FlutterTextureView(host.getActivity());

flutterTextureView.setOpaque(host.getTransparencyMode() == TransparencyMode.opaque);

// Allow our host to customize FlutterSurfaceView, if desired.
host.onFlutterTextureViewCreated(flutterTextureView);

// Create the FlutterView that owns the FlutterTextureView.
flutterView = new FlutterView(host.getContext(), flutterTextureView);
flutterView = new FlutterView(host.getActivity(), flutterTextureView);
}

// Add listener to be notified when Flutter renders its first frame.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,31 +378,21 @@ public void itDoesNotAttachFlutterToTheActivityIfNotDesired() {
// Declare that the host does NOT want Flutter to attach to the surrounding Activity.
when(mockHost.shouldAttachEngineToActivity()).thenReturn(false);

// getActivity() returns null if the activity is not attached
when(mockHost.getActivity()).thenReturn(null);

// Create the real object that we're testing.
FlutterActivityAndFragmentDelegate delegate = new FlutterActivityAndFragmentDelegate(mockHost);

// --- Execute the behavior under test ---
// Flutter is attached to the surrounding Activity in onAttach.
delegate.onAttach(RuntimeEnvironment.application);

// Make sure all of the other lifecycle methods can run safely as well
// without a valid Activity
delegate.onCreateView(null, null, null);
delegate.onStart();
delegate.onResume();
delegate.onPause();
delegate.onStop();
delegate.onDestroyView();
// Verify that the ActivityControlSurface was NOT told to attach to an Activity.
verify(mockFlutterEngine.getActivityControlSurface(), never())
.attachToActivity(any(Activity.class), any(Lifecycle.class));

// Flutter is detached from the surrounding Activity in onDetach.
delegate.onDetach();

// Verify that the ActivityControlSurface was NOT told to attach or detach to an Activity.
verify(mockFlutterEngine.getActivityControlSurface(), never())
.attachToActivity(any(Activity.class), any(Lifecycle.class));
// Verify that the ActivityControlSurface was NOT told to detach from the Activity.
verify(mockFlutterEngine.getActivityControlSurface(), never()).detachFromActivity();
}

Expand Down

0 comments on commit 093c4ed

Please sign in to comment.