Skip to content

Commit

Permalink
Wait for tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpoole committed Sep 19, 2023
1 parent 11da600 commit 6b7e223
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions src/androidTest/java/de/blau/android/gpx/GpxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,7 @@ public void recordSaveAndImportGpx() {
TestUtils.setupMockLocation(main, Criteria.ACCURACY_FINE);
// wait for the trackerservice to start
// unluckily there doesn't seem to be any elegant way to do this
int retries = 0;
synchronized (device) {
while (main.getTracker() == null && retries < 60) {
try {
device.wait(1000);
} catch (InterruptedException e) {
// Ignore
}
retries++;
if (retries >= 60) {
fail("Tracker service didn't start");
}
}
}
checkTracker();
// set min distance to 1m
prefs.setGpsDistance(0);

Expand Down Expand Up @@ -239,14 +226,9 @@ public void recordSaveAndImportGpx() {
}

/**
* Start recording, pause resume, clear
* Wait until the tracker is available
*/
// @SdkSuppress(minSdkVersion = 26)
@Test
public void recordPauseAndResume() {
TestUtils.setupMockLocation(main, Criteria.ACCURACY_FINE);
// wait for the trackerservice to start
// unluckily there doesn't seem to be any elegant way to do this
private void checkTracker() {
int retries = 0;
synchronized (device) {
while (main.getTracker() == null && retries < 60) {
Expand All @@ -261,6 +243,19 @@ public void recordPauseAndResume() {
}
}
}
}

/**
* Start recording, pause resume, clear
*/
// @SdkSuppress(minSdkVersion = 26)
@Test
public void recordPauseAndResume() {
TestUtils.setupMockLocation(main, Criteria.ACCURACY_FINE);
// wait for the trackerservice to start
// unluckily there doesn't seem to be any elegant way to do this
int retries = 0;
checkTracker();
// set min distance to 1m
prefs.setGpsDistance(0);

Expand Down Expand Up @@ -363,13 +358,14 @@ public void importWayPoints() {
@Test
public void followNetworkLocation() {
TestUtils.setupMockLocation(main, Criteria.ACCURACY_COARSE);
checkTracker();
// set min distance to 1m
prefs.setGpsDistance(0);

TestUtils.zoomToLevel(device, main, 19);
TestUtils.clickButton(device, device.getCurrentPackageName() + ":id/follow", false);
assertTrue(main.getFollowGPS());

ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream is = loader.getResourceAsStream("20110513_121244-tp.gpx");
Track track = new Track(main, false);
Expand Down

0 comments on commit 6b7e223

Please sign in to comment.