Makes android embedding to send full uri (flutter/engine#41836)
related https://github.com/flutter/flutter/issues/100624 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -525,16 +525,7 @@ import java.util.List;
|
||||
if (host.shouldHandleDeeplinking()) {
|
||||
Uri data = intent.getData();
|
||||
if (data != null) {
|
||||
String fullRoute = data.getPath();
|
||||
if (fullRoute != null && !fullRoute.isEmpty()) {
|
||||
if (data.getQuery() != null && !data.getQuery().isEmpty()) {
|
||||
fullRoute += "?" + data.getQuery();
|
||||
}
|
||||
if (data.getFragment() != null && !data.getFragment().isEmpty()) {
|
||||
fullRoute += "#" + data.getFragment();
|
||||
}
|
||||
return fullRoute;
|
||||
}
|
||||
return data.toString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -309,7 +309,7 @@ public class FlutterActivityAndFragmentDelegateTest {
|
||||
ArgumentCaptor<FlutterEngineGroup.Options> optionsCaptor =
|
||||
ArgumentCaptor.forClass(FlutterEngineGroup.Options.class);
|
||||
verify(flutterEngineGroup, times(1)).createAndRunEngine(optionsCaptor.capture());
|
||||
assertEquals("/initial_route", optionsCaptor.getValue().getInitialRoute());
|
||||
assertEquals("foo://example.com/initial_route", optionsCaptor.getValue().getInitialRoute());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -688,7 +688,7 @@ public class FlutterActivityAndFragmentDelegateTest {
|
||||
|
||||
// Verify that the navigation channel was given the initial route message.
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1))
|
||||
.setInitialRoute("/custom/route?query=test");
|
||||
.setInitialRoute("http://myApp/custom/route?query=test");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -716,7 +716,7 @@ public class FlutterActivityAndFragmentDelegateTest {
|
||||
|
||||
// Verify that the navigation channel was given the initial route message.
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1))
|
||||
.setInitialRoute("/custom/route?query=test#fragment");
|
||||
.setInitialRoute("http://myApp/custom/route?query=test#fragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -744,7 +744,7 @@ public class FlutterActivityAndFragmentDelegateTest {
|
||||
|
||||
// Verify that the navigation channel was given the initial route message.
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1))
|
||||
.setInitialRoute("/custom/route#fragment");
|
||||
.setInitialRoute("http://myApp/custom/route#fragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -771,7 +771,8 @@ public class FlutterActivityAndFragmentDelegateTest {
|
||||
delegate.onStart();
|
||||
|
||||
// Verify that the navigation channel was given the initial route message.
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1)).setInitialRoute("/custom/route");
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1))
|
||||
.setInitialRoute("http://myApp/custom/route");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -809,19 +810,19 @@ public class FlutterActivityAndFragmentDelegateTest {
|
||||
// --- Execute the behavior under test ---
|
||||
// The FlutterEngine is set up in onAttach().
|
||||
delegate.onAttach(ctx);
|
||||
String expected = "http://myApp/custom/route?query=test";
|
||||
|
||||
Intent mockIntent = mock(Intent.class);
|
||||
when(mockIntent.getData()).thenReturn(Uri.parse("http://myApp/custom/route?query=test"));
|
||||
when(mockIntent.getData()).thenReturn(Uri.parse(expected));
|
||||
// Emulate the host and call the method that we expect to be forwarded.
|
||||
delegate.onNewIntent(mockIntent);
|
||||
|
||||
// Verify that the navigation channel was given the push route message.
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1))
|
||||
.pushRouteInformation("/custom/route?query=test");
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1)).pushRouteInformation(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itDoesNotSendPushRouteInformationMessageWhenOnNewIntentIsNonHierarchicalUri() {
|
||||
public void itDoesSendPushRouteInformationMessageWhenOnNewIntentIsNonHierarchicalUri() {
|
||||
when(mockHost.shouldHandleDeeplinking()).thenReturn(true);
|
||||
// Create the real object that we're testing.
|
||||
FlutterActivityAndFragmentDelegate delegate = new FlutterActivityAndFragmentDelegate(mockHost);
|
||||
@@ -839,7 +840,7 @@ public class FlutterActivityAndFragmentDelegateTest {
|
||||
delegate.onNewIntent(mockIntent);
|
||||
|
||||
// Verify that the navigation channel was not given a push route message.
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(0))
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1))
|
||||
.pushRouteInformation("mailto:test@test.com");
|
||||
}
|
||||
|
||||
@@ -852,16 +853,15 @@ public class FlutterActivityAndFragmentDelegateTest {
|
||||
// --- Execute the behavior under test ---
|
||||
// The FlutterEngine is set up in onAttach().
|
||||
delegate.onAttach(ctx);
|
||||
String expected = "http://myApp/custom/route?query=test#fragment";
|
||||
|
||||
Intent mockIntent = mock(Intent.class);
|
||||
when(mockIntent.getData())
|
||||
.thenReturn(Uri.parse("http://myApp/custom/route?query=test#fragment"));
|
||||
when(mockIntent.getData()).thenReturn(Uri.parse(expected));
|
||||
// Emulate the host and call the method that we expect to be forwarded.
|
||||
delegate.onNewIntent(mockIntent);
|
||||
|
||||
// Verify that the navigation channel was given the push route message.
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1))
|
||||
.pushRouteInformation("/custom/route?query=test#fragment");
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1)).pushRouteInformation(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -873,15 +873,15 @@ public class FlutterActivityAndFragmentDelegateTest {
|
||||
// --- Execute the behavior under test ---
|
||||
// The FlutterEngine is set up in onAttach().
|
||||
delegate.onAttach(ctx);
|
||||
String expected = "http://myApp/custom/route#fragment";
|
||||
|
||||
Intent mockIntent = mock(Intent.class);
|
||||
when(mockIntent.getData()).thenReturn(Uri.parse("http://myApp/custom/route#fragment"));
|
||||
when(mockIntent.getData()).thenReturn(Uri.parse(expected));
|
||||
// Emulate the host and call the method that we expect to be forwarded.
|
||||
delegate.onNewIntent(mockIntent);
|
||||
|
||||
// Verify that the navigation channel was given the push route message.
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1))
|
||||
.pushRouteInformation("/custom/route#fragment");
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1)).pushRouteInformation(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -893,15 +893,15 @@ public class FlutterActivityAndFragmentDelegateTest {
|
||||
// --- Execute the behavior under test ---
|
||||
// The FlutterEngine is set up in onAttach().
|
||||
delegate.onAttach(ctx);
|
||||
String expected = "http://myApp/custom/route#fragment";
|
||||
|
||||
Intent mockIntent = mock(Intent.class);
|
||||
when(mockIntent.getData()).thenReturn(Uri.parse("http://myApp/custom/route"));
|
||||
when(mockIntent.getData()).thenReturn(Uri.parse(expected));
|
||||
// Emulate the host and call the method that we expect to be forwarded.
|
||||
delegate.onNewIntent(mockIntent);
|
||||
|
||||
// Verify that the navigation channel was given the push route message.
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1))
|
||||
.pushRouteInformation("/custom/route");
|
||||
verify(mockFlutterEngine.getNavigationChannel(), times(1)).pushRouteInformation(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user