src/androidTest/java/de/blau/android/gpx/GpxTest.java
/**
     * Replay a track and pretend the output are network generated locations
     */
Replay a track and pretend the output are network generated locations
Replay a track and pretend the output are network generated locations
@Test
    public void followNetworkLocation() {
        TestUtils.setupMockLocation(main, Criteria.ACCURACY_COARSE);
        prefs.setGpsDistance(0);
        TestUtils.zoomToLevel(device, main, 19);
        TestUtils.clickButton(device, device.getCurrentPackageName() + ":id/follow", false);
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        InputStream is = loader.getResourceAsStream("20110513_121244-tp.gpx");
        Track track = new Track(main, false);
        track.importFromGPX(is);
        main.getTracker().getTrack().reset(); 
        final CountDownLatch signal = new CountDownLatch(1);
        TestUtils.injectLocation(main, track.getTrackPoints(), Criteria.ACCURACY_COARSE, 1000, new SignalHandler(signal));
        TestUtils.sleep(TIMEOUT * 1000L);
        clickGpsButton(device);
        assertTrue(TestUtils.clickText(device, false, "Pause GPX track", true, false));
        TrackPoint lastPoint = track.getTrackPoints().get(track.getTrackPoints().size() - 1);
        ViewBox box = main.getMap().getViewBox();
        assertEquals(lastPoint.getLatitude(), box.getCenterLat(), 0.001);
        assertEquals(lastPoint.getLongitude(), ((box.getLeft() - box.getRight()) / 2d + box.getRight()) / 1E7D, 0.001);
    }
@ Test public void followNetworkLocation ( ) { TestUtils . setupMockLocation ( main , Criteria . ACCURACY_COARSE ) ; prefs . setGpsDistance ( 0 ) ; TestUtils . zoomToLevel ( device , main , 19 ) ; TestUtils . clickButton ( device , device . getCurrentPackageName ( ) + ":id/follow" , false ) ; ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; InputStream is = loader . getResourceAsStream ( "20110513_121244-tp.gpx" ) ; Track track = new Track ( main , false ) ; track . importFromGPX ( is ) ; main . getTracker ( ) . getTrack ( ) . reset ( ) ; final CountDownLatch signal = new CountDownLatch ( 1 ) ; TestUtils . injectLocation ( main , track . getTrackPoints ( ) , Criteria . ACCURACY_COARSE , 1000 , new SignalHandler ( signal ) ) ; TestUtils . sleep ( TIMEOUT * 1000L ) ; clickGpsButton ( device ) ; assertTrue ( TestUtils . clickText ( device , false , "Pause GPX track" , true , false ) ) ; TrackPoint lastPoint = track . getTrackPoints ( ) . get ( track . getTrackPoints ( ) . size ( ) - 1 ) ; ViewBox box = main . getMap ( ) . getViewBox ( ) ; assertEquals ( lastPoint . getLatitude ( ) , box . getCenterLat ( ) , 0.001 ) ; assertEquals ( lastPoint . getLongitude ( ) , ( ( box . getLeft ( ) - box . getRight ( ) ) / 2d + box . getRight ( ) ) / 1E7D , 0.001 ) ; }
Replay a track and pretend the output are network generated locations
Replay a track and pretend the output are network generated locations
// set min distance to 1m // clear out anything saved // compare roughly with last location