mirror of
https://github.com/revanced/jadb.git
synced 2025-05-01 23:24:31 +02:00
Asserting no unexpected pushes where sent.
This commit is contained in:
parent
ee239467d0
commit
e93bdb1658
@ -31,6 +31,7 @@ public class MockedTestCases {
|
||||
public void tearDown() throws Exception {
|
||||
connection.close();
|
||||
server.stop();
|
||||
server.verifyExpectations();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,6 +47,10 @@ public class FakeAdbServer implements AdbResponder {
|
||||
devices.add(new DeviceResponder(serial));
|
||||
}
|
||||
|
||||
public void verifyExpectations() {
|
||||
org.junit.Assert.assertEquals(0, remoteFileExpectations.size());
|
||||
}
|
||||
|
||||
private static class RemoteFileExpectation {
|
||||
|
||||
private final String serial;
|
||||
@ -83,7 +87,7 @@ public class FakeAdbServer implements AdbResponder {
|
||||
}
|
||||
}
|
||||
|
||||
private List<RemoteFileExpectation> _remoteFileExpectations = new ArrayList<RemoteFileExpectation>();
|
||||
private List<RemoteFileExpectation> remoteFileExpectations = new ArrayList<RemoteFileExpectation>();
|
||||
|
||||
public void expectPush(String serial, RemoteFile path, String contents){
|
||||
expectPush(serial, path, contents.getBytes(Charset.forName("UTF-8")));
|
||||
@ -91,11 +95,11 @@ public class FakeAdbServer implements AdbResponder {
|
||||
|
||||
public void expectPush(String serial, RemoteFile path, byte[] contents)
|
||||
{
|
||||
_remoteFileExpectations.add(new RemoteFileExpectation(serial, path, contents));
|
||||
remoteFileExpectations.add(new RemoteFileExpectation(serial, path, contents));
|
||||
}
|
||||
|
||||
private void filePushed(String serial, RemoteFile path, byte[] contents) {
|
||||
boolean removed = _remoteFileExpectations.remove(new RemoteFileExpectation(serial, path, contents));
|
||||
boolean removed = remoteFileExpectations.remove(new RemoteFileExpectation(serial, path, contents));
|
||||
if (!removed) throw new RuntimeException("Unexpected push to device " + serial + " at " + path.getPath());
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user