Merge "Move UWB Tests to CTS"
This commit is contained in:
@@ -2,6 +2,9 @@
|
|||||||
"presubmit": [
|
"presubmit": [
|
||||||
{
|
{
|
||||||
"name": "UwbManagerTests"
|
"name": "UwbManagerTests"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "CtsUwbTestCases"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020 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.uwb;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test of {@link AngleMeasurement}.
|
|
||||||
*/
|
|
||||||
@SmallTest
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class AngleMeasurementTest {
|
|
||||||
private static final double EPSILON = 0.00000000001;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilder() {
|
|
||||||
double radians = 0.1234;
|
|
||||||
double errorRadians = 0.5678;
|
|
||||||
double confidence = 0.5;
|
|
||||||
|
|
||||||
AngleMeasurement.Builder builder = new AngleMeasurement.Builder();
|
|
||||||
tryBuild(builder, false);
|
|
||||||
|
|
||||||
builder.setRadians(radians);
|
|
||||||
tryBuild(builder, false);
|
|
||||||
|
|
||||||
builder.setErrorRadians(errorRadians);
|
|
||||||
tryBuild(builder, false);
|
|
||||||
|
|
||||||
builder.setConfidenceLevel(confidence);
|
|
||||||
AngleMeasurement measurement = tryBuild(builder, true);
|
|
||||||
|
|
||||||
assertEquals(measurement.getRadians(), radians, 0);
|
|
||||||
assertEquals(measurement.getErrorRadians(), errorRadians, 0);
|
|
||||||
assertEquals(measurement.getConfidenceLevel(), confidence, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private AngleMeasurement tryBuild(AngleMeasurement.Builder builder, boolean expectSuccess) {
|
|
||||||
AngleMeasurement measurement = null;
|
|
||||||
try {
|
|
||||||
measurement = builder.build();
|
|
||||||
if (!expectSuccess) {
|
|
||||||
fail("Expected AngleMeasurement.Builder.build() to fail, but it succeeded");
|
|
||||||
}
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
if (expectSuccess) {
|
|
||||||
fail("Expected AngleMeasurement.Builder.build() to succeed, but it failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return measurement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcel() {
|
|
||||||
Parcel parcel = Parcel.obtain();
|
|
||||||
AngleMeasurement measurement = UwbTestUtils.getAngleMeasurement();
|
|
||||||
measurement.writeToParcel(parcel, 0);
|
|
||||||
parcel.setDataPosition(0);
|
|
||||||
AngleMeasurement fromParcel = AngleMeasurement.CREATOR.createFromParcel(parcel);
|
|
||||||
assertEquals(measurement, fromParcel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020 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.uwb;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test of {@link AngleOfArrivalMeasurement}.
|
|
||||||
*/
|
|
||||||
@SmallTest
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class AngleOfArrivalMeasurementTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilder() {
|
|
||||||
AngleMeasurement azimuth = UwbTestUtils.getAngleMeasurement();
|
|
||||||
AngleMeasurement altitude = UwbTestUtils.getAngleMeasurement();
|
|
||||||
|
|
||||||
AngleOfArrivalMeasurement.Builder builder = new AngleOfArrivalMeasurement.Builder();
|
|
||||||
tryBuild(builder, false);
|
|
||||||
|
|
||||||
builder.setAltitude(altitude);
|
|
||||||
tryBuild(builder, false);
|
|
||||||
|
|
||||||
builder.setAzimuth(azimuth);
|
|
||||||
AngleOfArrivalMeasurement measurement = tryBuild(builder, true);
|
|
||||||
|
|
||||||
assertEquals(azimuth, measurement.getAzimuth());
|
|
||||||
assertEquals(altitude, measurement.getAltitude());
|
|
||||||
}
|
|
||||||
|
|
||||||
private AngleMeasurement getAngleMeasurement(double radian, double error, double confidence) {
|
|
||||||
return new AngleMeasurement.Builder()
|
|
||||||
.setRadians(radian)
|
|
||||||
.setErrorRadians(error)
|
|
||||||
.setConfidenceLevel(confidence)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private AngleOfArrivalMeasurement tryBuild(AngleOfArrivalMeasurement.Builder builder,
|
|
||||||
boolean expectSuccess) {
|
|
||||||
AngleOfArrivalMeasurement measurement = null;
|
|
||||||
try {
|
|
||||||
measurement = builder.build();
|
|
||||||
if (!expectSuccess) {
|
|
||||||
fail("Expected AngleOfArrivalMeasurement.Builder.build() to fail");
|
|
||||||
}
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
if (expectSuccess) {
|
|
||||||
fail("Expected AngleOfArrivalMeasurement.Builder.build() to succeed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return measurement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcel() {
|
|
||||||
Parcel parcel = Parcel.obtain();
|
|
||||||
AngleOfArrivalMeasurement measurement = UwbTestUtils.getAngleOfArrivalMeasurement();
|
|
||||||
measurement.writeToParcel(parcel, 0);
|
|
||||||
parcel.setDataPosition(0);
|
|
||||||
AngleOfArrivalMeasurement fromParcel =
|
|
||||||
AngleOfArrivalMeasurement.CREATOR.createFromParcel(parcel);
|
|
||||||
assertEquals(measurement, fromParcel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020 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.uwb;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test of {@link DistanceMeasurement}.
|
|
||||||
*/
|
|
||||||
@SmallTest
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class DistanceMeasurementTest {
|
|
||||||
private static final double EPSILON = 0.00000000001;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilder() {
|
|
||||||
double meters = 0.12;
|
|
||||||
double error = 0.54;
|
|
||||||
double confidence = 0.99;
|
|
||||||
|
|
||||||
DistanceMeasurement.Builder builder = new DistanceMeasurement.Builder();
|
|
||||||
tryBuild(builder, false);
|
|
||||||
|
|
||||||
builder.setMeters(meters);
|
|
||||||
tryBuild(builder, false);
|
|
||||||
|
|
||||||
builder.setErrorMeters(error);
|
|
||||||
tryBuild(builder, false);
|
|
||||||
|
|
||||||
builder.setConfidenceLevel(confidence);
|
|
||||||
DistanceMeasurement measurement = tryBuild(builder, true);
|
|
||||||
|
|
||||||
assertEquals(meters, measurement.getMeters(), 0);
|
|
||||||
assertEquals(error, measurement.getErrorMeters(), 0);
|
|
||||||
assertEquals(confidence, measurement.getConfidenceLevel(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private DistanceMeasurement tryBuild(DistanceMeasurement.Builder builder,
|
|
||||||
boolean expectSuccess) {
|
|
||||||
DistanceMeasurement measurement = null;
|
|
||||||
try {
|
|
||||||
measurement = builder.build();
|
|
||||||
if (!expectSuccess) {
|
|
||||||
fail("Expected DistanceMeasurement.Builder.build() to fail");
|
|
||||||
}
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
if (expectSuccess) {
|
|
||||||
fail("Expected DistanceMeasurement.Builder.build() to succeed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return measurement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcel() {
|
|
||||||
Parcel parcel = Parcel.obtain();
|
|
||||||
DistanceMeasurement measurement = UwbTestUtils.getDistanceMeasurement();
|
|
||||||
measurement.writeToParcel(parcel, 0);
|
|
||||||
parcel.setDataPosition(0);
|
|
||||||
DistanceMeasurement fromParcel =
|
|
||||||
DistanceMeasurement.CREATOR.createFromParcel(parcel);
|
|
||||||
assertEquals(measurement, fromParcel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020 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.uwb;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.SystemClock;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test of {@link RangingMeasurement}.
|
|
||||||
*/
|
|
||||||
@SmallTest
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class RangingMeasurementTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilder() {
|
|
||||||
int status = RangingMeasurement.RANGING_STATUS_SUCCESS;
|
|
||||||
UwbAddress address = UwbTestUtils.getUwbAddress(false);
|
|
||||||
long time = SystemClock.elapsedRealtimeNanos();
|
|
||||||
AngleOfArrivalMeasurement angleMeasurement = UwbTestUtils.getAngleOfArrivalMeasurement();
|
|
||||||
DistanceMeasurement distanceMeasurement = UwbTestUtils.getDistanceMeasurement();
|
|
||||||
|
|
||||||
RangingMeasurement.Builder builder = new RangingMeasurement.Builder();
|
|
||||||
|
|
||||||
builder.setStatus(status);
|
|
||||||
tryBuild(builder, false);
|
|
||||||
|
|
||||||
builder.setElapsedRealtimeNanos(time);
|
|
||||||
tryBuild(builder, false);
|
|
||||||
|
|
||||||
builder.setAngleOfArrivalMeasurement(angleMeasurement);
|
|
||||||
tryBuild(builder, false);
|
|
||||||
|
|
||||||
builder.setDistanceMeasurement(distanceMeasurement);
|
|
||||||
tryBuild(builder, false);
|
|
||||||
|
|
||||||
builder.setRemoteDeviceAddress(address);
|
|
||||||
RangingMeasurement measurement = tryBuild(builder, true);
|
|
||||||
|
|
||||||
assertEquals(status, measurement.getStatus());
|
|
||||||
assertEquals(address, measurement.getRemoteDeviceAddress());
|
|
||||||
assertEquals(time, measurement.getElapsedRealtimeNanos());
|
|
||||||
assertEquals(angleMeasurement, measurement.getAngleOfArrivalMeasurement());
|
|
||||||
assertEquals(distanceMeasurement, measurement.getDistanceMeasurement());
|
|
||||||
}
|
|
||||||
|
|
||||||
private RangingMeasurement tryBuild(RangingMeasurement.Builder builder,
|
|
||||||
boolean expectSuccess) {
|
|
||||||
RangingMeasurement measurement = null;
|
|
||||||
try {
|
|
||||||
measurement = builder.build();
|
|
||||||
if (!expectSuccess) {
|
|
||||||
fail("Expected RangingMeasurement.Builder.build() to fail");
|
|
||||||
}
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
if (expectSuccess) {
|
|
||||||
fail("Expected DistanceMeasurement.Builder.build() to succeed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return measurement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcel() {
|
|
||||||
Parcel parcel = Parcel.obtain();
|
|
||||||
RangingMeasurement measurement = UwbTestUtils.getRangingMeasurement();
|
|
||||||
measurement.writeToParcel(parcel, 0);
|
|
||||||
parcel.setDataPosition(0);
|
|
||||||
RangingMeasurement fromParcel = RangingMeasurement.CREATOR.createFromParcel(parcel);
|
|
||||||
assertEquals(measurement, fromParcel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020 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.uwb;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test of {@link RangingReport}.
|
|
||||||
*/
|
|
||||||
@SmallTest
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class RangingReportTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilder() {
|
|
||||||
List<RangingMeasurement> measurements = UwbTestUtils.getRangingMeasurements(5);
|
|
||||||
|
|
||||||
RangingReport.Builder builder = new RangingReport.Builder();
|
|
||||||
builder.addMeasurements(measurements);
|
|
||||||
RangingReport report = tryBuild(builder, true);
|
|
||||||
verifyMeasurementsEqual(measurements, report.getMeasurements());
|
|
||||||
|
|
||||||
|
|
||||||
builder = new RangingReport.Builder();
|
|
||||||
for (RangingMeasurement measurement : measurements) {
|
|
||||||
builder.addMeasurement(measurement);
|
|
||||||
}
|
|
||||||
report = tryBuild(builder, true);
|
|
||||||
verifyMeasurementsEqual(measurements, report.getMeasurements());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifyMeasurementsEqual(List<RangingMeasurement> expected,
|
|
||||||
List<RangingMeasurement> actual) {
|
|
||||||
assertEquals(expected.size(), actual.size());
|
|
||||||
for (int i = 0; i < expected.size(); i++) {
|
|
||||||
assertEquals(expected.get(i), actual.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private RangingReport tryBuild(RangingReport.Builder builder,
|
|
||||||
boolean expectSuccess) {
|
|
||||||
RangingReport report = null;
|
|
||||||
try {
|
|
||||||
report = builder.build();
|
|
||||||
if (!expectSuccess) {
|
|
||||||
fail("Expected RangingReport.Builder.build() to fail");
|
|
||||||
}
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
if (expectSuccess) {
|
|
||||||
fail("Expected RangingReport.Builder.build() to succeed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return report;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcel() {
|
|
||||||
Parcel parcel = Parcel.obtain();
|
|
||||||
RangingReport report = UwbTestUtils.getRangingReports(5);
|
|
||||||
report.writeToParcel(parcel, 0);
|
|
||||||
parcel.setDataPosition(0);
|
|
||||||
RangingReport fromParcel = RangingReport.CREATOR.createFromParcel(parcel);
|
|
||||||
assertEquals(report, fromParcel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,378 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2020 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.uwb;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
|
||||||
import static org.mockito.Mockito.doAnswer;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.times;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
import android.os.PersistableBundle;
|
|
||||||
import android.os.RemoteException;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
|
||||||
import org.mockito.stubbing.Answer;
|
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test of {@link RangingSession}.
|
|
||||||
*/
|
|
||||||
@SmallTest
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class RangingSessionTest {
|
|
||||||
private static final Executor EXECUTOR = UwbTestUtils.getExecutor();
|
|
||||||
private static final PersistableBundle PARAMS = new PersistableBundle();
|
|
||||||
private static final @RangingSession.Callback.Reason int REASON =
|
|
||||||
RangingSession.Callback.REASON_GENERIC_ERROR;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testOnRangingOpened_OnOpenSuccessCalled() {
|
|
||||||
SessionHandle handle = new SessionHandle(123);
|
|
||||||
RangingSession.Callback callback = mock(RangingSession.Callback.class);
|
|
||||||
IUwbAdapter adapter = mock(IUwbAdapter.class);
|
|
||||||
RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
|
|
||||||
verifyOpenState(session, false);
|
|
||||||
|
|
||||||
session.onRangingOpened();
|
|
||||||
verifyOpenState(session, true);
|
|
||||||
|
|
||||||
// Verify that the onOpenSuccess callback was invoked
|
|
||||||
verify(callback, times(1)).onOpened(eq(session));
|
|
||||||
verify(callback, times(0)).onClosed(anyInt(), any());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testOnRangingOpened_CannotOpenClosedSession() {
|
|
||||||
SessionHandle handle = new SessionHandle(123);
|
|
||||||
RangingSession.Callback callback = mock(RangingSession.Callback.class);
|
|
||||||
IUwbAdapter adapter = mock(IUwbAdapter.class);
|
|
||||||
RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
|
|
||||||
|
|
||||||
session.onRangingOpened();
|
|
||||||
verifyOpenState(session, true);
|
|
||||||
verify(callback, times(1)).onOpened(eq(session));
|
|
||||||
verify(callback, times(0)).onClosed(anyInt(), any());
|
|
||||||
|
|
||||||
session.onRangingClosed(REASON, PARAMS);
|
|
||||||
verifyOpenState(session, false);
|
|
||||||
verify(callback, times(1)).onOpened(eq(session));
|
|
||||||
verify(callback, times(1)).onClosed(anyInt(), any());
|
|
||||||
|
|
||||||
// Now invoke the ranging started callback and ensure the session remains closed
|
|
||||||
session.onRangingOpened();
|
|
||||||
verifyOpenState(session, false);
|
|
||||||
verify(callback, times(1)).onOpened(eq(session));
|
|
||||||
verify(callback, times(1)).onClosed(anyInt(), any());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testOnRangingClosed_OnClosedCalledWhenSessionNotOpen() {
|
|
||||||
SessionHandle handle = new SessionHandle(123);
|
|
||||||
RangingSession.Callback callback = mock(RangingSession.Callback.class);
|
|
||||||
IUwbAdapter adapter = mock(IUwbAdapter.class);
|
|
||||||
RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
|
|
||||||
verifyOpenState(session, false);
|
|
||||||
|
|
||||||
session.onRangingClosed(REASON, PARAMS);
|
|
||||||
verifyOpenState(session, false);
|
|
||||||
|
|
||||||
// Verify that the onOpenSuccess callback was invoked
|
|
||||||
verify(callback, times(0)).onOpened(eq(session));
|
|
||||||
verify(callback, times(1)).onClosed(anyInt(), any());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testOnRangingClosed_OnClosedCalled() {
|
|
||||||
SessionHandle handle = new SessionHandle(123);
|
|
||||||
RangingSession.Callback callback = mock(RangingSession.Callback.class);
|
|
||||||
IUwbAdapter adapter = mock(IUwbAdapter.class);
|
|
||||||
RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
|
|
||||||
session.onRangingStarted(PARAMS);
|
|
||||||
session.onRangingClosed(REASON, PARAMS);
|
|
||||||
verify(callback, times(1)).onClosed(anyInt(), any());
|
|
||||||
|
|
||||||
verifyOpenState(session, false);
|
|
||||||
session.onRangingClosed(REASON, PARAMS);
|
|
||||||
verify(callback, times(2)).onClosed(anyInt(), any());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testOnRangingResult_OnReportReceivedCalled() {
|
|
||||||
SessionHandle handle = new SessionHandle(123);
|
|
||||||
RangingSession.Callback callback = mock(RangingSession.Callback.class);
|
|
||||||
IUwbAdapter adapter = mock(IUwbAdapter.class);
|
|
||||||
RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
|
|
||||||
verifyOpenState(session, false);
|
|
||||||
|
|
||||||
session.onRangingStarted(PARAMS);
|
|
||||||
verifyOpenState(session, true);
|
|
||||||
|
|
||||||
RangingReport report = UwbTestUtils.getRangingReports(1);
|
|
||||||
session.onRangingResult(report);
|
|
||||||
verify(callback, times(1)).onReportReceived(eq(report));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStart_CannotStartIfAlreadyStarted() throws RemoteException {
|
|
||||||
SessionHandle handle = new SessionHandle(123);
|
|
||||||
RangingSession.Callback callback = mock(RangingSession.Callback.class);
|
|
||||||
IUwbAdapter adapter = mock(IUwbAdapter.class);
|
|
||||||
RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
|
|
||||||
doAnswer(new StartAnswer(session)).when(adapter).startRanging(any(), any());
|
|
||||||
session.onRangingOpened();
|
|
||||||
|
|
||||||
session.start(PARAMS);
|
|
||||||
verify(callback, times(1)).onStarted(any());
|
|
||||||
|
|
||||||
// Calling start again should throw an illegal state
|
|
||||||
verifyThrowIllegalState(() -> session.start(PARAMS));
|
|
||||||
verify(callback, times(1)).onStarted(any());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStop_CannotStopIfAlreadyStopped() throws RemoteException {
|
|
||||||
SessionHandle handle = new SessionHandle(123);
|
|
||||||
RangingSession.Callback callback = mock(RangingSession.Callback.class);
|
|
||||||
IUwbAdapter adapter = mock(IUwbAdapter.class);
|
|
||||||
RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
|
|
||||||
doAnswer(new StartAnswer(session)).when(adapter).startRanging(any(), any());
|
|
||||||
doAnswer(new StopAnswer(session)).when(adapter).stopRanging(any());
|
|
||||||
session.onRangingOpened();
|
|
||||||
session.start(PARAMS);
|
|
||||||
|
|
||||||
verifyNoThrowIllegalState(session::stop);
|
|
||||||
verify(callback, times(1)).onStopped();
|
|
||||||
|
|
||||||
// Calling stop again should throw an illegal state
|
|
||||||
verifyThrowIllegalState(session::stop);
|
|
||||||
verify(callback, times(1)).onStopped();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testReconfigure_OnlyWhenOpened() throws RemoteException {
|
|
||||||
SessionHandle handle = new SessionHandle(123);
|
|
||||||
RangingSession.Callback callback = mock(RangingSession.Callback.class);
|
|
||||||
IUwbAdapter adapter = mock(IUwbAdapter.class);
|
|
||||||
RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
|
|
||||||
doAnswer(new StartAnswer(session)).when(adapter).startRanging(any(), any());
|
|
||||||
doAnswer(new ReconfigureAnswer(session)).when(adapter).reconfigureRanging(any(), any());
|
|
||||||
|
|
||||||
verifyThrowIllegalState(() -> session.reconfigure(PARAMS));
|
|
||||||
verify(callback, times(0)).onReconfigured(any());
|
|
||||||
verifyOpenState(session, false);
|
|
||||||
|
|
||||||
session.onRangingOpened();
|
|
||||||
verifyNoThrowIllegalState(() -> session.reconfigure(PARAMS));
|
|
||||||
verify(callback, times(1)).onReconfigured(any());
|
|
||||||
verifyOpenState(session, true);
|
|
||||||
|
|
||||||
session.onRangingStarted(PARAMS);
|
|
||||||
verifyNoThrowIllegalState(() -> session.reconfigure(PARAMS));
|
|
||||||
verify(callback, times(2)).onReconfigured(any());
|
|
||||||
verifyOpenState(session, true);
|
|
||||||
|
|
||||||
session.onRangingStopped();
|
|
||||||
verifyNoThrowIllegalState(() -> session.reconfigure(PARAMS));
|
|
||||||
verify(callback, times(3)).onReconfigured(any());
|
|
||||||
verifyOpenState(session, true);
|
|
||||||
|
|
||||||
|
|
||||||
session.onRangingClosed(REASON, PARAMS);
|
|
||||||
verifyThrowIllegalState(() -> session.reconfigure(PARAMS));
|
|
||||||
verify(callback, times(3)).onReconfigured(any());
|
|
||||||
verifyOpenState(session, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testClose_NoCallbackUntilInvoked() throws RemoteException {
|
|
||||||
SessionHandle handle = new SessionHandle(123);
|
|
||||||
RangingSession.Callback callback = mock(RangingSession.Callback.class);
|
|
||||||
IUwbAdapter adapter = mock(IUwbAdapter.class);
|
|
||||||
RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
|
|
||||||
session.onRangingOpened();
|
|
||||||
|
|
||||||
// Calling close multiple times should invoke closeRanging until the session receives
|
|
||||||
// the onClosed callback.
|
|
||||||
int totalCallsBeforeOnRangingClosed = 3;
|
|
||||||
for (int i = 1; i <= totalCallsBeforeOnRangingClosed; i++) {
|
|
||||||
session.close();
|
|
||||||
verifyOpenState(session, true);
|
|
||||||
verify(adapter, times(i)).closeRanging(handle);
|
|
||||||
verify(callback, times(0)).onClosed(anyInt(), any());
|
|
||||||
}
|
|
||||||
|
|
||||||
// After onClosed is invoked, then the adapter should no longer be called for each call to
|
|
||||||
// the session's close.
|
|
||||||
final int totalCallsAfterOnRangingClosed = 2;
|
|
||||||
for (int i = 1; i <= totalCallsAfterOnRangingClosed; i++) {
|
|
||||||
session.onRangingClosed(REASON, PARAMS);
|
|
||||||
verifyOpenState(session, false);
|
|
||||||
verify(adapter, times(totalCallsBeforeOnRangingClosed)).closeRanging(handle);
|
|
||||||
verify(callback, times(i)).onClosed(anyInt(), any());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testClose_OnClosedCalled() throws RemoteException {
|
|
||||||
SessionHandle handle = new SessionHandle(123);
|
|
||||||
RangingSession.Callback callback = mock(RangingSession.Callback.class);
|
|
||||||
IUwbAdapter adapter = mock(IUwbAdapter.class);
|
|
||||||
RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
|
|
||||||
doAnswer(new CloseAnswer(session)).when(adapter).closeRanging(any());
|
|
||||||
session.onRangingOpened();
|
|
||||||
|
|
||||||
session.close();
|
|
||||||
verify(callback, times(1)).onClosed(anyInt(), any());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testClose_CannotInteractFurther() throws RemoteException {
|
|
||||||
SessionHandle handle = new SessionHandle(123);
|
|
||||||
RangingSession.Callback callback = mock(RangingSession.Callback.class);
|
|
||||||
IUwbAdapter adapter = mock(IUwbAdapter.class);
|
|
||||||
RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
|
|
||||||
doAnswer(new CloseAnswer(session)).when(adapter).closeRanging(any());
|
|
||||||
session.close();
|
|
||||||
|
|
||||||
verifyThrowIllegalState(() -> session.start(PARAMS));
|
|
||||||
verifyThrowIllegalState(() -> session.reconfigure(PARAMS));
|
|
||||||
verifyThrowIllegalState(() -> session.stop());
|
|
||||||
verifyNoThrowIllegalState(() -> session.close());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testOnRangingResult_OnReportReceivedCalledWhenOpen() {
|
|
||||||
SessionHandle handle = new SessionHandle(123);
|
|
||||||
RangingSession.Callback callback = mock(RangingSession.Callback.class);
|
|
||||||
IUwbAdapter adapter = mock(IUwbAdapter.class);
|
|
||||||
RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
|
|
||||||
|
|
||||||
assertFalse(session.isOpen());
|
|
||||||
session.onRangingStarted(PARAMS);
|
|
||||||
assertTrue(session.isOpen());
|
|
||||||
|
|
||||||
// Verify that the onReportReceived callback was invoked
|
|
||||||
RangingReport report = UwbTestUtils.getRangingReports(1);
|
|
||||||
session.onRangingResult(report);
|
|
||||||
verify(callback, times(1)).onReportReceived(report);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testOnRangingResult_OnReportReceivedNotCalledWhenNotOpen() {
|
|
||||||
SessionHandle handle = new SessionHandle(123);
|
|
||||||
RangingSession.Callback callback = mock(RangingSession.Callback.class);
|
|
||||||
IUwbAdapter adapter = mock(IUwbAdapter.class);
|
|
||||||
RangingSession session = new RangingSession(EXECUTOR, callback, adapter, handle);
|
|
||||||
|
|
||||||
assertFalse(session.isOpen());
|
|
||||||
|
|
||||||
// Verify that the onReportReceived callback was invoked
|
|
||||||
RangingReport report = UwbTestUtils.getRangingReports(1);
|
|
||||||
session.onRangingResult(report);
|
|
||||||
verify(callback, times(0)).onReportReceived(report);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifyOpenState(RangingSession session, boolean expected) {
|
|
||||||
assertEquals(expected, session.isOpen());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifyThrowIllegalState(Runnable runnable) {
|
|
||||||
try {
|
|
||||||
runnable.run();
|
|
||||||
fail();
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
// Pass
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifyNoThrowIllegalState(Runnable runnable) {
|
|
||||||
try {
|
|
||||||
runnable.run();
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
fail();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class AdapterAnswer implements Answer {
|
|
||||||
protected RangingSession mSession;
|
|
||||||
|
|
||||||
protected AdapterAnswer(RangingSession session) {
|
|
||||||
mSession = session;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class StartAnswer extends AdapterAnswer {
|
|
||||||
StartAnswer(RangingSession session) {
|
|
||||||
super(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object answer(InvocationOnMock invocation) {
|
|
||||||
mSession.onRangingStarted(PARAMS);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ReconfigureAnswer extends AdapterAnswer {
|
|
||||||
ReconfigureAnswer(RangingSession session) {
|
|
||||||
super(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object answer(InvocationOnMock invocation) {
|
|
||||||
mSession.onRangingReconfigured(PARAMS);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class StopAnswer extends AdapterAnswer {
|
|
||||||
StopAnswer(RangingSession session) {
|
|
||||||
super(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object answer(InvocationOnMock invocation) {
|
|
||||||
mSession.onRangingStopped();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class CloseAnswer extends AdapterAnswer {
|
|
||||||
CloseAnswer(RangingSession session) {
|
|
||||||
super(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object answer(InvocationOnMock invocation) {
|
|
||||||
mSession.onRangingClosed(REASON, PARAMS);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020 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.uwb;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test of {@link SessionHandle}.
|
|
||||||
*/
|
|
||||||
@SmallTest
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class SessionHandleTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBasic() {
|
|
||||||
int handleId = 12;
|
|
||||||
SessionHandle handle = new SessionHandle(handleId);
|
|
||||||
assertEquals(handle.getId(), handleId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcel() {
|
|
||||||
Parcel parcel = Parcel.obtain();
|
|
||||||
SessionHandle handle = new SessionHandle(10);
|
|
||||||
handle.writeToParcel(parcel, 0);
|
|
||||||
parcel.setDataPosition(0);
|
|
||||||
SessionHandle fromParcel = SessionHandle.CREATOR.createFromParcel(parcel);
|
|
||||||
assertEquals(handle, fromParcel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020 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.uwb;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test of {@link UwbAddress}.
|
|
||||||
*/
|
|
||||||
@SmallTest
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class UwbAddressTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFromBytes_Short() {
|
|
||||||
runFromBytes(UwbAddress.SHORT_ADDRESS_BYTE_LENGTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFromBytes_Extended() {
|
|
||||||
runFromBytes(UwbAddress.EXTENDED_ADDRESS_BYTE_LENGTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runFromBytes(int len) {
|
|
||||||
byte[] addressBytes = getByteArray(len);
|
|
||||||
UwbAddress address = UwbAddress.fromBytes(addressBytes);
|
|
||||||
assertEquals(address.size(), len);
|
|
||||||
assertEquals(addressBytes, address.toBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] getByteArray(int len) {
|
|
||||||
byte[] res = new byte[len];
|
|
||||||
for (int i = 0; i < len; i++) {
|
|
||||||
res[i] = (byte) i;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcel_Short() {
|
|
||||||
runParcel(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcel_Extended() {
|
|
||||||
runParcel(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runParcel(boolean useShortAddress) {
|
|
||||||
Parcel parcel = Parcel.obtain();
|
|
||||||
UwbAddress address = UwbTestUtils.getUwbAddress(useShortAddress);
|
|
||||||
address.writeToParcel(parcel, 0);
|
|
||||||
parcel.setDataPosition(0);
|
|
||||||
UwbAddress fromParcel = UwbAddress.CREATOR.createFromParcel(parcel);
|
|
||||||
assertEquals(address, fromParcel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020 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.uwb;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.test.InstrumentationRegistry;
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test of {@link UwbManager}.
|
|
||||||
*/
|
|
||||||
@SmallTest
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class UwbManagerTest {
|
|
||||||
|
|
||||||
public final Context mContext = InstrumentationRegistry.getContext();
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testServiceAvailable() {
|
|
||||||
UwbManager manager = mContext.getSystemService(UwbManager.class);
|
|
||||||
if (UwbTestUtils.isUwbSupported(mContext)) {
|
|
||||||
assertNotNull(manager);
|
|
||||||
} else {
|
|
||||||
assertNull(manager);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user