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

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

Issue 1989013003: Add test for DirectRTCClient in AppRTC Demo for Android (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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 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.appspot.apprtc;
12
13 import android.util.Log;
14
15 import org.appspot.apprtc.util.RobolectricLooperExecutor;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.junit.runner.RunWith;
19 import org.robolectric.RobolectricTestRunner;
20 import org.robolectric.annotation.Config;
21 import org.webrtc.IceCandidate;
22 import org.webrtc.SessionDescription;
23
24 import static org.junit.Assert.fail;
25 import static org.mockito.Matchers.any;
26 import static org.mockito.Matchers.isNotNull;
27 import static org.mockito.Mockito.mock;
28 import static org.mockito.Mockito.timeout;
29 import static org.mockito.Mockito.verify;
30 import static org.mockito.Mockito.verifyNoMoreInteractions;
31
32 /**
33 * Test for DirectRTCClient. Test is very simple and only tests the overall sani ty of the class
34 * behaviour.
35 */
36 @RunWith(RobolectricTestRunner.class)
37 @Config(manifest = Config.NONE)
38 public class DirectRTCClientTest {
39 private static final String ROOM_URL = "";
40 private static final boolean LOOPBACK = false;
41
42 private static final String DUMMY_SDP_MID = "sdpMid";
43 private static final String DUMMY_SDP = "sdp";
44
45 public static final int SERVER_WAIT = 10;
46 public static final int NETWORK_TIMEOUT = 100;
47
48 private DirectRTCClient client;
49 private DirectRTCClient server;
50
51 AppRTCClient.SignalingEvents clientEvents;
52 AppRTCClient.SignalingEvents serverEvents;
53
54 @Before
55 public void setUp() {
56 clientEvents = mock(AppRTCClient.SignalingEvents.class);
57 serverEvents = mock(AppRTCClient.SignalingEvents.class);
58
59 client = new DirectRTCClient(clientEvents, new RobolectricLooperExecutor());
60 server = new DirectRTCClient(serverEvents, new RobolectricLooperExecutor());
61 }
62
63 @Test
64 public void testDirectRTCClient() {
65 server.connectToRoom(new AppRTCClient.RoomConnectionParameters(ROOM_URL, "0. 0.0.0", LOOPBACK));
66 try {
67 Thread.sleep(SERVER_WAIT);
68 } catch (InterruptedException e) {
69 fail(e.getMessage());
70 }
71 client.connectToRoom(
72 new AppRTCClient.RoomConnectionParameters(ROOM_URL, "127.0.0.1", LOOPBAC K));
73 verify(serverEvents, timeout(NETWORK_TIMEOUT))
74 .onConnectedToRoom(any(AppRTCClient.SignalingParameters.class));
75
76 SessionDescription offerSdp = new SessionDescription(SessionDescription.Type .OFFER, DUMMY_SDP);
77 server.sendOfferSdp(offerSdp);
78 verify(clientEvents, timeout(NETWORK_TIMEOUT))
79 .onConnectedToRoom(any(AppRTCClient.SignalingParameters.class));
80
81 SessionDescription answerSdp
82 = new SessionDescription(SessionDescription.Type.ANSWER, DUMMY_SDP);
83 client.sendAnswerSdp(answerSdp);
84 verify(serverEvents, timeout(NETWORK_TIMEOUT))
85 .onRemoteDescription(isNotNull(SessionDescription.class));
86
87 IceCandidate candidate = new IceCandidate(DUMMY_SDP_MID, 0, DUMMY_SDP);
88 server.sendLocalIceCandidate(candidate);
89 verify(clientEvents, timeout(NETWORK_TIMEOUT))
90 .onRemoteIceCandidate(isNotNull(IceCandidate.class));
91
92 client.sendLocalIceCandidate(candidate);
93 verify(serverEvents, timeout(NETWORK_TIMEOUT))
94 .onRemoteIceCandidate(isNotNull(IceCandidate.class));
95
96 client.disconnectFromRoom();
97 verify(clientEvents, timeout(NETWORK_TIMEOUT)).onChannelClose();
98 verify(serverEvents, timeout(NETWORK_TIMEOUT)).onChannelClose();
99
100 verifyNoMoreInteractions(clientEvents);
101 verifyNoMoreInteractions(serverEvents);
102 }
103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698