From 39a0bfb5a5b4435715889467e3de4f7b224c1319 Mon Sep 17 00:00:00 2001 From: Lezh1k Date: Mon, 19 Mar 2018 10:09:14 +0600 Subject: [PATCH] Fixed tests --- .../lezh1k/sensordatacollector/MainActivity.java | 2 +- .../Lib/Services/KalmanLocationService.java | 15 +++++++++++---- .../gpsacckalmanfusion/CoordinatesUnitTest.java | 5 ++++- .../DeviationsCalculatorTest.java | 3 +++ .../gpsacckalmanfusion/GeoHashUnitTest.java | 4 ++++ .../gpsacckalmanfusion/MatrixUnitTest.java | 3 +++ .../SensorGpsDataItemQueueUnitTest.java | 3 +++ 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/example/lezh1k/sensordatacollector/MainActivity.java b/app/src/main/java/com/example/lezh1k/sensordatacollector/MainActivity.java index 7b2542a..0932eb3 100644 --- a/app/src/main/java/com/example/lezh1k/sensordatacollector/MainActivity.java +++ b/app/src/main/java/com/example/lezh1k/sensordatacollector/MainActivity.java @@ -191,7 +191,7 @@ private void set_isLogging(boolean isLogging) { Utils.GEOHASH_DEFAULT_PREC, Utils.GEOHASH_DEFAULT_MIN_POINT_COUNT, Utils.SENSOR_DEFAULT_FREQ_HZ, - this); + this, false); value.reset(settings); //warning!! here you can adjust your filter behavior value.start(); }); diff --git a/madlocationmanager/src/main/java/com/example/gpsacckalmanfusion/Lib/Services/KalmanLocationService.java b/madlocationmanager/src/main/java/com/example/gpsacckalmanfusion/Lib/Services/KalmanLocationService.java index ab52b70..b16a434 100644 --- a/madlocationmanager/src/main/java/com/example/gpsacckalmanfusion/Lib/Services/KalmanLocationService.java +++ b/madlocationmanager/src/main/java/com/example/gpsacckalmanfusion/Lib/Services/KalmanLocationService.java @@ -50,6 +50,7 @@ public static class Settings { private int geoHashMinPointCount; private int sensorFfequencyHz; private ILogger logger; + private boolean filterMockGpsCoordinates; public Settings(double accelerationDeviation, @@ -58,7 +59,8 @@ public Settings(double accelerationDeviation, int geoHashPrecision, int geoHashMinPointCount, int sensorFfequencyHz, - ILogger logger) { + ILogger logger, + boolean filterMockGpsCoordinates) { this.accelerationDeviation = accelerationDeviation; this.gpsMinDistance = gpsMinDistance; this.gpsMinTime = gpsMinTime; @@ -66,6 +68,7 @@ public Settings(double accelerationDeviation, this.geoHashMinPointCount = geoHashMinPointCount; this.sensorFfequencyHz = sensorFfequencyHz; this.logger = logger; + this.filterMockGpsCoordinates = filterMockGpsCoordinates; } } @@ -84,8 +87,12 @@ public Settings(double accelerationDeviation, public static final int ServicePaused = 4; protected int m_serviceStatus = ServiceStopped; + public boolean isSensorsEnabled() { + return m_sensorsEnabled; + } + public boolean IsRunning() { - return m_serviceStatus != ServiceStopped && m_serviceStatus != ServicePaused; + return m_serviceStatus != ServiceStopped && m_serviceStatus != ServicePaused && m_sensorsEnabled; } public void addInterface(LocationServiceInterface locationServiceInterface) { @@ -164,7 +171,7 @@ public GeohashRTFilter getGeoHashRTFilter() { Utils.GPS_MIN_DISTANCE, Utils.GPS_MIN_TIME, Utils.GEOHASH_DEFAULT_PREC, Utils.GEOHASH_DEFAULT_MIN_POINT_COUNT, Utils.SENSOR_DEFAULT_FREQ_HZ, - null); + null, true); private Settings m_settings; private LocationManager m_locationManager; @@ -511,7 +518,7 @@ public void onAccuracyChanged(Sensor sensor, int accuracy) { public void onLocationChanged(Location loc) { if (loc == null) return; -// if (loc.isFromMockProvider()) return; + if (m_settings.filterMockGpsCoordinates && loc.isFromMockProvider()) return; double x, y, xVel, yVel, posDev, course, speed; long timeStamp; diff --git a/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/CoordinatesUnitTest.java b/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/CoordinatesUnitTest.java index 1fc27a4..8978a5c 100644 --- a/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/CoordinatesUnitTest.java +++ b/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/CoordinatesUnitTest.java @@ -1,5 +1,8 @@ package com.example.gpsacckalmanfusion; +import com.example.gpsacckalmanfusion.Lib.Commons.Coordinates; +import com.example.gpsacckalmanfusion.Lib.Commons.GeoPoint; + import org.junit.Test; import static junit.framework.Assert.assertTrue; @@ -36,7 +39,7 @@ public void MetersToGeoPointTest() throws Exception { @Test public void MetersBetween2PointsTest() throws Exception { - double distance = Coordinates.geoDistanceMeters(42.312000, 74.819000, 42.312001, 74.819000); + double distance = Coordinates.distanceBetween(42.312000, 74.819000, 42.312001, 74.819000); assertTrue(distance < 0.1); } } diff --git a/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/DeviationsCalculatorTest.java b/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/DeviationsCalculatorTest.java index 65f756c..ad1f71f 100644 --- a/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/DeviationsCalculatorTest.java +++ b/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/DeviationsCalculatorTest.java @@ -1,10 +1,13 @@ package com.example.gpsacckalmanfusion; +import com.example.gpsacckalmanfusion.Lib.SensorAux.DeviationCalculator; + import org.junit.Test; import java.util.Random; import static junit.framework.Assert.assertTrue; +import static junit.framework.Assert.assertEquals; /** * Created by lezh1k on 2/13/18. diff --git a/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/GeoHashUnitTest.java b/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/GeoHashUnitTest.java index e8adecd..8ee0537 100644 --- a/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/GeoHashUnitTest.java +++ b/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/GeoHashUnitTest.java @@ -1,11 +1,15 @@ package com.example.gpsacckalmanfusion; +import com.example.gpsacckalmanfusion.Lib.Commons.GeoPoint; +import com.example.gpsacckalmanfusion.Lib.Filters.GeoHash; + import org.junit.Test; import java.util.Arrays; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; +import static junit.framework.Assert.assertEquals; /** * Created by lezh1k on 2/13/18. diff --git a/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/MatrixUnitTest.java b/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/MatrixUnitTest.java index b382183..79b226f 100644 --- a/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/MatrixUnitTest.java +++ b/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/MatrixUnitTest.java @@ -1,10 +1,13 @@ package com.example.gpsacckalmanfusion; +import com.example.gpsacckalmanfusion.Lib.Commons.Matrix; + import org.junit.Test; import java.util.Random; import static junit.framework.Assert.assertTrue; +import static junit.framework.Assert.assertEquals; /** * Created by lezh1k on 2/13/18. diff --git a/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/SensorGpsDataItemQueueUnitTest.java b/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/SensorGpsDataItemQueueUnitTest.java index 767f71d..855299b 100644 --- a/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/SensorGpsDataItemQueueUnitTest.java +++ b/madlocationmanager/src/test/java/com/example/gpsacckalmanfusion/SensorGpsDataItemQueueUnitTest.java @@ -1,11 +1,14 @@ package com.example.gpsacckalmanfusion; +import com.example.gpsacckalmanfusion.Lib.Commons.SensorGpsDataItem; + import org.junit.Test; import java.util.Queue; import java.util.concurrent.PriorityBlockingQueue; import static org.junit.Assert.assertTrue; +import static junit.framework.Assert.assertEquals; /** * Created by lezh1k on 2/13/18.