mirror of
https://github.com/revanced/jadb.git
synced 2025-06-12 13:17:39 +02:00
Filtering out 0x0d, 0x0a sequences from shell commands. Makes screenshotting work again. :-)
This commit is contained in:
44
test/se/vidstige/jadb/test/AdbOutputStreamFixture.java
Normal file
44
test/se/vidstige/jadb/test/AdbOutputStreamFixture.java
Normal file
@ -0,0 +1,44 @@
|
||||
package se.vidstige.jadb.test;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import se.vidstige.jadb.AdbFilterOutputStream;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class AdbOutputStreamFixture {
|
||||
|
||||
private byte[] passthrough(byte[] input) throws IOException {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
OutputStream sut = new AdbFilterOutputStream(output);
|
||||
sut.write(input);
|
||||
sut.flush();
|
||||
return output.toByteArray();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimple() throws Exception {
|
||||
byte[] actual = passthrough(new byte[]{ 1, 2, 3});
|
||||
Assert.assertArrayEquals(new byte[]{ 1, 2, 3}, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmpty() throws Exception {
|
||||
byte[] actual = passthrough(new byte[]{});
|
||||
Assert.assertArrayEquals(new byte[]{}, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleRemoval() throws Exception {
|
||||
byte[] actual = passthrough(new byte[]{0x0d, 0x0a});
|
||||
Assert.assertArrayEquals(new byte[]{0x0a}, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoubleRemoval() throws Exception {
|
||||
byte[] actual = passthrough(new byte[]{0x0d, 0x0a, 0x0d, 0x0a});
|
||||
Assert.assertArrayEquals(new byte[]{0x0a, 0x0a}, actual);
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import se.vidstige.jadb.JadbException;
|
||||
import se.vidstige.jadb.RemoteFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.List;
|
||||
|
||||
public class RealDeviceTestCases {
|
||||
@ -77,4 +78,12 @@ public class RealDeviceTestCases {
|
||||
any.executeShell(System.out, "ls /");
|
||||
any.executeShell(System.out, "ls", "-la", "/");
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user