diff --git a/detox/test/e2e/o-location.js b/detox/test/e2e/o-location.js
index db2cb68122..918941170d 100644
--- a/detox/test/e2e/o-location.js
+++ b/detox/test/e2e/o-location.js
@@ -2,6 +2,7 @@ describe('location', () => {
it('Location should be unavabilable', async () => {
await device.relaunchApp({permissions: {location: 'never'}});
await element(by.label('Location')).tap();
+ await element(by.id('getLocationButton')).tap();
await expect(element(by.id('error'))).toBeVisible();
});
@@ -9,6 +10,7 @@ describe('location', () => {
await device.relaunchApp({permissions: {location: 'always'}});
await device.setLocation(20, 20);
await element(by.label('Location')).tap();
+ await element(by.id('getLocationButton')).tap();
await expect(element(by.text('Latitude: 20'))).toBeVisible();
await expect(element(by.text('Longitude: 20'))).toBeVisible();
});
diff --git a/detox/test/src/Screens/LocationScreen.js b/detox/test/src/Screens/LocationScreen.js
index 15c6853b76..c181e6eea3 100644
--- a/detox/test/src/Screens/LocationScreen.js
+++ b/detox/test/src/Screens/LocationScreen.js
@@ -1,7 +1,8 @@
import React, { Component } from 'react';
import {
Text,
- View
+ View,
+ Button
} from 'react-native';
export default class LocationScreen extends Component {
@@ -9,13 +10,14 @@ export default class LocationScreen extends Component {
constructor(props) {
super(props);
this.state = {
+ locationRequested: false,
coordinates: null
}
this.getLocation();
}
- getLocation() {
+ async getLocation() {
function success(pos) {
this.setState({
coordinates: pos.coords
@@ -28,10 +30,25 @@ export default class LocationScreen extends Component {
});
};
- navigator.geolocation.getCurrentPosition(success.bind(this), error.bind(this));
+ await navigator.geolocation.getCurrentPosition(success.bind(this), error.bind(this));
}
render() {
+ if(!this.state.locationRequested) {
+ return (
+
+
+ );
+ }
+
if (this.state.coordinates) {
return (