Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ analyzer:
errors:
# allow self-reference to deprecated members
deprecated_member_use_from_same_package: ignore
# allow deprecated member use in test files and examples
deprecated_member_use: ignore
exclude:
# Ignore generated files
- "**/*.g.dart"
Expand Down
4 changes: 2 additions & 2 deletions example/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ android {
applicationId = "com.google.maps.flutter.navigation_example"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = 23
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
Expand Down Expand Up @@ -123,4 +123,4 @@ secrets {
ignoreList.add("sdk.*")
// Ignore all keys matching the regexp "flutter.*"
ignoreList.add("flutter.*")
}
}
2 changes: 2 additions & 0 deletions example/integration_test/t01_initialization_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ void main() {
}

try {
// Note: Testing deprecated continueToNextDestination for proper exception
// handling.
await GoogleMapsNavigator.continueToNextDestination();
fail('Expected SessionNotInitializedException.');
} on Exception catch (e) {
Expand Down
63 changes: 52 additions & 11 deletions example/integration_test/t03_navigation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ void main() {

final GoogleNavigationInspectorPlatform inspector =
GoogleNavigationInspectorPlatform.instance!;
final multipleDestinationsVariants = ValueVariant<String>(<String>{
'continueToNextDestination',
'setDestinations',
});

/// Start location coordinates in Finland (Näkkäläntie).
const double startLat = startLocationLat;
Expand Down Expand Up @@ -183,6 +187,7 @@ void main() {
(PatrolIntegrationTester $) async {
final Completer<void> navigationFinished = Completer<void>();
int arrivalEventCount = 0;
List<NavigationWaypoint> waypoints = <NavigationWaypoint>[];

/// Set up navigation view and controller.
final GoogleNavigationViewController viewController =
Expand All @@ -208,7 +213,39 @@ void main() {

Future<void> onArrivalEvent(OnArrivalEvent msg) async {
arrivalEventCount += 1;
await GoogleMapsNavigator.continueToNextDestination();

if (multipleDestinationsVariants.currentValue ==
'continueToNextDestination') {
// Note: continueToNextDestination is deprecated.
// This test still uses it to verify the deprecated API works correctly.
// For new implementations, use setDestinations with updated waypoints instead.
await GoogleMapsNavigator.continueToNextDestination();
} else {
// Find and remove the waypoint that matches the arrived waypoint
int waypointIndex = -1;
for (int i = 0; i < waypoints.length; i++) {
final NavigationWaypoint waypoint = waypoints[i];
if (waypoint.title == msg.waypoint.title) {
waypointIndex = i;
break;
}
}

if (waypointIndex >= 0) {
waypoints.removeAt(waypointIndex);
}

if (waypoints.isNotEmpty) {
// Update destinations with remaining waypoints
final Destinations updatedDestinations = Destinations(
waypoints: waypoints,
displayOptions: NavigationDisplayOptions(
showDestinationMarkers: false,
),
);
await GoogleMapsNavigator.setDestinations(updatedDestinations);
}
}

/// Finish executing the tests once 2 onArrival events come in.
/// Test the guidance stops on last Arrival.
Expand All @@ -228,18 +265,21 @@ void main() {
tolerance,
);

/// Set up initial waypoints.
waypoints = <NavigationWaypoint>[
NavigationWaypoint.withLatLngTarget(
title: 'Näkkäläntie 1st stop',
target: const LatLng(latitude: midLat, longitude: midLon),
),
NavigationWaypoint.withLatLngTarget(
title: 'Näkkäläntie 2nd stop',
target: const LatLng(latitude: endLat, longitude: endLng),
),
];

/// Set Destination.
final Destinations destinations = Destinations(
waypoints: <NavigationWaypoint>[
NavigationWaypoint.withLatLngTarget(
title: 'Näkkäläntie 1st stop',
target: const LatLng(latitude: midLat, longitude: midLon),
),
NavigationWaypoint.withLatLngTarget(
title: 'Näkkäläntie 2nd stop',
target: const LatLng(latitude: endLat, longitude: endLng),
),
],
waypoints: waypoints,
displayOptions: NavigationDisplayOptions(showDestinationMarkers: false),
);
final NavigationRouteStatus status =
Expand Down Expand Up @@ -293,6 +333,7 @@ void main() {

await GoogleMapsNavigator.cleanup();
},
variant: multipleDestinationsVariants,
// TODO(jokerttu): Skipping Android as this fails on Android emulator on CI.
skip: Platform.isAndroid,
);
Expand Down
Loading
Loading