Skip to content

Commit 39a0bfb

Browse files
committed
Fixed tests
1 parent 86d2cf9 commit 39a0bfb

File tree

7 files changed

+29
-6
lines changed

7 files changed

+29
-6
lines changed

app/src/main/java/com/example/lezh1k/sensordatacollector/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private void set_isLogging(boolean isLogging) {
191191
Utils.GEOHASH_DEFAULT_PREC,
192192
Utils.GEOHASH_DEFAULT_MIN_POINT_COUNT,
193193
Utils.SENSOR_DEFAULT_FREQ_HZ,
194-
this);
194+
this, false);
195195
value.reset(settings); //warning!! here you can adjust your filter behavior
196196
value.start();
197197
});

madlocationmanager/src/main/java/com/example/gpsacckalmanfusion/Lib/Services/KalmanLocationService.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public static class Settings {
5050
private int geoHashMinPointCount;
5151
private int sensorFfequencyHz;
5252
private ILogger logger;
53+
private boolean filterMockGpsCoordinates;
5354

5455

5556
public Settings(double accelerationDeviation,
@@ -58,14 +59,16 @@ public Settings(double accelerationDeviation,
5859
int geoHashPrecision,
5960
int geoHashMinPointCount,
6061
int sensorFfequencyHz,
61-
ILogger logger) {
62+
ILogger logger,
63+
boolean filterMockGpsCoordinates) {
6264
this.accelerationDeviation = accelerationDeviation;
6365
this.gpsMinDistance = gpsMinDistance;
6466
this.gpsMinTime = gpsMinTime;
6567
this.geoHashPrecision = geoHashPrecision;
6668
this.geoHashMinPointCount = geoHashMinPointCount;
6769
this.sensorFfequencyHz = sensorFfequencyHz;
6870
this.logger = logger;
71+
this.filterMockGpsCoordinates = filterMockGpsCoordinates;
6972
}
7073
}
7174

@@ -84,8 +87,12 @@ public Settings(double accelerationDeviation,
8487
public static final int ServicePaused = 4;
8588
protected int m_serviceStatus = ServiceStopped;
8689

90+
public boolean isSensorsEnabled() {
91+
return m_sensorsEnabled;
92+
}
93+
8794
public boolean IsRunning() {
88-
return m_serviceStatus != ServiceStopped && m_serviceStatus != ServicePaused;
95+
return m_serviceStatus != ServiceStopped && m_serviceStatus != ServicePaused && m_sensorsEnabled;
8996
}
9097

9198
public void addInterface(LocationServiceInterface locationServiceInterface) {
@@ -164,7 +171,7 @@ public GeohashRTFilter getGeoHashRTFilter() {
164171
Utils.GPS_MIN_DISTANCE, Utils.GPS_MIN_TIME,
165172
Utils.GEOHASH_DEFAULT_PREC, Utils.GEOHASH_DEFAULT_MIN_POINT_COUNT,
166173
Utils.SENSOR_DEFAULT_FREQ_HZ,
167-
null);
174+
null, true);
168175

169176
private Settings m_settings;
170177
private LocationManager m_locationManager;
@@ -511,7 +518,7 @@ public void onAccuracyChanged(Sensor sensor, int accuracy) {
511518
public void onLocationChanged(Location loc) {
512519

513520
if (loc == null) return;
514-
// if (loc.isFromMockProvider()) return;
521+
if (m_settings.filterMockGpsCoordinates && loc.isFromMockProvider()) return;
515522

516523
double x, y, xVel, yVel, posDev, course, speed;
517524
long timeStamp;

madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/CoordinatesUnitTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.example.gpsacckalmanfusion;
22

3+
import com.example.gpsacckalmanfusion.Lib.Commons.Coordinates;
4+
import com.example.gpsacckalmanfusion.Lib.Commons.GeoPoint;
5+
36
import org.junit.Test;
47

58
import static junit.framework.Assert.assertTrue;
@@ -36,7 +39,7 @@ public void MetersToGeoPointTest() throws Exception {
3639

3740
@Test
3841
public void MetersBetween2PointsTest() throws Exception {
39-
double distance = Coordinates.geoDistanceMeters(42.312000, 74.819000, 42.312001, 74.819000);
42+
double distance = Coordinates.distanceBetween(42.312000, 74.819000, 42.312001, 74.819000);
4043
assertTrue(distance < 0.1);
4144
}
4245
}

madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/DeviationsCalculatorTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.example.gpsacckalmanfusion;
22

3+
import com.example.gpsacckalmanfusion.Lib.SensorAux.DeviationCalculator;
4+
35
import org.junit.Test;
46

57
import java.util.Random;
68

79
import static junit.framework.Assert.assertTrue;
10+
import static junit.framework.Assert.assertEquals;
811

912
/**
1013
* Created by lezh1k on 2/13/18.

madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/GeoHashUnitTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package com.example.gpsacckalmanfusion;
22

3+
import com.example.gpsacckalmanfusion.Lib.Commons.GeoPoint;
4+
import com.example.gpsacckalmanfusion.Lib.Filters.GeoHash;
5+
36
import org.junit.Test;
47

58
import java.util.Arrays;
69

710
import static junit.framework.Assert.assertFalse;
811
import static junit.framework.Assert.assertTrue;
12+
import static junit.framework.Assert.assertEquals;
913

1014
/**
1115
* Created by lezh1k on 2/13/18.

madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/MatrixUnitTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.example.gpsacckalmanfusion;
22

3+
import com.example.gpsacckalmanfusion.Lib.Commons.Matrix;
4+
35
import org.junit.Test;
46

57
import java.util.Random;
68

79
import static junit.framework.Assert.assertTrue;
10+
import static junit.framework.Assert.assertEquals;
811

912
/**
1013
* Created by lezh1k on 2/13/18.

madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/SensorGpsDataItemQueueUnitTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.example.gpsacckalmanfusion;
22

3+
import com.example.gpsacckalmanfusion.Lib.Commons.SensorGpsDataItem;
4+
35
import org.junit.Test;
46

57
import java.util.Queue;
68
import java.util.concurrent.PriorityBlockingQueue;
79

810
import static org.junit.Assert.assertTrue;
11+
import static junit.framework.Assert.assertEquals;
912

1013
/**
1114
* Created by lezh1k on 2/13/18.

0 commit comments

Comments
 (0)