mirror of
git://f0xx.org/ac/ac-mobile-android
synced 2026-07-29 04:18:25 +03:00
mobile: IodineVpnServiceTest lifecycle coverage + ndkVersion 29
- IodineVpnServiceTest: action constants, extras, IodineTunnelBridge state, config sanitize, RemoteAccessMode iodine round-trips - app/build.gradle: ndkVersion 29.0.14206865 (27 had corrupt empty dir) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -56,6 +56,7 @@ try {
|
||||
android {
|
||||
namespace 'com.foxx.androidcast'
|
||||
compileSdk 34
|
||||
ndkVersion '29.0.14206865'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.foxx.androidcast"
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.foxx.androidcast.remoteaccess;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/** Unit tests for IodineVpnService lifecycle helpers (no Android runtime required). */
|
||||
public class IodineVpnServiceTest {
|
||||
|
||||
@Test
|
||||
public void actionConstants_areNonNull() {
|
||||
assertNotNull(IodineVpnService.ACTION_UP);
|
||||
assertNotNull(IodineVpnService.ACTION_DOWN);
|
||||
assertTrue(IodineVpnService.ACTION_UP.contains("iodine"));
|
||||
assertTrue(IodineVpnService.ACTION_DOWN.contains("iodine"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extraConstants_areNonNull() {
|
||||
assertNotNull(IodineVpnService.EXTRA_HOST);
|
||||
assertNotNull(IodineVpnService.EXTRA_PORT);
|
||||
assertNotNull(IodineVpnService.EXTRA_TUNNEL);
|
||||
assertNotNull(IodineVpnService.EXTRA_PASSWORD);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void actionUp_notEqualsDown() {
|
||||
assertFalse(IodineVpnService.ACTION_UP.equals(IodineVpnService.ACTION_DOWN));
|
||||
}
|
||||
|
||||
// IodineTunnelBridge state — no Android context needed
|
||||
|
||||
@Test
|
||||
public void tunnelBridge_initiallyNotConnected() {
|
||||
assertFalse(IodineTunnelBridge.isConnected());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tunnelBridge_lastDetailInitiallyEmpty() {
|
||||
String detail = IodineTunnelBridge.getLastDetail();
|
||||
assertNotNull(detail);
|
||||
}
|
||||
|
||||
// IodineConfig integration
|
||||
|
||||
@Test
|
||||
public void defaultUdpPort_matchesExpected() {
|
||||
assertEquals(5350, IodineConfig.DEFAULT_UDP_PORT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultPassword_isLabValue() {
|
||||
assertEquals("zxc123", IodineConfig.DEFAULT_PASSWORD);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sanitize_roundTrip() {
|
||||
assertEquals("fe.example.org", IodineConfig.sanitizeHost(" fe.example.org "));
|
||||
assertEquals(IodineConfig.DEFAULT_SERVER_HOST, IodineConfig.sanitizeHost(null));
|
||||
assertEquals(IodineConfig.DEFAULT_SERVER_HOST, IodineConfig.sanitizeHost(""));
|
||||
assertEquals(IodineConfig.DEFAULT_TUNNEL_DOMAIN, IodineConfig.sanitizeTunnelDomain(null));
|
||||
assertEquals(5350, IodineConfig.sanitizePort(-1));
|
||||
assertEquals(5350, IodineConfig.sanitizePort(99999));
|
||||
assertEquals(443, IodineConfig.sanitizePort(443));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sanitizePassword_nullFallsBackToDefault() {
|
||||
assertEquals(IodineConfig.DEFAULT_PASSWORD, IodineConfig.sanitizePassword(null));
|
||||
assertEquals("custom", IodineConfig.sanitizePassword("custom"));
|
||||
}
|
||||
|
||||
// RemoteAccessMode iodine integration
|
||||
|
||||
@Test
|
||||
public void remoteAccessMode_iodineApiValue() {
|
||||
assertEquals("iodine", RemoteAccessMode.IODINE.toApiValue());
|
||||
assertTrue(RemoteAccessMode.IODINE.isActive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void remoteAccessMode_fromStored_iodine() {
|
||||
assertEquals(RemoteAccessMode.IODINE, RemoteAccessMode.fromStored("iodine"));
|
||||
assertEquals(RemoteAccessMode.IODINE, RemoteAccessMode.fromStored("IODINE"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user