diff options
Diffstat (limited to 'test/org/traccar/location/LocationProviderTest.java')
-rw-r--r-- | test/org/traccar/location/LocationProviderTest.java | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/test/org/traccar/location/LocationProviderTest.java b/test/org/traccar/location/LocationProviderTest.java index 910f9e9ea..aec210c84 100644 --- a/test/org/traccar/location/LocationProviderTest.java +++ b/test/org/traccar/location/LocationProviderTest.java @@ -2,34 +2,29 @@ package org.traccar.location; import org.junit.Assert; import org.junit.Test; -import org.traccar.model.Position; +import org.traccar.BaseTest; +import org.traccar.model.CellTower; +import org.traccar.model.Network; -import java.util.HashMap; -import java.util.Map; - -public class LocationProviderTest { +public class LocationProviderTest extends BaseTest { private boolean enable = false; @Test - public void test() { + public void test() throws Exception { if (enable) { - testOpenCellId(); + testGoogleLocationProvider(); } } - public void testOpenCellId() { - OpenCellIdLocationProvider locationProvider = new OpenCellIdLocationProvider("fake"); + public void testGoogleLocationProvider() throws Exception { + GoogleLocationProvider locationProvider = new GoogleLocationProvider("KEY"); - Map<String, Object> attributes = new HashMap<>(); - attributes.put(Position.KEY_MCC, 260); - attributes.put(Position.KEY_MNC, 2); - attributes.put(Position.KEY_LAC, 10250); - attributes.put(Position.KEY_CID, 26511); + Network network = new Network(CellTower.from(260, 2, 10250, 26511)); - locationProvider.getLocation(attributes, new LocationProvider.LocationProviderCallback() { + locationProvider.getLocation(network, new LocationProvider.LocationProviderCallback() { @Override - public void onSuccess(double latitude, double longitude) { + public void onSuccess(double latitude, double longitude, double accuracy) { Assert.assertEquals(60.07254, latitude, 0.00001); Assert.assertEquals(30.30996, longitude, 0.00001); } @@ -39,6 +34,8 @@ public class LocationProviderTest { Assert.fail(); } }); + + Thread.sleep(Long.MAX_VALUE); } } |