Skip to content
This repository was archived by the owner on Sep 25, 2023. It is now read-only.

Add IATF test example. #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/p2p/iatfTest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
41 changes: 41 additions & 0 deletions test/p2p/iatfTest/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion 21

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}


compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}


repositories {
flatDir {
dirs '../../libs'
}
}

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
implementation project(':test:p2p:util')
}
21 changes: 21 additions & 0 deletions test/p2p/iatfTest/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package owt.test.p2p.apitest;

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

import org.json.JSONException;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

import owt.p2p.P2PClient;
import owt.test.util.LockServer;


@RunWith(AndroidJUnit4.class)
public class TestDevice1 {
private static LockServer mLockServer = new LockServer();
private static String taskId = null;
private int caseSequenceNumber = 0;

@Test
public void testConnect() {
mLockServer.notifyWorkflowLock("user1", "connect");
mLockServer.waitWorkflowLock("user2", "connect");
}

@BeforeClass
public static void beforeClass() {
taskId = InstrumentationRegistry.getArguments().getString("taskId");
mLockServer.connect(taskId,"role1");
mLockServer.waitControlLock("task-start");
}

@AfterClass
public static void afterClass() {
mLockServer.disconnect();
}

@After
public void tearDown() {
JSONObject lockData = new JSONObject();
try {
lockData.put("sequenceNumber", this.caseSequenceNumber);
} catch (JSONException e) {
e.printStackTrace();
}
mLockServer.notifyControlLock("case-end", lockData);
mLockServer.initStatus();
}

@Before
public void setUp() {
this.caseSequenceNumber++;
JSONObject lockData = new JSONObject();
try {
lockData.put("sequenceNumber", this.caseSequenceNumber);
} catch (JSONException e) {
e.printStackTrace();
}
mLockServer.notifyControlLock("case-ready", lockData);
mLockServer.waitControlLock("case-start");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package owt.test.p2p.apitest;

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

import org.json.JSONException;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

import owt.test.util.LockServer;

@RunWith(AndroidJUnit4.class)
public class TestDevice2 {
private static LockServer mLockServer = new LockServer();
private static String taskId = null;
private int caseSequenceNumber = 0;

@Test
public void testConnect() {
mLockServer.waitWorkflowLock("user1", "connect");
mLockServer.notifyWorkflowLock("user2", "connect");
}

@BeforeClass
public static void beforeClass() {
taskId = InstrumentationRegistry.getArguments().getString("taskId");
mLockServer.connect(taskId,"role2");
mLockServer.waitControlLock("task-start");
}

@AfterClass
public static void afterClass() {
mLockServer.disconnect();

}

@After
public void tearDown() {
JSONObject lockData = new JSONObject();
try {
lockData.put("sequenceNumber", this.caseSequenceNumber);
} catch (JSONException e) {
e.printStackTrace();
}
mLockServer.notifyControlLock("case-end", lockData);
mLockServer.initStatus();
}

@Before
public void setUp() {
this.caseSequenceNumber++;
JSONObject lockData = new JSONObject();
try {
lockData.put("sequenceNumber", caseSequenceNumber);
} catch (JSONException e) {
e.printStackTrace();
}
mLockServer.notifyControlLock("case-ready", lockData);
mLockServer.waitControlLock("case-start");
}

}
33 changes: 33 additions & 0 deletions test/p2p/iatfTest/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" package="owt.test.p2p.apitest">

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package owt.test.p2p.apitest;

import android.app.Activity;
import android.os.Bundle;


public class MainActivity extends Activity {
private final static String TAG = "owt_p2p_iatf_test";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
}

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions test/p2p/iatfTest/src/main/res/layout/activity_test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--suppress AndroidDomInspection -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context="${relativePackage}.${activityClass}" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:ignore="UselessParent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:id="@+id/testTitleTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textSize="20sp" />
</LinearLayout>

</LinearLayout>

</RelativeLayout>
5 changes: 5 additions & 0 deletions test/p2p/iatfTest/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">owt_p2p_iatf_test</string>
<string name="title_activity_test">owt_p2p_iatf_test</string>
</resources>
4 changes: 4 additions & 0 deletions test/util/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ repositories {
}
}
dependencies {
implementation('io.socket:socket.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
implementation 'org.dom4j:dom4j:2.0.2'
api project(':src:sdk:base')
api project(':src:sdk:conference')
Expand Down
12 changes: 12 additions & 0 deletions test/util/src/main/java/owt/test/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public class Config {

public static final String RAW_STREAM_FILE;

public static final String IATF_SERVER;

public static final String IATF_WAIT_TIME;

static {
InputStream config = Thread.currentThread().getContextClassLoader().getResourceAsStream(
"config.xml");
Expand Down Expand Up @@ -82,6 +86,14 @@ public class Config {

Element rawStreamFileElement = rootElement.element("rawStreamFile");
RAW_STREAM_FILE = rawStreamFileElement == null ? "" : rawStreamFileElement.getText();

Element iatfServerElement = rootElement.element("iatfServer");
IATF_SERVER = iatfServerElement == null ? "" : iatfServerElement.getText();


Element iatfWaitLockTimeElement = rootElement.element("iatfWaitLockTime");
IATF_WAIT_TIME = iatfWaitLockTimeElement == null ? "" : iatfWaitLockTimeElement.getText();

} catch (DocumentException e) {
throw new RuntimeException(e.getMessage());
}
Expand Down
Loading