mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-825 Add connection tests for TCP and USB
This commit is contained in:
parent
13cb5b8fbb
commit
1d96dfd30e
@ -23,7 +23,6 @@
|
||||
*/
|
||||
package org.openpilot.androidgcs.test.telemetryservice;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.openpilot.androidgcs.telemetry.HidUAVTalk;
|
||||
import org.openpilot.androidgcs.telemetry.TcpUAVTalk;
|
||||
import org.openpilot.androidgcs.telemetry.BluetoothUAVTalk;
|
||||
@ -42,6 +41,9 @@ import android.test.mock.MockContext;
|
||||
public class OPTelemetryServiceTests extends
|
||||
ServiceTestCase<OPTelemetryService> {
|
||||
|
||||
private static final int PREF_BLUETOOTH_CONN = 2;
|
||||
private static final int PREF_TCP_CONN = 3;
|
||||
private static final int PREF_USB_CONN = 4;
|
||||
private Object _syncTelemetryTaskStarted = new Object();
|
||||
private Object _syncTelemetryConnected = new Object();
|
||||
private BroadcastReceiver _connectBroadcastReceiver;
|
||||
@ -130,13 +132,13 @@ public class OPTelemetryServiceTests extends
|
||||
}
|
||||
|
||||
public void testStartBluetoothTelemetryTask(){
|
||||
LocalBinder binder = startTelemetryTask(Integer.valueOf(2));
|
||||
LocalBinder binder = startTelemetryTask(Integer.valueOf(PREF_BLUETOOTH_CONN));
|
||||
|
||||
assertTrue("Started wrong telemetry service type", binder.getTelemetryTask(0) instanceof BluetoothUAVTalk);
|
||||
}
|
||||
|
||||
public void testStartBluetoothConnection() throws InterruptedException{
|
||||
LocalBinder binder = startTelemetryTask(Integer.valueOf(2));
|
||||
LocalBinder binder = startTelemetryTask(Integer.valueOf(PREF_BLUETOOTH_CONN));
|
||||
|
||||
synchronized (_syncTelemetryConnected) {
|
||||
_syncTelemetryConnected.wait(2000);
|
||||
@ -148,17 +150,41 @@ public class OPTelemetryServiceTests extends
|
||||
}
|
||||
|
||||
public void testStartTCPTelemetryTask(){
|
||||
LocalBinder binder = startTelemetryTask(Integer.valueOf(3));
|
||||
LocalBinder binder = startTelemetryTask(Integer.valueOf(PREF_TCP_CONN));
|
||||
|
||||
assertTrue("Started wrong telemetry service type", binder.getTelemetryTask(0) instanceof TcpUAVTalk);
|
||||
}
|
||||
|
||||
public void testStartTCPConnection() throws InterruptedException{
|
||||
LocalBinder binder = startTelemetryTask(Integer.valueOf(PREF_TCP_CONN));
|
||||
|
||||
synchronized (_syncTelemetryConnected) {
|
||||
_syncTelemetryConnected.wait(2000);
|
||||
}
|
||||
|
||||
assertTrue("Failed to connect to telemetry service", binder.isConnected());
|
||||
|
||||
assertTrue("Started wrong telemetry service type", binder.getTelemetryTask(0) instanceof TcpUAVTalk);
|
||||
}
|
||||
|
||||
public void testStartUSBTelemetryTask(){
|
||||
LocalBinder binder = startTelemetryTask(Integer.valueOf(4));
|
||||
LocalBinder binder = startTelemetryTask(Integer.valueOf(PREF_USB_CONN));
|
||||
|
||||
assertTrue("Started wrong telemetry service type", binder.getTelemetryTask(0) instanceof HidUAVTalk);
|
||||
}
|
||||
|
||||
public void testStartUSBConnection() throws InterruptedException{
|
||||
LocalBinder binder = startTelemetryTask(Integer.valueOf(PREF_USB_CONN));
|
||||
|
||||
synchronized (_syncTelemetryConnected) {
|
||||
_syncTelemetryConnected.wait(2000);
|
||||
}
|
||||
|
||||
assertTrue("Failed to connect to telemetry service", binder.isConnected());
|
||||
|
||||
assertTrue("Started wrong telemetry service type", binder.getTelemetryTask(0) instanceof HidUAVTalk);
|
||||
}
|
||||
|
||||
private LocalBinder startTelemetryTask(Integer telemetryType) {
|
||||
LocalBinder binder = (LocalBinder) bindService(new Intent(getContext(),
|
||||
org.openpilot.androidgcs.telemetry.OPTelemetryService.class));
|
||||
|
Loading…
x
Reference in New Issue
Block a user