diff options
| author | Lena <lena@omega> | 2026-01-01 00:00:00 +0000 |
|---|---|---|
| committer | Lena <lena@omega> | 2026-06-24 22:14:50 +0300 |
| commit | eb0c8951196c637e44daf3c0617b131b997d5d2c (patch) | |
| tree | 2f83b6a41cee745467e53fc401942b82cea286ea /app/src/test/java/invalid/lena/scrcpy/DevicesTest.java | |
| download | scrcpy-android-eb0c8951196c637e44daf3c0617b131b997d5d2c.tar.gz | |
scrcpy-android: mirror an Android device over wireless ADB0.1
Native Java app for Android 12+ that mirrors another Android
device over wireless ADB, forwarding video, audio, touch input,
and clipboard. Bundles a pinned scrcpy-server.jar and the
vendored libadb-android stack. Supports h264/h265/av1 video and
raw/opus audio with in-app codec selection. No NDK, no Kotlin.
Includes JVM unit tests and a Docker-based emulator e2e rig.
Diffstat (limited to 'app/src/test/java/invalid/lena/scrcpy/DevicesTest.java')
| -rw-r--r-- | app/src/test/java/invalid/lena/scrcpy/DevicesTest.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/app/src/test/java/invalid/lena/scrcpy/DevicesTest.java b/app/src/test/java/invalid/lena/scrcpy/DevicesTest.java new file mode 100644 index 0000000..d1e4f02 --- /dev/null +++ b/app/src/test/java/invalid/lena/scrcpy/DevicesTest.java @@ -0,0 +1,64 @@ +package invalid.lena.scrcpy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class DevicesTest { + + @Test + public void parseEmptyOrNull() { + assertTrue(Devices.parse(null).isEmpty()); + assertTrue(Devices.parse("").isEmpty()); + assertTrue(Devices.parse(" ").isEmpty()); + } + + @Test + public void parseNonArrayReturnsEmpty() { + assertTrue(Devices.parse("{not json").isEmpty()); + assertTrue(Devices.parse("{\"host\":\"x\"}").isEmpty()); + } + + @Test + public void parseSkipsMalformedRowsKeepsValid() { + // Middle row missing 'port' - must NOT nuke the other two. + String json = "[" + + "{\"host\":\"a\",\"port\":1}," + + "{\"host\":\"bad\"}," + + "{\"host\":\"c\",\"port\":3}" + + "]"; + List<Devices.Device> got = Devices.parse(json); + assertEquals(2, got.size()); + assertEquals("a", got.get(0).host); + assertEquals("c", got.get(1).host); + } + + @Test + public void roundTrip() { + List<Devices.Device> in = new ArrayList<>(Arrays.asList( + new Devices.Device("192.168.1.10", 5555), + new Devices.Device("10.0.0.2", 43210))); + String json = Devices.serialize(in); + List<Devices.Device> out = Devices.parse(json); + assertEquals(2, out.size()); + assertEquals("192.168.1.10", out.get(0).host); + assertEquals(5555, out.get(0).port); + assertEquals("10.0.0.2", out.get(1).host); + assertEquals(43210, out.get(1).port); + } + + @Test + public void deviceEqualsByHostAndPort() { + Devices.Device a = new Devices.Device("1.1.1.1", 5555); + Devices.Device b = new Devices.Device("1.1.1.1", 5555); + Devices.Device c = new Devices.Device("1.1.1.1", 5556); + assertEquals(a, b); + assertEquals(a.hashCode(), b.hashCode()); + assertEquals(false, a.equals(c)); + } +} |