Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1694)

Unified Diff: webrtc/examples/androidjunit/src/org/appspot/apprtc/DirectRTCClientTest.java

Issue 2009493002: Improve IP_PATTERN in DirectRTCClient in Android AppRTC Demo (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/examples/androidapp/src/org/appspot/apprtc/DirectRTCClient.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/examples/androidjunit/src/org/appspot/apprtc/DirectRTCClientTest.java
diff --git a/webrtc/examples/androidjunit/src/org/appspot/apprtc/DirectRTCClientTest.java b/webrtc/examples/androidjunit/src/org/appspot/apprtc/DirectRTCClientTest.java
index 26ad536adf51b4f5edad8e80ba66b09a1b925f47..f1073ae4b92e4b7e792ad08402972a88786771ed 100644
--- a/webrtc/examples/androidjunit/src/org/appspot/apprtc/DirectRTCClientTest.java
+++ b/webrtc/examples/androidjunit/src/org/appspot/apprtc/DirectRTCClientTest.java
@@ -18,6 +18,8 @@ import org.robolectric.annotation.Config;
import org.webrtc.IceCandidate;
import org.webrtc.SessionDescription;
+import java.util.regex.Matcher;
+
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.isNotNull;
@@ -58,6 +60,48 @@ public class DirectRTCClientTest {
}
@Test
+ public void testIpPattern() {
magjed_webrtc 2016/05/24 14:08:23 Split up in two tests testValidIpPattern()/testInv
sakal 2016/05/24 14:17:48 Done.
+ // Strings that should match the pattern.
+ final String[] ipAddresses = new String[] {
+ "0.0.0.0",
+ "127.0.0.1",
+ "192.168.0.1",
+ "0.0.0.0:8888",
+ "127.0.0.1:8888",
+ "192.168.0.1:8888",
+ "::",
+ "::1",
+ "2001:0db8:85a3:0000:0000:8a2e:0370:7946",
+ "[::]",
+ "[::1]",
+ "[2001:0db8:85a3:0000:0000:8a2e:0370:7946]",
+ "[::]:8888",
+ "[::1]:8888",
+ "[2001:0db8:85a3:0000:0000:8a2e:0370:7946]:8888"
+ };
+ // Strings that shouldn't match the pattern.
+ final String[] fakeIpAddresses = new String[] {
+ "Hello, World!",
+ "aaaa",
+ "1111",
+ "[hello world]",
+ "hello:world"
+ };
+
+ for (String ip : ipAddresses) {
+ if (!DirectRTCClient.IP_PATTERN.matcher(ip).matches()) {
+ fail(ip + " didn't match IP_PATTERN even though it should.");
+ }
+ }
+
+ for (String fakeIp : fakeIpAddresses) {
+ if (DirectRTCClient.IP_PATTERN.matcher(fakeIp).matches()) {
+ fail(fakeIp + " matched IP_PATTERN even though it shouldn't.");
+ }
+ }
+ }
+
+ @Test
public void testDirectRTCClient() {
server.connectToRoom(new AppRTCClient.RoomConnectionParameters(ROOM_URL, "0.0.0.0", LOOPBACK));
try {
« no previous file with comments | « webrtc/examples/androidapp/src/org/appspot/apprtc/DirectRTCClient.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698