Skip to content

Commit 2acaf0f

Browse files
committed
initial import
1 parent ebfda50 commit 2acaf0f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+5311
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.gradle
2+
.idea
3+
*.iml
4+
/local.properties
5+
/build
6+
/app/build

app/build.gradle

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 21
5+
buildToolsVersion "21.1.2"
6+
7+
defaultConfig {
8+
applicationId "org.appspot.apprtc"
9+
minSdkVersion 13
10+
targetSdkVersion 21
11+
12+
testApplicationId "org.appspot.apprtc.test"
13+
testInstrumentationRunner "android.test.InstrumentationTestRunner"
14+
}
15+
16+
buildTypes {
17+
release {
18+
minifyEnabled false
19+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
20+
}
21+
}
22+
23+
lintOptions {
24+
abortOnError false
25+
}
26+
}
27+
28+
dependencies {
29+
compile files('libs/autobanh.jar')
30+
compile files('libs/libjingle_peerconnection.jar')
31+
}

app/libs/autobanh.jar

44.4 KB
Binary file not shown.

app/libs/libjingle_peerconnection.jar

79.4 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* libjingle
3+
* Copyright 2015, Google Inc.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice,
9+
* this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation
12+
* and/or other materials provided with the distribution.
13+
* 3. The name of the author may not be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19+
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24+
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
package org.appspot.apprtc.test;
29+
30+
import java.util.concurrent.CountDownLatch;
31+
import java.util.concurrent.TimeUnit;
32+
33+
import org.appspot.apprtc.util.LooperExecutor;
34+
35+
import android.test.InstrumentationTestCase;
36+
import android.util.Log;
37+
38+
public class LooperExecutorTest extends InstrumentationTestCase {
39+
private static final String TAG = "LooperTest";
40+
private static final int WAIT_TIMEOUT = 5000;
41+
42+
public void testLooperExecutor() throws InterruptedException {
43+
Log.d(TAG, "testLooperExecutor");
44+
final int counter[] = new int[1];
45+
final int expectedCounter = 10;
46+
final CountDownLatch looperDone = new CountDownLatch(1);
47+
48+
Runnable counterIncRunnable = new Runnable() {
49+
@Override
50+
public void run() {
51+
counter[0]++;
52+
Log.d(TAG, "Run " + counter[0]);
53+
}
54+
};
55+
LooperExecutor executor = new LooperExecutor();
56+
57+
// Try to execute a counter increment task before starting an executor.
58+
executor.execute(counterIncRunnable);
59+
60+
// Start the executor and run expected amount of counter increment task.
61+
executor.requestStart();
62+
for (int i = 0; i < expectedCounter; i++) {
63+
executor.execute(counterIncRunnable);
64+
}
65+
executor.execute(new Runnable() {
66+
@Override
67+
public void run() {
68+
looperDone.countDown();
69+
}
70+
});
71+
executor.requestStop();
72+
73+
// Try to execute a task after stopping the executor.
74+
executor.execute(counterIncRunnable);
75+
76+
// Wait for final looper task and make sure the counter increment task
77+
// is executed expected amount of times.
78+
looperDone.await(WAIT_TIMEOUT, TimeUnit.MILLISECONDS);
79+
assertTrue (looperDone.getCount() == 0);
80+
assertTrue (counter[0] == expectedCounter);
81+
82+
Log.d(TAG, "testLooperExecutor done");
83+
}
84+
}

0 commit comments

Comments
 (0)