diff --git a/core/src/androidTest/java/com/github/shadowsocks/ExampleInstrumentedTest.java b/core/src/androidTest/java/com/github/shadowsocks/ExampleInstrumentedTest.java index defcdd50..de7a5f96 100644 --- a/core/src/androidTest/java/com/github/shadowsocks/ExampleInstrumentedTest.java +++ b/core/src/androidTest/java/com/github/shadowsocks/ExampleInstrumentedTest.java @@ -21,6 +21,6 @@ public class ExampleInstrumentedTest { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); - assertEquals("com.github.shadowsockscorelibraries.test", appContext.getPackageName()); + assertEquals("com.github.shadowsocks.core.test", appContext.getPackageName()); } } diff --git a/mobile/build.gradle b/mobile/build.gradle index 6b7d22bb..5f922166 100644 --- a/mobile/build.gradle +++ b/mobile/build.gradle @@ -22,6 +22,7 @@ android { targetSdkVersion rootProject.sdkVersion versionCode 201 versionName "4.4.1" + testApplicationId "com.github.shadowsocks.test" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary true resConfigs "fa", "ja", "ko", "ru", "zh-rCN", "zh-rTW" diff --git a/mobile/src/androidTest/java/com/github/shadowsocks/ExampleInstrumentedTest.java b/mobile/src/androidTest/java/com/github/shadowsocks/ExampleInstrumentedTest.java deleted file mode 100644 index 191c2e05..00000000 --- a/mobile/src/androidTest/java/com/github/shadowsocks/ExampleInstrumentedTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.github.shadowsocks; - -import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumented test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() throws Exception { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); - - assertEquals("com.github.shadowsocks", appContext.getPackageName()); - } -} diff --git a/mobile/src/androidTest/java/com/github/shadowsocks/acl/AclTest.kt b/mobile/src/androidTest/java/com/github/shadowsocks/acl/AclTest.kt index 7620ee36..e8b79885 100644 --- a/mobile/src/androidTest/java/com/github/shadowsocks/acl/AclTest.kt +++ b/mobile/src/androidTest/java/com/github/shadowsocks/acl/AclTest.kt @@ -28,7 +28,6 @@ class AclTest { private const val INPUT1 = """[proxy_all] [bypass_list] 1.0.1.0/24 -[proxy_list] (^|\.)4tern\.com${'$'} """ } diff --git a/mobile/src/test/java/com/github/shadowsocks/utils/SubnetTest.kt b/mobile/src/androidTest/java/com/github/shadowsocks/utils/SubnetTest.kt similarity index 100% rename from mobile/src/test/java/com/github/shadowsocks/utils/SubnetTest.kt rename to mobile/src/androidTest/java/com/github/shadowsocks/utils/SubnetTest.kt diff --git a/mobile/src/main/java/com/github/shadowsocks/utils/Subnet.kt b/mobile/src/main/java/com/github/shadowsocks/utils/Subnet.kt index 56468075..f6cfb6e8 100644 --- a/mobile/src/main/java/com/github/shadowsocks/utils/Subnet.kt +++ b/mobile/src/main/java/com/github/shadowsocks/utils/Subnet.kt @@ -30,7 +30,8 @@ class Subnet(val address: InetAddress, val prefixSize: Int) : Comparable val parts = (value as java.lang.String).split("/", 2) val addr = parts[0].parseNumericAddress() ?: return null return if (parts.size == 2) try { - Subnet(addr, parts[1].toInt()) + val prefixSize = parts[1].toInt() + if (prefixSize < 0 || prefixSize > addr.address.size shl 3) null else Subnet(addr, prefixSize) } catch (_: NumberFormatException) { null } else Subnet(addr, addr.address.size shl 3)