summaryrefslogtreecommitdiff
path: root/location/tests
diff options
context:
space:
mode:
authorgomo <gomo@google.com>2018-12-12 16:49:39 -0800
committergomo <gomo@google.com>2018-12-20 15:27:08 -0800
commit226b7b7775dd1009ab5504fc1aec17db34f24a2e (patch)
treec2f9e5e1fdcf9dabea92e78f10d4316ddb9a3e44 /location/tests
parent6fa14abad36ed3197df467831dc3e018b05ec635 (diff)
Bluesky Android Q Platform Changes
- Changes to C++ HAL and GNSS Location Provder Code to inject corrections to chipset - Changes to JNI bridge to translate the Java corrections to C++ - Changes to JAVA side of the bridge: GnssLocationProvider.cpp to pipe the corrections through the JNI - Build the Locaiton Manager First Party APIs and methods - Build needed Java containers: GnssMeasuremetCorrections.java, GnssSingleSatCorrections.java and ReflectingPlane.java - Build the Parcelables to send all our Java objects through processes - Build piping methods in CallbackTransport.java, LocationMangerservice.java, etc to pass the data in both direcions - update API docs: current.txt and system-current.txt Bug: 111441283 Test: Existing tests pass. Change-Id: I8650fea21c69c8f31ba9cabe63d4a6676ffe38d7
Diffstat (limited to 'location/tests')
-rw-r--r--location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java107
-rw-r--r--location/tests/locationtests/src/android/location/GnssReflectingPlaneTest.java67
-rw-r--r--location/tests/locationtests/src/android/location/GnssSingleSatCorrectionsTest.java81
3 files changed, 255 insertions, 0 deletions
diff --git a/location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java b/location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java
new file mode 100644
index 000000000000..c18d58f9a704
--- /dev/null
+++ b/location/tests/locationtests/src/android/location/GnssMeasurementCorrectionsTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.location;
+
+import android.os.Parcel;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/** Unit tests for {@link GnssMeasurementCorrections}. */
+public class GnssMeasurementCorrectionsTest extends TestCase {
+ public void testDescribeContents() {
+ GnssMeasurementCorrections measurementCorrections =
+ new GnssMeasurementCorrections.Builder().build();
+ measurementCorrections.describeContents();
+ }
+
+ public void testWriteToParcel() {
+ GnssMeasurementCorrections.Builder measurementCorrections =
+ new GnssMeasurementCorrections.Builder();
+ setTestValues(measurementCorrections);
+ Parcel parcel = Parcel.obtain();
+ measurementCorrections.build().writeToParcel(parcel, 0);
+ parcel.setDataPosition(0);
+ GnssMeasurementCorrections newMeasurementCorrection =
+ GnssMeasurementCorrections.CREATOR.createFromParcel(parcel);
+ verifyTestValues(newMeasurementCorrection);
+ parcel.recycle();
+ }
+
+ private static void verifyTestValues(GnssMeasurementCorrections measurementCorrections) {
+ assertEquals(37.386051, measurementCorrections.getLatitudeDegrees());
+ assertEquals(-122.083855, measurementCorrections.getLongitudeDegrees());
+ assertEquals(32.0, measurementCorrections.getAltitudeMeters());
+ assertEquals(604000000000000L, measurementCorrections.getToaGpsNanosecondsOfWeek());
+
+ GnssSingleSatCorrection singleSatCorrection =
+ measurementCorrections.getSingleSatCorrectionList().get(0);
+ GnssSingleSatCorrectionsTest.verifyTestValues(singleSatCorrection);
+
+ singleSatCorrection = measurementCorrections.getSingleSatCorrectionList().get(1);
+ assertEquals(15, singleSatCorrection.getSingleSatCorrectionFlags());
+ assertEquals(GnssStatus.CONSTELLATION_GPS, singleSatCorrection.getConstellationType());
+ assertEquals(11, singleSatCorrection.getSatId());
+ assertEquals(1575430000f, singleSatCorrection.getCarrierFrequencyHz());
+ assertEquals(false, singleSatCorrection.isSatelliteLineOfSight());
+ assertEquals(50.0f, singleSatCorrection.getExcessPathLengthMeters());
+ assertEquals(55.0f, singleSatCorrection.getExcessPathLengthUncertaintyMeters());
+ GnssReflectingPlane reflectingPlane = singleSatCorrection.getReflectingPlane();
+ assertEquals(37.386054, reflectingPlane.getLatitudeDegrees());
+ assertEquals(-122.083855, reflectingPlane.getLongitudeDegrees());
+ assertEquals(120.0, reflectingPlane.getAltitudeMeters());
+ assertEquals(153.0, reflectingPlane.getAzimuthDegrees());
+ }
+
+ private static void setTestValues(GnssMeasurementCorrections.Builder measurementCorrections) {
+ measurementCorrections
+ .setLatitudeDegrees(37.386051)
+ .setLongitudeDegrees(-122.083855)
+ .setAltitudeMeters(32)
+ .setToaGpsNanosecondsOfWeek(604000000000000L);
+ List<GnssSingleSatCorrection> singleSatCorrectionList = new ArrayList<>();
+ singleSatCorrectionList.add(GnssSingleSatCorrectionsTest.generateTestSingleSatCorrection());
+ singleSatCorrectionList.add(generateTestSingleSatCorrection());
+ measurementCorrections.setSingleSatCorrectionList(singleSatCorrectionList);
+ }
+
+ private static GnssSingleSatCorrection generateTestSingleSatCorrection() {
+ GnssSingleSatCorrection.Builder singleSatCorrection = new GnssSingleSatCorrection.Builder();
+ singleSatCorrection
+ .setSingleSatCorrectionFlags(8)
+ .setConstellationType(GnssStatus.CONSTELLATION_GPS)
+ .setSatId(11)
+ .setCarrierFrequencyHz(1575430000f)
+ .setSatIsLos(false)
+ .setExcessPathLengthMeters(50.0f)
+ .setExcessPathLengthUncertaintyMeters(55.0f)
+ .setReflectingPlane(generateTestReflectingPlane());
+ return singleSatCorrection.build();
+ }
+
+ private static GnssReflectingPlane generateTestReflectingPlane() {
+ GnssReflectingPlane.Builder reflectingPlane =
+ new GnssReflectingPlane.Builder()
+ .setLatitudeDegrees(37.386054)
+ .setLongitudeDegrees(-122.083855)
+ .setAltitudeMeters(120.0)
+ .setAzimuthDegrees(153);
+ return reflectingPlane.build();
+ }
+}
diff --git a/location/tests/locationtests/src/android/location/GnssReflectingPlaneTest.java b/location/tests/locationtests/src/android/location/GnssReflectingPlaneTest.java
new file mode 100644
index 000000000000..d7a3378e5a12
--- /dev/null
+++ b/location/tests/locationtests/src/android/location/GnssReflectingPlaneTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.location;
+
+import android.os.Parcel;
+
+import junit.framework.TestCase;
+
+/** Unit tests for {@link GnssReflectingPlane}. */
+public class GnssReflectingPlaneTest extends TestCase {
+ public void testDescribeContents() {
+ GnssReflectingPlane reflectingPlane = new GnssReflectingPlane.Builder().build();
+ reflectingPlane.describeContents();
+ }
+
+ public void testWriteToParcel() {
+ GnssReflectingPlane.Builder reflectingPlane = new GnssReflectingPlane.Builder();
+ setTestValues(reflectingPlane);
+ Parcel parcel = Parcel.obtain();
+ reflectingPlane.build().writeToParcel(parcel, 0);
+ parcel.setDataPosition(0);
+ GnssReflectingPlane newReflectingPlane =
+ GnssReflectingPlane.CREATOR.createFromParcel(parcel);
+ verifyTestValues(newReflectingPlane);
+ parcel.recycle();
+ }
+
+ public static void verifyTestValues(GnssReflectingPlane reflectingPlane) {
+ assertEquals(37.386052, reflectingPlane.getLatitudeDegrees());
+ assertEquals(-122.083853, reflectingPlane.getLongitudeDegrees());
+ assertEquals(100.0, reflectingPlane.getAltitudeMeters());
+ assertEquals(123.0, reflectingPlane.getAzimuthDegrees());
+ }
+
+ private static void setTestValues(GnssReflectingPlane.Builder reflectingPlane) {
+ GnssReflectingPlane refPlane = generateTestReflectingPlane();
+ reflectingPlane
+ .setLatitudeDegrees(refPlane.getLatitudeDegrees())
+ .setLongitudeDegrees(refPlane.getLongitudeDegrees())
+ .setAltitudeMeters(refPlane.getAltitudeMeters())
+ .setAzimuthDegrees(refPlane.getAzimuthDegrees());
+ }
+
+ public static GnssReflectingPlane generateTestReflectingPlane() {
+ GnssReflectingPlane.Builder reflectingPlane =
+ new GnssReflectingPlane.Builder()
+ .setLatitudeDegrees(37.386052)
+ .setLongitudeDegrees(-122.083853)
+ .setAltitudeMeters(100.0)
+ .setAzimuthDegrees(123.0);
+ return reflectingPlane.build();
+ }
+}
diff --git a/location/tests/locationtests/src/android/location/GnssSingleSatCorrectionsTest.java b/location/tests/locationtests/src/android/location/GnssSingleSatCorrectionsTest.java
new file mode 100644
index 000000000000..2e54ae463595
--- /dev/null
+++ b/location/tests/locationtests/src/android/location/GnssSingleSatCorrectionsTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.location;
+
+import android.os.Parcel;
+
+import junit.framework.TestCase;
+
+/** Unit tests for {@link GnssSingleSatCorrection}. */
+public class GnssSingleSatCorrectionsTest extends TestCase {
+ public void testDescribeContents() {
+ GnssSingleSatCorrection singleSatCorrection = new GnssSingleSatCorrection.Builder().build();
+ singleSatCorrection.describeContents();
+ }
+
+ public void testWriteToParcel() {
+ GnssSingleSatCorrection.Builder singleSatCorrection = new GnssSingleSatCorrection.Builder();
+ setTestValues(singleSatCorrection);
+ Parcel parcel = Parcel.obtain();
+ singleSatCorrection.build().writeToParcel(parcel, 0);
+ parcel.setDataPosition(0);
+ GnssSingleSatCorrection newSingleSatCorrection =
+ GnssSingleSatCorrection.CREATOR.createFromParcel(parcel);
+ verifyTestValues(newSingleSatCorrection);
+ parcel.recycle();
+ }
+
+ public static void verifyTestValues(GnssSingleSatCorrection singleSatCorrection) {
+ assertEquals(15, singleSatCorrection.getSingleSatCorrectionFlags());
+ assertEquals(GnssStatus.CONSTELLATION_GALILEO, singleSatCorrection.getConstellationType());
+ assertEquals(12, singleSatCorrection.getSatId());
+ assertEquals(1575420000f, singleSatCorrection.getCarrierFrequencyHz());
+ assertEquals(true, singleSatCorrection.isSatelliteLineOfSight());
+ assertEquals(10.0f, singleSatCorrection.getExcessPathLengthMeters());
+ assertEquals(5.0f, singleSatCorrection.getExcessPathLengthUncertaintyMeters());
+ GnssReflectingPlane reflectingPlane = singleSatCorrection.getReflectingPlane();
+ GnssReflectingPlaneTest.verifyTestValues(reflectingPlane);
+ }
+
+ private static void setTestValues(GnssSingleSatCorrection.Builder singleSatCorrection) {
+ GnssSingleSatCorrection singleSatCorr = generateTestSingleSatCorrection();
+ singleSatCorrection
+ .setSingleSatCorrectionFlags(singleSatCorr.getSingleSatCorrectionFlags())
+ .setConstellationType(singleSatCorr.getConstellationType())
+ .setSatId(singleSatCorr.getSatId())
+ .setCarrierFrequencyHz(singleSatCorr.getCarrierFrequencyHz())
+ .setSatIsLos(singleSatCorr.isSatelliteLineOfSight())
+ .setExcessPathLengthMeters(singleSatCorr.getExcessPathLengthMeters())
+ .setExcessPathLengthUncertaintyMeters(
+ singleSatCorr.getExcessPathLengthUncertaintyMeters())
+ .setReflectingPlane(singleSatCorr.getReflectingPlane());
+ }
+
+ public static GnssSingleSatCorrection generateTestSingleSatCorrection() {
+ GnssSingleSatCorrection.Builder singleSatCorrection =
+ new GnssSingleSatCorrection.Builder()
+ .setSingleSatCorrectionFlags(15)
+ .setConstellationType(GnssStatus.CONSTELLATION_GALILEO)
+ .setSatId(12)
+ .setCarrierFrequencyHz(1575420000f)
+ .setSatIsLos(true)
+ .setExcessPathLengthMeters(10.0f)
+ .setExcessPathLengthUncertaintyMeters(5.0f)
+ .setReflectingPlane(GnssReflectingPlaneTest.generateTestReflectingPlane());
+ return singleSatCorrection.build();
+ }
+}