diff --git a/build.xml b/build.xml index fb92e35..acbaf1f 100644 --- a/build.xml +++ b/build.xml @@ -130,6 +130,18 @@ - + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/se/vidstige/jadb/test/RealDeviceTestCases.java b/test/se/vidstige/jadb/test/RealDeviceTestCases.java index 0bc6e1b..689c404 100644 --- a/test/se/vidstige/jadb/test/RealDeviceTestCases.java +++ b/test/se/vidstige/jadb/test/RealDeviceTestCases.java @@ -1,5 +1,6 @@ package se.vidstige.jadb.test; +import org.junit.Before; import org.junit.Test; import se.vidstige.jadb.JadbConnection; import se.vidstige.jadb.JadbDevice; @@ -8,27 +9,36 @@ import se.vidstige.jadb.RemoteFile; import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.util.List; public class RealDeviceTestCases { + private JadbConnection jadb; + + @Before + public void connect() throws IOException { + try { + jadb = new JadbConnection(); + jadb.getHostVersion(); + } catch (Exception e) { + org.junit.Assume.assumeNoException(e); + } + } + @Test public void testGetHostVersion() throws Exception { - JadbConnection jadb = new JadbConnection(); jadb.getHostVersion(); } @Test public void testGetDevices() throws Exception { - //JadbConnection jadb = new JadbConnection("localhost", 15037); - JadbConnection jadb = new JadbConnection(); List actual = jadb.getDevices(); //Assert.assertEquals("emulator-5554", actual.get(0).getSerial()); } @Test public void testListFilesTwice() throws Exception { - JadbConnection jadb = new JadbConnection(); JadbDevice any = jadb.getAnyDevice(); for (RemoteFile f : any.list("/")) { System.out.println(f.getPath()); @@ -41,7 +51,6 @@ public class RealDeviceTestCases { @Test public void testPushFile() throws Exception { - JadbConnection jadb = new JadbConnection(); JadbDevice any = jadb.getAnyDevice(); any.push(new File("README.md"), new RemoteFile("/sdcard/README.md")); //second read on the same device @@ -50,14 +59,12 @@ public class RealDeviceTestCases { @Test(expected = JadbException.class) public void testPushFileToInvalidPath() throws Exception { - JadbConnection jadb = new JadbConnection(); JadbDevice any = jadb.getAnyDevice(); any.push(new File("README.md"), new RemoteFile("/no/such/directory/README.md")); } @Test public void testPullFile() throws Exception { - JadbConnection jadb = new JadbConnection(); JadbDevice any = jadb.getAnyDevice(); any.pull(new RemoteFile("/sdcard/README.md"), new File("foobar.md")); //second read on the same device @@ -66,14 +73,12 @@ public class RealDeviceTestCases { @Test(expected = JadbException.class) public void testPullInvalidFile() throws Exception { - JadbConnection jadb = new JadbConnection(); JadbDevice any = jadb.getAnyDevice(); any.pull(new RemoteFile("/file/does/not/exist"), new File("xyz")); } @Test public void testShellExecuteTwice() throws Exception { - JadbConnection jadb = new JadbConnection(); JadbDevice any = jadb.getAnyDevice(); any.executeShell(System.out, "ls /"); any.executeShell(System.out, "ls", "-la", "/"); @@ -81,7 +86,6 @@ public class RealDeviceTestCases { @Test public void testScreenshot() throws Exception { - JadbConnection jadb = new JadbConnection(); JadbDevice any = jadb.getAnyDevice(); FileOutputStream outputStream = new FileOutputStream(new File("screenshot.png")); any.executeShell(outputStream, "screencap", "-p");