minor changes to some API

This commit is contained in:
Giemsa 2016-12-09 02:46:03 +09:00 committed by Samuel Carlsson
parent 958e9258d3
commit d1af94d257
2 changed files with 10 additions and 4 deletions

View File

@ -12,11 +12,11 @@ public class JadbConnection implements ITransportFactory {
private static final int DEFAULTPORT = 5037; private static final int DEFAULTPORT = 5037;
public JadbConnection() throws IOException { public JadbConnection() {
this("localhost", DEFAULTPORT); this("localhost", DEFAULTPORT);
} }
public JadbConnection(String host, int port) throws IOException { public JadbConnection(String host, int port) {
this.host = host; this.host = host;
this.port = port; this.port = port;
} }
@ -25,16 +25,17 @@ public class JadbConnection implements ITransportFactory {
return new Transport(new Socket(host, port)); return new Transport(new Socket(host, port));
} }
public void getHostVersion() throws IOException, JadbException { public String getHostVersion() throws IOException, JadbException {
Transport main = createTransport(); Transport main = createTransport();
main.send("host:version"); main.send("host:version");
main.verifyResponse(); main.verifyResponse();
String version = main.readString();
main.close(); main.close();
return version;
} }
public List<JadbDevice> getDevices() throws IOException, JadbException { public List<JadbDevice> getDevices() throws IOException, JadbException {
Transport devices = createTransport(); Transport devices = createTransport();
devices.send("host:devices"); devices.send("host:devices");
devices.verifyResponse(); devices.verifyResponse();
String body = devices.readString(); String body = devices.readString();

View File

@ -36,6 +36,11 @@ public class MockedTestCases {
server.verifyExpectations(); server.verifyExpectations();
} }
@Test
public void testGetHostVersion() throws Exception {
Assert.assertEquals("001f", connection.getHostVersion());
}
@Test @Test
public void testListDevices() throws Exception { public void testListDevices() throws Exception {
server.add("serial-123"); server.add("serial-123");