Skip to content

Commit

Permalink
part implement of PeerConnection_jni.cpp && apply google-java-format …
Browse files Browse the repository at this point in the history
…(with plugin)
  • Loading branch information
haiyangwu committed Oct 9, 2019
1 parent d8a6460 commit cdf10d8
Show file tree
Hide file tree
Showing 24 changed files with 715 additions and 314 deletions.
3 changes: 0 additions & 3 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/google-java-format.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
@@ -0,0 +1,17 @@
package org.mediasoup.droid;

import android.content.Context;
import android.support.test.InstrumentationRegistry;

import org.junit.Before;

public abstract class BaseTest {

@Before
public void setUp() {
Context context = InstrumentationRegistry.getContext();
Logger.setLogLevel(Logger.LogLevel.LOG_DEBUG);
Logger.setDefaultHandler();
MediasoupClient.initialize(context.getApplicationContext());
}
}
@@ -1,7 +1,5 @@
package org.mediasoup.droid;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.text.TextUtils;

Expand All @@ -17,74 +15,68 @@
import static org.junit.Assert.assertTrue;

@RunWith(AndroidJUnit4.class)
public class DeviceTest {

private Device mDevice;

@Rule
public ExpectedException thrown = ExpectedException.none();

@Before
public void setUp() {
Context context = InstrumentationRegistry.getTargetContext();

Logger.setLogLevel(Logger.LogLevel.LOG_DEBUG);
Logger.setDefaultHandler();

MediasoupClient.initialize(context.getApplicationContext());
mDevice = new Device();
}

@After
public void tearDown() {
mDevice.dispose();
}

@Test(expected = RuntimeException.class)
public void testWithoutLoad() {
// 'device->IsLoaded()' is false if not loaded.
assertFalse(mDevice.isLoaded());

// 'device->GetRtpCapabilities()' throws if not loaded.
mDevice.GetRtpCapabilities();
thrown.expect(RuntimeException.class);
thrown.expectMessage("Not loaded");

// 'device->CanProduce()' with audio/video throws if not loaded/
mDevice.canProduce("video");
thrown.expect(RuntimeException.class);
thrown.expectMessage("Not loaded");
mDevice.canProduce("audio");
thrown.expect(RuntimeException.class);
thrown.expectMessage("Not loaded");

// 'device->CreateSendTransport()' fails if not loaded"
// TODO:

// 'device->CreateRecvTransport()' fails if not loaded
// TODO:
}

@Test(expected = RuntimeException.class)
public void testLoad() {
String routerRtpCapabilities = Parameters.generateRouterRtpCapabilities();
assertFalse(TextUtils.isEmpty(routerRtpCapabilities));

// 'device->Load()' succeeds
mDevice.load(routerRtpCapabilities);
assertTrue(mDevice.isLoaded());
assertFalse(TextUtils.isEmpty(mDevice.GetRtpCapabilities()));
assertTrue(mDevice.canProduce("audio"));
assertTrue(mDevice.canProduce("video"));

// device->CanProduce() with invalid kind throws exception
assertTrue(mDevice.canProduce("chicken"));
thrown.expect(RuntimeException.class);

// 'device->CreateSendTransport()' succeeds
// TODO;

// 'device->CreateRecvTransport()' succeeds
// TODO:
}
public class DeviceTest extends BaseTest {

private Device mDevice;

@Rule public ExpectedException thrown = ExpectedException.none();

@Before
public void setUp() {
super.setUp();
mDevice = new Device();
}

@After
public void tearDown() {
mDevice.dispose();
}

@Test(expected = RuntimeException.class)
public void testWithoutLoad() {
// 'device->IsLoaded()' is false if not loaded.
assertFalse(mDevice.isLoaded());

// 'device->GetRtpCapabilities()' throws if not loaded.
mDevice.GetRtpCapabilities();
thrown.expect(RuntimeException.class);
thrown.expectMessage("Not loaded");

// 'device->CanProduce()' with audio/video throws if not loaded.
mDevice.canProduce("video");
thrown.expect(RuntimeException.class);
thrown.expectMessage("Not loaded");
mDevice.canProduce("audio");
thrown.expect(RuntimeException.class);
thrown.expectMessage("Not loaded");

// 'device->CreateSendTransport()' fails if not loaded".
// TODO:

// 'device->CreateRecvTransport()' fails if not loaded.
// TODO:
}

@Test(expected = RuntimeException.class)
public void testLoad() {
String routerRtpCapabilities = Parameters.generateRouterRtpCapabilities();
assertFalse(TextUtils.isEmpty(routerRtpCapabilities));

// 'device->Load()' succeeds.
mDevice.load(routerRtpCapabilities);
assertTrue(mDevice.isLoaded());
assertFalse(TextUtils.isEmpty(mDevice.GetRtpCapabilities()));
assertTrue(mDevice.canProduce("audio"));
assertTrue(mDevice.canProduce("video"));

// device->CanProduce() with invalid kind throws exception.
assertTrue(mDevice.canProduce("chicken"));
thrown.expect(RuntimeException.class);

// 'device->CreateSendTransport()' succeeds.
// TODO;

// 'device->CreateRecvTransport()' succeeds.
// TODO:
}
}

This file was deleted.

Expand Up @@ -8,20 +8,20 @@
@RunWith(AndroidJUnit4.class)
public class LoggerTest {

private static final String TAG = "LoggerTest";
private static final String TAG = "LoggerTest";

@Test
public void setDefaultHandler() {
Logger.setDefaultHandler();
}
@Test
public void setDefaultHandler() {
Logger.setDefaultHandler();
}

@Test
public void log() {
Logger.setLogLevel(Logger.LogLevel.LOG_TRACE);
@Test
public void log() {
Logger.setLogLevel(Logger.LogLevel.LOG_TRACE);

Logger.v(TAG, "test log");
Logger.d(TAG, "test log");
Logger.w(TAG, "test log");
Logger.e(TAG, "test log");
}
Logger.v(TAG, "test log");
Logger.d(TAG, "test log");
Logger.w(TAG, "test log");
Logger.e(TAG, "test log");
}
}
Expand Up @@ -10,8 +10,8 @@
@RunWith(AndroidJUnit4.class)
public class MediasoupClientTest {

@Test
public void version() {
assertEquals(MediasoupClient.version(), BuildConfig.VERSION_NAME);
}
@Test
public void version() {
assertEquals(MediasoupClient.version(), BuildConfig.VERSION_NAME);
}
}
@@ -0,0 +1,61 @@
package org.mediasoup.droid;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;

@RunWith(AndroidJUnit4.class)
public class PeerConnectionTest {

private PeerConnection.PrivateListener mListener;
private PeerConnection.Options mPeerConnectionOptions;
private PeerConnection mPc;

@Before
public void setUp() {
Context context = InstrumentationRegistry.getTargetContext();
Logger.setLogLevel(Logger.LogLevel.LOG_DEBUG);
Logger.setDefaultHandler();
MediasoupClient.initialize(context.getApplicationContext());

mListener = new PeerConnection.PrivateListener();
mPeerConnectionOptions = new PeerConnection.Options();
mPc = new PeerConnection(mListener, mPeerConnectionOptions);
}

@After
public void tearDown() {
mPc.dispose();
}

@Test
public void getConfiguration() {
assertNotNull("'pc.GetConfiguration()' succeeds", mPc.getConfiguration());
}

@Test
public void setConfiguration() {
PeerConnection.PrivateListener listener = new PeerConnection.PrivateListener();

List<org.webrtc.PeerConnection.IceServer> iceServerUris = new ArrayList<>();
iceServerUris.add(new org.webrtc.PeerConnection.IceServer("Wrong URI"));
org.webrtc.PeerConnection.RTCConfiguration rtcConfiguration =
new org.webrtc.PeerConnection.RTCConfiguration(iceServerUris);

PeerConnection pc = new PeerConnection(listener, mPeerConnectionOptions);
assertFalse(
"'pc.SetConfiguration()' fails if wrong options are provided",
pc.setConfiguration(rtcConfiguration));
}
}
@@ -0,0 +1,3 @@
package org.mediasoup.droid;

public class PeerConnectionUtils {}
Expand Up @@ -2,15 +2,15 @@

public class Parameters {

public static native String generateRouterRtpCapabilities();
public static native String generateRouterRtpCapabilities();

public static native String generateRtpParametersByKind();
public static native String generateRtpParametersByKind();

public static native String generateLocalDtlsParameters();
public static native String generateLocalDtlsParameters();

public static native String generateTransportRemoteParameters();
public static native String generateTransportRemoteParameters();

public static native String generateProducerRemoteId();
public static native String generateProducerRemoteId();

public static native String generateConsumerRemoteParameters(String codecMimeType);
public static native String generateConsumerRemoteParameters(String codecMimeType);
}
@@ -1,6 +1,3 @@
package org.mediasoup.droid;

public class Consumer {


}
public class Consumer {}

0 comments on commit cdf10d8

Please sign in to comment.