mirror of
https://github.com/revanced/jadb.git
synced 2025-02-14 11:06:48 +01:00
Merge pull request #5 from vidstige/gi-tests-rebased
Runs tests as part of travis build
This commit is contained in:
commit
58db71039d
14
build.xml
14
build.xml
@ -130,6 +130,18 @@
|
|||||||
<target name="all" depends="build.modules, build.all.artifacts" description="build all"/>
|
<target name="all" depends="build.modules, build.all.artifacts" description="build all"/>
|
||||||
|
|
||||||
<target name="test" depends="build.modules">
|
<target name="test" depends="build.modules">
|
||||||
|
<junit haltonfailure="yes">
|
||||||
|
<classpath>
|
||||||
|
<pathelement path="bin/"/>
|
||||||
|
<pathelement location="lib/junit-4.10.jar"/>
|
||||||
|
</classpath>
|
||||||
|
<formatter type="plain" usefile="false" />
|
||||||
|
<batchtest>
|
||||||
|
<fileset dir="test/">
|
||||||
|
<include name="**/*TestCases.java" />
|
||||||
|
<include name="**/*Fixture.java" />
|
||||||
|
</fileset>
|
||||||
|
</batchtest>
|
||||||
|
</junit>
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
@ -1,5 +1,6 @@
|
|||||||
package se.vidstige.jadb.test;
|
package se.vidstige.jadb.test;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import se.vidstige.jadb.JadbConnection;
|
import se.vidstige.jadb.JadbConnection;
|
||||||
import se.vidstige.jadb.JadbDevice;
|
import se.vidstige.jadb.JadbDevice;
|
||||||
@ -8,27 +9,36 @@ import se.vidstige.jadb.RemoteFile;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class RealDeviceTestCases {
|
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
|
@Test
|
||||||
public void testGetHostVersion() throws Exception {
|
public void testGetHostVersion() throws Exception {
|
||||||
JadbConnection jadb = new JadbConnection();
|
|
||||||
jadb.getHostVersion();
|
jadb.getHostVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDevices() throws Exception {
|
public void testGetDevices() throws Exception {
|
||||||
//JadbConnection jadb = new JadbConnection("localhost", 15037);
|
|
||||||
JadbConnection jadb = new JadbConnection();
|
|
||||||
List<JadbDevice> actual = jadb.getDevices();
|
List<JadbDevice> actual = jadb.getDevices();
|
||||||
//Assert.assertEquals("emulator-5554", actual.get(0).getSerial());
|
//Assert.assertEquals("emulator-5554", actual.get(0).getSerial());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListFilesTwice() throws Exception {
|
public void testListFilesTwice() throws Exception {
|
||||||
JadbConnection jadb = new JadbConnection();
|
|
||||||
JadbDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
for (RemoteFile f : any.list("/")) {
|
for (RemoteFile f : any.list("/")) {
|
||||||
System.out.println(f.getPath());
|
System.out.println(f.getPath());
|
||||||
@ -41,7 +51,6 @@ public class RealDeviceTestCases {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPushFile() throws Exception {
|
public void testPushFile() throws Exception {
|
||||||
JadbConnection jadb = new JadbConnection();
|
|
||||||
JadbDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
any.push(new File("README.md"), new RemoteFile("/sdcard/README.md"));
|
any.push(new File("README.md"), new RemoteFile("/sdcard/README.md"));
|
||||||
//second read on the same device
|
//second read on the same device
|
||||||
@ -50,14 +59,12 @@ public class RealDeviceTestCases {
|
|||||||
|
|
||||||
@Test(expected = JadbException.class)
|
@Test(expected = JadbException.class)
|
||||||
public void testPushFileToInvalidPath() throws Exception {
|
public void testPushFileToInvalidPath() throws Exception {
|
||||||
JadbConnection jadb = new JadbConnection();
|
|
||||||
JadbDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
any.push(new File("README.md"), new RemoteFile("/no/such/directory/README.md"));
|
any.push(new File("README.md"), new RemoteFile("/no/such/directory/README.md"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPullFile() throws Exception {
|
public void testPullFile() throws Exception {
|
||||||
JadbConnection jadb = new JadbConnection();
|
|
||||||
JadbDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
any.pull(new RemoteFile("/sdcard/README.md"), new File("foobar.md"));
|
any.pull(new RemoteFile("/sdcard/README.md"), new File("foobar.md"));
|
||||||
//second read on the same device
|
//second read on the same device
|
||||||
@ -66,14 +73,12 @@ public class RealDeviceTestCases {
|
|||||||
|
|
||||||
@Test(expected = JadbException.class)
|
@Test(expected = JadbException.class)
|
||||||
public void testPullInvalidFile() throws Exception {
|
public void testPullInvalidFile() throws Exception {
|
||||||
JadbConnection jadb = new JadbConnection();
|
|
||||||
JadbDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
any.pull(new RemoteFile("/file/does/not/exist"), new File("xyz"));
|
any.pull(new RemoteFile("/file/does/not/exist"), new File("xyz"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShellExecuteTwice() throws Exception {
|
public void testShellExecuteTwice() throws Exception {
|
||||||
JadbConnection jadb = new JadbConnection();
|
|
||||||
JadbDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
any.executeShell(System.out, "ls /");
|
any.executeShell(System.out, "ls /");
|
||||||
any.executeShell(System.out, "ls", "-la", "/");
|
any.executeShell(System.out, "ls", "-la", "/");
|
||||||
@ -81,7 +86,6 @@ public class RealDeviceTestCases {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testScreenshot() throws Exception {
|
public void testScreenshot() throws Exception {
|
||||||
JadbConnection jadb = new JadbConnection();
|
|
||||||
JadbDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
FileOutputStream outputStream = new FileOutputStream(new File("screenshot.png"));
|
FileOutputStream outputStream = new FileOutputStream(new File("screenshot.png"));
|
||||||
any.executeShell(outputStream, "screencap", "-p");
|
any.executeShell(outputStream, "screencap", "-p");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user