Repository navigation
feat: add token routing and Android SDK 8.1.0 #712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1803ca6
feat: upgrade Android Navigation SDK to 8.1.0
illuminati1911 9e73aa4
fix: pr fixes
illuminati1911 bd826a8
feat: accept an options object for token routing and reject unsupport…
illuminati1911 06b062e
chore: quality improvements
jokerttu a05763f
docs: trim 0.19.1 migration notes
jokerttu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| /** | ||
| * Copyright 2026 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { device, element, waitFor, by } from 'detox'; | ||
| import { | ||
| initializeIntegrationTestsPage, | ||
| agreeToTermsAndConditions, | ||
| selectTestByName, | ||
| waitForTestToFinish, | ||
| expectSuccess, | ||
| expectNoErrors, | ||
| } from './shared.js'; | ||
|
|
||
| // Opt in with --testMatch and this file's absolute path; see example/README.md. | ||
| // The default suite needs no Routes API key; targeted runs require one. | ||
| // Keep these fixtures in sync with the in-app token integration scenarios. | ||
| const ORIGIN = { latitude: 37.791366, longitude: -122.415659 }; | ||
| const DESTINATION = { latitude: 37.791957, longitude: -122.412529 }; | ||
| const INTERMEDIATE = { latitude: 37.79165, longitude: -122.4141 }; | ||
|
|
||
| const fetchFreshRouteToken = async (multiStop = false) => { | ||
| const apiKey = process.env.ROUTES_API_KEY?.trim(); | ||
| if (!apiKey) { | ||
| throw new Error( | ||
| 'ROUTES_API_KEY is required for the targeted token-routing tests; enable Routes API for this credential.' | ||
| ); | ||
| } | ||
|
|
||
| let response; | ||
| try { | ||
| response = await fetch( | ||
| 'https://routes.googleapis.com/directions/v2:computeRoutes', | ||
| { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| 'X-Goog-Api-Key': apiKey, | ||
| 'X-Goog-FieldMask': 'routes.routeToken', | ||
| }, | ||
| body: JSON.stringify({ | ||
| origin: { location: { latLng: ORIGIN } }, | ||
| destination: { location: { latLng: DESTINATION } }, | ||
| intermediates: multiStop | ||
| ? [{ location: { latLng: INTERMEDIATE }, via: false }] | ||
| : [], | ||
| travelMode: 'DRIVE', | ||
| routingPreference: 'TRAFFIC_AWARE', | ||
| }), | ||
| signal: AbortSignal.timeout(30000), | ||
| } | ||
| ); | ||
| } catch (error) { | ||
| // Do not include request headers, credentials, or an unsanitized HTTP error. | ||
| const code = error?.cause?.code ?? error?.code ?? error?.name; | ||
| throw new Error( | ||
| `Routes API request failed before an HTTP response (${code}).` | ||
| ); | ||
| } | ||
| if (!response.ok) { | ||
| throw new Error(`Routes API request failed (HTTP ${response.status}).`); | ||
| } | ||
|
|
||
| let data; | ||
| try { | ||
| data = await response.json(); | ||
| } catch { | ||
| throw new Error( | ||
| `Routes API returned invalid JSON (HTTP ${response.status}).` | ||
| ); | ||
| } | ||
| const token = data.routes?.[0]?.routeToken; | ||
| if (typeof token !== 'string' || !token.trim()) { | ||
| throw new Error('Routes API returned no route token.'); | ||
| } | ||
| return token; | ||
| }; | ||
|
|
||
| const runTokenTest = async (testName, multiStop = false) => { | ||
| // Fetch immediately before each run; do not hardcode or cache route tokens. | ||
| const routeToken = await fetchFreshRouteToken(multiStop); | ||
| await initializeIntegrationTestsPage(); | ||
| await device.disableSynchronization(); | ||
| const tokenInput = element(by.id('route_token_input')); | ||
| await waitFor(tokenInput).toBeVisible().withTimeout(10000); | ||
| await tokenInput.tap(); | ||
| await tokenInput.replaceText(routeToken); | ||
| if (device.getPlatform() === 'android') { | ||
| await device.pressBack(); | ||
| } else { | ||
| await tokenInput.tapReturnKey(); | ||
| } | ||
| await selectTestByName(testName); | ||
| await agreeToTermsAndConditions(); | ||
| await waitForTestToFinish(180000); | ||
| await expectNoErrors(); | ||
| await expectSuccess(); | ||
| }; | ||
|
|
||
| describe('Fresh route-token navigation tests', () => { | ||
| it('NT12 - handles omitted and supported client modes, replaces routes, routes with deprecated routeTokenOptions, clears, guides and arrives', async () => { | ||
| await runTokenTest('testTokenRouting'); | ||
| }, 240000); | ||
|
|
||
| it('NT13 - follows a multi-stop token, continues between SDK legs and clears the final route', async () => { | ||
| await runTokenTest('testMultiStopTokenRouting', true); | ||
| }, 240000); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.