• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2019 The WebRTC Project Authors. All rights reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 package org.webrtc;
12 
13 import static com.google.common.truth.Truth.assertThat;
14 
15 import androidx.test.runner.AndroidJUnit4;
16 import org.junit.Test;
17 import org.junit.runner.RunWith;
18 import org.robolectric.annotation.Config;
19 import org.webrtc.IceCandidate;
20 
21 @RunWith(AndroidJUnit4.class)
22 @Config(manifest = Config.NONE)
23 public class IceCandidateTest {
24   @Test
testIceCandidateEquals()25   public void testIceCandidateEquals() {
26     IceCandidate c1 = new IceCandidate(
27         "audio", 0, "candidate:1532086002 1 udp 2122194687 192.168.86.144 37138 typ host");
28     IceCandidate c2 = new IceCandidate(
29         "audio", 0, "candidate:1532086002 1 udp 2122194687 192.168.86.144 37138 typ host");
30 
31     // c3 differ by sdpMid
32     IceCandidate c3 = new IceCandidate(
33         "video", 0, "candidate:1532086002 1 udp 2122194687 192.168.86.144 37138 typ host");
34     // c4 differ by sdpMLineIndex
35     IceCandidate c4 = new IceCandidate(
36         "audio", 1, "candidate:1532086002 1 udp 2122194687 192.168.86.144 37138 typ host");
37     // c5 differ by sdp.
38     IceCandidate c5 = new IceCandidate(
39         "audio", 0, "candidate:1532086002 1 udp 2122194687 192.168.86.144 37139 typ host");
40 
41     assertThat(c1.equals(c2)).isTrue();
42     assertThat(c2.equals(c1)).isTrue();
43     assertThat(c1.equals(null)).isFalse();
44     assertThat(c1.equals(c3)).isFalse();
45     assertThat(c1.equals(c4)).isFalse();
46     assertThat(c5.equals(c1)).isFalse();
47 
48     Object o2 = c2;
49     assertThat(c1.equals(o2)).isTrue();
50     assertThat(o2.equals(c1)).isTrue();
51   }
52 }