mirror of
https://github.com/revanced/jadb.git
synced 2025-05-16 22:17:07 +02:00
commit
9c6dfc2220
@ -2,7 +2,9 @@ package se.vidstige.jadb.test;
|
|||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
import se.vidstige.jadb.*;
|
import se.vidstige.jadb.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -15,6 +17,9 @@ public class RealDeviceTestCases {
|
|||||||
|
|
||||||
private JadbConnection jadb;
|
private JadbConnection jadb;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public TemporaryFolder temporaryFolder = new TemporaryFolder(); //Must be public
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void tryToStartAdbServer() {
|
public static void tryToStartAdbServer() {
|
||||||
try {
|
try {
|
||||||
@ -76,15 +81,15 @@ public class RealDeviceTestCases {
|
|||||||
@Test
|
@Test
|
||||||
public void testPullFile() throws Exception {
|
public void testPullFile() throws Exception {
|
||||||
JadbDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
any.pull(new RemoteFile("/sdcard/README.md"), new File("out/foobar.md"));
|
any.pull(new RemoteFile("/sdcard/README.md"), temporaryFolder.newFile("foobar.md"));
|
||||||
//second read on the same device
|
//second read on the same device
|
||||||
any.pull(new RemoteFile("/sdcard/README.md"), new File("out/foobar.md"));
|
any.pull(new RemoteFile("/sdcard/README.md"), temporaryFolder.newFile("foobar.md"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = JadbException.class)
|
@Test(expected = JadbException.class)
|
||||||
public void testPullInvalidFile() throws Exception {
|
public void testPullInvalidFile() throws Exception {
|
||||||
JadbDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
any.pull(new RemoteFile("/file/does/not/exist"), new File("out/xyz"));
|
any.pull(new RemoteFile("/file/does/not/exist"), temporaryFolder.newFile("xyz"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -99,7 +104,7 @@ public class RealDeviceTestCases {
|
|||||||
JadbDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
FileOutputStream outputStream = null;
|
FileOutputStream outputStream = null;
|
||||||
try {
|
try {
|
||||||
outputStream = new FileOutputStream(new File("out/screenshot.png"));
|
outputStream = new FileOutputStream(temporaryFolder.newFile("screenshot.png"));
|
||||||
InputStream stdout = any.executeShell("screencap", "-p");
|
InputStream stdout = any.executeShell("screencap", "-p");
|
||||||
Stream.copy(stdout, outputStream);
|
Stream.copy(stdout, outputStream);
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user