Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 clientEvents = mock(AppRTCClient.SignalingEvents.class); | 55 clientEvents = mock(AppRTCClient.SignalingEvents.class); |
| 56 serverEvents = mock(AppRTCClient.SignalingEvents.class); | 56 serverEvents = mock(AppRTCClient.SignalingEvents.class); |
| 57 | 57 |
| 58 client = new DirectRTCClient(clientEvents); | 58 client = new DirectRTCClient(clientEvents); |
| 59 server = new DirectRTCClient(serverEvents); | 59 server = new DirectRTCClient(serverEvents); |
| 60 } | 60 } |
| 61 | 61 |
| 62 @Test | 62 @Test |
| 63 public void testValidIpPattern() { | 63 public void testValidIpPattern() { |
| 64 // Strings that should match the pattern. | 64 // Strings that should match the pattern. |
| 65 final String[] ipAddresses = new String[] { | 65 final String[] ipAddresses = |
|
magjed_webrtc
2016/09/28 13:45:05
revert.
| |
| 66 "0.0.0.0", | 66 new String[] {"0.0.0.0", "127.0.0.1", "192.168.0.1", "0.0.0.0:8888", "12 7.0.0.1:8888", |
| 67 "127.0.0.1", | 67 "192.168.0.1:8888", "::", "::1", "2001:0db8:85a3:0000:0000:8a2e:0370 :7946", "[::]", |
| 68 "192.168.0.1", | 68 "[::1]", "[2001:0db8:85a3:0000:0000:8a2e:0370:7946]", "[::]:8888", " [::1]:8888", |
| 69 "0.0.0.0:8888", | 69 "[2001:0db8:85a3:0000:0000:8a2e:0370:7946]:8888"}; |
| 70 "127.0.0.1:8888", | |
| 71 "192.168.0.1:8888", | |
| 72 "::", | |
| 73 "::1", | |
| 74 "2001:0db8:85a3:0000:0000:8a2e:0370:7946", | |
| 75 "[::]", | |
| 76 "[::1]", | |
| 77 "[2001:0db8:85a3:0000:0000:8a2e:0370:7946]", | |
| 78 "[::]:8888", | |
| 79 "[::1]:8888", | |
| 80 "[2001:0db8:85a3:0000:0000:8a2e:0370:7946]:8888" | |
| 81 }; | |
| 82 | 70 |
| 83 for (String ip : ipAddresses) { | 71 for (String ip : ipAddresses) { |
| 84 assertTrue(ip + " didn't match IP_PATTERN even though it should.", | 72 assertTrue(ip + " didn't match IP_PATTERN even though it should.", |
| 85 DirectRTCClient.IP_PATTERN.matcher(ip).matches()); | 73 DirectRTCClient.IP_PATTERN.matcher(ip).matches()); |
| 86 } | 74 } |
| 87 } | 75 } |
| 88 | 76 |
| 89 @Test | 77 @Test |
| 90 public void testInvalidIpPattern() { | 78 public void testInvalidIpPattern() { |
| 91 // Strings that shouldn't match the pattern. | 79 // Strings that shouldn't match the pattern. |
| 92 final String[] invalidIpAddresses = new String[] { | 80 final String[] invalidIpAddresses = |
| 93 "Hello, World!", | 81 new String[] {"Hello, World!", "aaaa", "1111", "[hello world]", "hello:w orld"}; |
| 94 "aaaa", | |
| 95 "1111", | |
| 96 "[hello world]", | |
| 97 "hello:world" | |
| 98 }; | |
| 99 | 82 |
| 100 for (String invalidIp : invalidIpAddresses) { | 83 for (String invalidIp : invalidIpAddresses) { |
| 101 assertFalse(invalidIp + " matched IP_PATTERN even though it shouldn't.", | 84 assertFalse(invalidIp + " matched IP_PATTERN even though it shouldn't.", |
| 102 DirectRTCClient.IP_PATTERN.matcher(invalidIp).matches()); | 85 DirectRTCClient.IP_PATTERN.matcher(invalidIp).matches()); |
| 103 } | 86 } |
| 104 } | 87 } |
| 105 | 88 |
| 106 @Test | 89 @Test |
| 107 public void testDirectRTCClient() { | 90 public void testDirectRTCClient() { |
| 108 server.connectToRoom(new AppRTCClient.RoomConnectionParameters(ROOM_URL, "0. 0.0.0", LOOPBACK)); | 91 server.connectToRoom(new AppRTCClient.RoomConnectionParameters(ROOM_URL, "0. 0.0.0", LOOPBACK)); |
| 109 try { | 92 try { |
| 110 Thread.sleep(SERVER_WAIT); | 93 Thread.sleep(SERVER_WAIT); |
| 111 } catch (InterruptedException e) { | 94 } catch (InterruptedException e) { |
| 112 fail(e.getMessage()); | 95 fail(e.getMessage()); |
| 113 } | 96 } |
| 114 client.connectToRoom( | 97 client.connectToRoom( |
| 115 new AppRTCClient.RoomConnectionParameters(ROOM_URL, "127.0.0.1", LOOPBAC K)); | 98 new AppRTCClient.RoomConnectionParameters(ROOM_URL, "127.0.0.1", LOOPBAC K)); |
| 116 verify(serverEvents, timeout(NETWORK_TIMEOUT)) | 99 verify(serverEvents, timeout(NETWORK_TIMEOUT)) |
| 117 .onConnectedToRoom(any(AppRTCClient.SignalingParameters.class)); | 100 .onConnectedToRoom(any(AppRTCClient.SignalingParameters.class)); |
| 118 | 101 |
| 119 SessionDescription offerSdp = new SessionDescription(SessionDescription.Type .OFFER, DUMMY_SDP); | 102 SessionDescription offerSdp = new SessionDescription(SessionDescription.Type .OFFER, DUMMY_SDP); |
| 120 server.sendOfferSdp(offerSdp); | 103 server.sendOfferSdp(offerSdp); |
| 121 verify(clientEvents, timeout(NETWORK_TIMEOUT)) | 104 verify(clientEvents, timeout(NETWORK_TIMEOUT)) |
| 122 .onConnectedToRoom(any(AppRTCClient.SignalingParameters.class)); | 105 .onConnectedToRoom(any(AppRTCClient.SignalingParameters.class)); |
| 123 | 106 |
| 124 SessionDescription answerSdp | 107 SessionDescription answerSdp = |
| 125 = new SessionDescription(SessionDescription.Type.ANSWER, DUMMY_SDP); | 108 new SessionDescription(SessionDescription.Type.ANSWER, DUMMY_SDP); |
| 126 client.sendAnswerSdp(answerSdp); | 109 client.sendAnswerSdp(answerSdp); |
| 127 verify(serverEvents, timeout(NETWORK_TIMEOUT)) | 110 verify(serverEvents, timeout(NETWORK_TIMEOUT)) |
| 128 .onRemoteDescription(isNotNull(SessionDescription.class)); | 111 .onRemoteDescription(isNotNull(SessionDescription.class)); |
| 129 | 112 |
| 130 IceCandidate candidate = new IceCandidate(DUMMY_SDP_MID, 0, DUMMY_SDP); | 113 IceCandidate candidate = new IceCandidate(DUMMY_SDP_MID, 0, DUMMY_SDP); |
| 131 server.sendLocalIceCandidate(candidate); | 114 server.sendLocalIceCandidate(candidate); |
| 132 verify(clientEvents, timeout(NETWORK_TIMEOUT)) | 115 verify(clientEvents, timeout(NETWORK_TIMEOUT)) |
| 133 .onRemoteIceCandidate(isNotNull(IceCandidate.class)); | 116 .onRemoteIceCandidate(isNotNull(IceCandidate.class)); |
| 134 | 117 |
| 135 client.sendLocalIceCandidate(candidate); | 118 client.sendLocalIceCandidate(candidate); |
| 136 verify(serverEvents, timeout(NETWORK_TIMEOUT)) | 119 verify(serverEvents, timeout(NETWORK_TIMEOUT)) |
| 137 .onRemoteIceCandidate(isNotNull(IceCandidate.class)); | 120 .onRemoteIceCandidate(isNotNull(IceCandidate.class)); |
| 138 | 121 |
| 139 client.disconnectFromRoom(); | 122 client.disconnectFromRoom(); |
| 140 verify(clientEvents, timeout(NETWORK_TIMEOUT)).onChannelClose(); | 123 verify(clientEvents, timeout(NETWORK_TIMEOUT)).onChannelClose(); |
| 141 verify(serverEvents, timeout(NETWORK_TIMEOUT)).onChannelClose(); | 124 verify(serverEvents, timeout(NETWORK_TIMEOUT)).onChannelClose(); |
| 142 | 125 |
| 143 verifyNoMoreInteractions(clientEvents); | 126 verifyNoMoreInteractions(clientEvents); |
| 144 verifyNoMoreInteractions(serverEvents); | 127 verifyNoMoreInteractions(serverEvents); |
| 145 } | 128 } |
| 146 } | 129 } |
| OLD | NEW |