diff --git a/androidgcs/.classpath b/androidgcs/.classpath index c88f96260..9e9c6b0d0 100644 --- a/androidgcs/.classpath +++ b/androidgcs/.classpath @@ -2,7 +2,6 @@ - diff --git a/androidgcs/tests/org/openpilot/uavtalk/DataObjectTest.java b/androidgcs/tests/org/openpilot/uavtalk/DataObjectTest.java deleted file mode 100644 index 3efa7d300..000000000 --- a/androidgcs/tests/org/openpilot/uavtalk/DataObjectTest.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.openpilot.uavtalk; - -import static org.junit.Assert.*; - -import java.nio.ByteBuffer; -import java.util.Observer; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.openpilot.uavtalk.uavobjects.ActuatorCommand; -import org.openpilot.uavtalk.uavobjects.UAVObjectsInitialize; - -public class DataObjectTest { - - boolean succeed = false; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @Test - public void testUpdatedObserver() { - - succeed = false; - - UAVObject obj = new ActuatorCommand(); - obj.addUpdatedObserver( new Observer() { - - public void update(java.util.Observable observable, Object data) { - System.out.println("Updated: " + data.toString()); - succeed = true; - } - }); - obj.updated(); - - if(!succeed) - fail("No callback"); - - System.out.println("Done"); - - } - - @Test - public void testUpdatedViaObjMngr() { - succeed = false; - - UAVObjectManager objMngr = new UAVObjectManager(); - UAVObjectsInitialize.register(objMngr); - - UAVObject obj = objMngr.getObject("FlightTelemetryStats"); - obj.addUpdatedObserver( new Observer() { - - public void update(java.util.Observable observable, Object data) { - System.out.println("Updated: " + data.toString()); - succeed = true; - } - }); - objMngr.getObject("FlightTelemetryStats").updated(); - - if(!succeed) - fail("No callback"); - System.out.println("Done"); - - } - - @Test - public void testUnpackedViaObjMngr() { - succeed = false; - - UAVObjectManager objMngr = new UAVObjectManager(); - UAVObjectsInitialize.register(objMngr); - - UAVObject obj = objMngr.getObject("FlightTelemetryStats"); - obj.addUnpackedObserver( new Observer() { - - public void update(java.util.Observable observable, Object data) { - System.out.println("Updated: " + data.toString()); - succeed = true; - } - }); - - ByteBuffer bbuf = ByteBuffer.allocate(obj.getNumBytes()); - objMngr.getObject("FlightTelemetryStats").unpack(bbuf); - - if(!succeed) - fail("No callback"); - - System.out.println("Done"); - - } - - -} diff --git a/androidgcs/tests/org/openpilot/uavtalk/FieldTest.java b/androidgcs/tests/org/openpilot/uavtalk/FieldTest.java deleted file mode 100644 index 2d161fc25..000000000 --- a/androidgcs/tests/org/openpilot/uavtalk/FieldTest.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.openpilot.uavtalk; - -import static org.junit.Assert.*; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - -import org.junit.BeforeClass; -import org.junit.Test; - -import org.openpilot.uavtalk.UAVObjectField; -import org.openpilot.uavtalk.UAVObject; -import org.openpilot.uavtalk.uavobjects.*; - -public class FieldTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @Test - public void testPackUint16() { - // Need an object initialized to the field to provide metadata - UAVObject obj = null; - try { - obj = new ActuatorCommand(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - UAVObjectField field = new UAVObjectField("TestField", "No Units", UAVObjectField.FieldType.UINT16, 3, null); - field.initialize(obj); - field.setValue(3,0); - field.setValue(-50,1); - field.setValue(5003585,2); - - ByteBuffer bbuf = ByteBuffer.allocate(field.getNumBytes()); - - try { - field.pack(bbuf); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - fail("Buffer size incorrect"); - } - - // Expect data to come out as little endian - byte[] expected = {3,0,0,0,(byte) 0xff,(byte) 0xff}; - for(int i = 0; i < expected.length && i < bbuf.array().length; i++) { - System.out.println("Expected: " + expected[i] + " (" + i + ")"); - System.out.println("Received: " + bbuf.array()[i] + " (" + i + ")"); - assertEquals(bbuf.array()[i],expected[i]); - } - } - - @Test - public void testUnpackUint16() { - // Need an object initialized to the field to provide metadata - UAVObject obj = null; - obj = new ActuatorCommand(); - UAVObjectField field = new UAVObjectField("TestField", "No Units", UAVObjectField.FieldType.UINT16, 3, null); - field.initialize(obj); - - ByteBuffer bbuf = ByteBuffer.allocate(field.getNumBytes()); - byte[] expected = {3,0,0,0,(byte) 0xff,(byte) 0xff}; - bbuf.put(expected); - bbuf.position(0); - field.unpack(bbuf); - - assertEquals(field.getValue(0), 3); - assertEquals(field.getValue(1), 0); - assertEquals(field.getValue(2), 65535); - } - - @Test - public void testEnumSetGetValue() { - List options = new ArrayList(); - options.add("Opt1"); - options.add("Opt2"); - options.add("Opt3"); - - // Need an object initialized to the field to provide metadata - UAVObject obj = null; - try { - obj = new ActuatorCommand(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - UAVObjectField field = new UAVObjectField("TestField", "No Units", UAVObjectField.FieldType.ENUM, 3, options); - field.initialize(obj); - field.setValue("Opt1",0); - field.setValue("Opt2",1); - field.setValue("Opt3",2); - assertEquals(field.getValue(0), "Opt1"); - assertEquals(field.getValue(1), "Opt2"); - assertEquals(field.getValue(2), "Opt3"); - } - - @Test - public void testUint16SetGetValue() { - - // Need an object initialized to the field to provide metadata - UAVObject obj = null; - try { - obj = new ActuatorCommand(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - UAVObjectField field = new UAVObjectField("TestField", "No Units", UAVObjectField.FieldType.UINT16, 3, null); - field.initialize(obj); - field.setValue(3,0); - field.setValue(-50,1); - field.setValue(5003585,2); - assertEquals(field.getValue(0), 3); - assertEquals(field.getValue(1), 0); - assertEquals(field.getValue(2), 65535); - } -} diff --git a/androidgcs/tests/org/openpilot/uavtalk/ObjMngrTest.java b/androidgcs/tests/org/openpilot/uavtalk/ObjMngrTest.java deleted file mode 100644 index 57e641c96..000000000 --- a/androidgcs/tests/org/openpilot/uavtalk/ObjMngrTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.openpilot.uavtalk; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.openpilot.uavtalk.uavobjects.UAVObjectsInitialize; - -public class ObjMngrTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @Test - public void testGetObjects() { - UAVObjectManager objMngr = new UAVObjectManager(); - UAVObjectsInitialize.register(objMngr); -// System.out.println(objMngr.getObject("ActuatorSettings", 0)); - } - -} diff --git a/androidgcs/tests/org/openpilot/uavtalk/SettingsTest.java b/androidgcs/tests/org/openpilot/uavtalk/SettingsTest.java deleted file mode 100644 index 5a805ae88..000000000 --- a/androidgcs/tests/org/openpilot/uavtalk/SettingsTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.openpilot.uavtalk; - -import static org.junit.Assert.*; - -import org.junit.BeforeClass; -import org.junit.Test; - -public class SettingsTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @Test - public void testGetDefaultMetadata() { - fail("Not yet implemented"); - } - - @Test - public void testSetDefaultFieldValues() { - fail("Not yet implemented"); - } - - @Test - public void testIsSettings() { - fail("Not yet implemented"); - } - - @Test - public void testGetField() { - fail("Not yet implemented"); - } - -} diff --git a/androidgcs/tests/org/openpilot/uavtalk/TalkTest.java b/androidgcs/tests/org/openpilot/uavtalk/TalkTest.java deleted file mode 100644 index 5e6186442..000000000 --- a/androidgcs/tests/org/openpilot/uavtalk/TalkTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.openpilot.uavtalk; -import static org.junit.Assert.*; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.net.InetAddress; -import java.net.Socket; -import java.util.Observable; -import java.util.Observer; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.openpilot.uavtalk.uavobjects.UAVObjectsInitialize; -import org.openpilot.uavtalk.UAVTalk; - - -public class TalkTest { - - static UAVObjectManager objMngr; - static final String IP_ADDRDESS = new String("127.0.0.1"); - static final int PORT_NUM = 7777; - boolean succeed = false; - - byte[] flightStatsConnected = - {0x3c,0x20,0x1d,0x00, - (byte) 0x5e,(byte) 0x26,(byte) 0x0c,(byte) 0x66, - 0x03,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, - 0x00,(byte) 0xAE}; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - objMngr = new UAVObjectManager(); - UAVObjectsInitialize.register(objMngr); - } - - //@Test - public void testGetFlightStatus() { - Socket connection = null; - UAVTalk talk = null; - try{ - InetAddress ip = InetAddress.getByName(IP_ADDRDESS); - connection = new Socket(ip, PORT_NUM); - } catch (Exception e) { - e.printStackTrace(); - fail("Couldn't connect to test platform"); - } - - try { - talk = new UAVTalk(connection.getInputStream(), connection.getOutputStream(), objMngr); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - fail("Couldn't construct UAVTalk object"); - } - - Thread inputStream = talk.getInputProcessThread(); - inputStream.start(); - - succeed = false; - - UAVObject obj = objMngr.getObject("FlightTelemetryStats"); - - obj.addUpdatedObserver( new Observer() { - public void update(Observable observable, Object data) { - // TODO Auto-generated method stub - System.out.println("Updated: " + data.toString()); - succeed = true; - } - }); - - try { - Thread.sleep(1000); - } catch (InterruptedException e1) { - } - - if(!succeed) - fail("Never received a FlightTelemetryStats update"); - - } - - @Test - public void testSendObjectRequest() throws IOException { - ByteArrayInputStream is = new ByteArrayInputStream(new byte[0], 0, 0); - ByteArrayOutputStream os = new ByteArrayOutputStream(100); - - UAVTalk talk = new UAVTalk(is,os,objMngr); - UAVObject obj = objMngr.getObject("FlightTelemetryStats"); - obj.getField("Status").setValue("Connected"); - - talk.sendObject(obj, false, false); - - System.out.println("Size: " + os.size()); - byte [] array = os.toByteArray(); - for(int i = 0; i < array.length; i++) { - System.out.print("0x" + Integer.toHexString((int) array[i] & 0xff)); - System.out.print("/0x" + Integer.toHexString((int) flightStatsConnected[i] & 0xff)); - if(i != array.length-1) - System.out.print("\n"); - } - System.out.print("\n"); - for(int i = 0; i < array.length; i++) - assertEquals(os.toByteArray()[i], flightStatsConnected[i]); - } - - @Test - public void testReceiveObject() throws InterruptedException { - ByteArrayInputStream is = new ByteArrayInputStream(flightStatsConnected, 0, flightStatsConnected.length); - ByteArrayOutputStream os = new ByteArrayOutputStream(100); - - // Make the Status wrong initially - UAVObject obj = objMngr.getObject("FlightTelemetryStats"); - obj.getField("Status").setValue("Disconnected"); - - // Test receiving from that stream - UAVTalk talk = new UAVTalk(is,os,objMngr); - Thread inputStream = talk.getInputProcessThread(); - inputStream.start(); - - Thread.sleep(1000); - - System.out.println("Should be FlightTelemetry Stats:"); - System.out.println(objMngr.getObject("FlightTelemetryStats").toString()); - - assertEquals(obj.getField("Status").getValue(), new String("Connected")); - } - - -} diff --git a/androidgcs/tests/org/openpilot/uavtalk/TelemetryMonitorTest.java b/androidgcs/tests/org/openpilot/uavtalk/TelemetryMonitorTest.java deleted file mode 100644 index 6ddcfe03e..000000000 --- a/androidgcs/tests/org/openpilot/uavtalk/TelemetryMonitorTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.openpilot.uavtalk; - -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.Socket; - -import org.junit.Test; -import org.openpilot.uavtalk.uavobjects.UAVObjectsInitialize; - -import android.os.Looper; - - -public class TelemetryMonitorTest { - - static UAVObjectManager objMngr; - static UAVTalk talk; - static final String IP_ADDRDESS = new String("127.0.0.1"); - static final int PORT_NUM = 7777; - static Socket connection = null; - boolean succeed = false; - - @Test - public void testTelemetry() throws Exception { - objMngr = new UAVObjectManager(); - UAVObjectsInitialize.register(objMngr); - talk = null; - try{ - InetAddress ip = InetAddress.getByName(IP_ADDRDESS); - connection = new Socket(ip, PORT_NUM); - } catch (Exception e) { - e.printStackTrace(); - fail("Couldn't connect to test platform"); - } - - try { - talk = new UAVTalk(connection.getInputStream(), connection.getOutputStream(), objMngr); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - fail("Couldn't construct UAVTalk object"); - } - - Thread inputStream = talk.getInputProcessThread(); - inputStream.start(); - - Looper.prepare(); - Telemetry tel = new Telemetry(talk, objMngr, Looper.myLooper()); - @SuppressWarnings("unused") - TelemetryMonitor mon = new TelemetryMonitor(objMngr,tel); - - Thread.sleep(10000); - - System.out.println("Done"); - } - - -}