refactor java code in autotest
Review URL: http://webrtc-codereview.appspot.com/22020 git-svn-id: http://webrtc.googlecode.com/svn/trunk@41 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -1,159 +1,162 @@
|
|||||||
package org.webrtc.vieautotest;
|
/*
|
||||||
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||||
import org.webrtc.vieautotest.R;
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
import android.app.Activity;
|
* that can be found in the LICENSE file in the root of the source
|
||||||
import android.os.Bundle;
|
* tree. An additional intellectual property rights grant can be found
|
||||||
import android.util.Log;
|
* in the file PATENTS. All contributing project authors may
|
||||||
import android.widget.Button;
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
import android.view.SurfaceView;
|
*/
|
||||||
import android.view.View;
|
|
||||||
import android.view.SurfaceHolder;
|
package org.webrtc.vieautotest;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.opengl.GLSurfaceView;
|
import org.webrtc.vieautotest.R;
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.ArrayAdapter;
|
import android.app.Activity;
|
||||||
import android.widget.AdapterView;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.Button;
|
||||||
public class ViEAutotest extends Activity
|
import android.view.SurfaceView;
|
||||||
implements
|
import android.view.View;
|
||||||
AdapterView.OnItemSelectedListener,
|
import android.view.SurfaceHolder;
|
||||||
View.OnClickListener {
|
import android.widget.LinearLayout;
|
||||||
|
import android.opengl.GLSurfaceView;
|
||||||
private Thread _testThread;
|
import android.widget.Spinner;
|
||||||
private Spinner _testSpinner;
|
import android.widget.ArrayAdapter;
|
||||||
private Spinner _subtestSpinner;
|
import android.widget.AdapterView;
|
||||||
private int _testSelection;
|
|
||||||
private int _subTestSelection;
|
public class ViEAutotest extends Activity
|
||||||
|
implements
|
||||||
// View for remote video
|
AdapterView.OnItemSelectedListener,
|
||||||
private LinearLayout _remoteSurface = null;
|
View.OnClickListener {
|
||||||
private GLSurfaceView _glSurfaceView = null;
|
|
||||||
private SurfaceView _surfaceView = null;
|
private Thread _testThread;
|
||||||
|
private Spinner _testSpinner;
|
||||||
private LinearLayout _localSurface = null;
|
private Spinner _subtestSpinner;
|
||||||
private GLSurfaceView _glLocalSurfaceView = null;
|
private int _testSelection;
|
||||||
private SurfaceView _localSurfaceView = null;
|
private int _subTestSelection;
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
// View for remote video
|
||||||
@Override
|
private LinearLayout _remoteSurface = null;
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
private GLSurfaceView _glSurfaceView = null;
|
||||||
|
private SurfaceView _surfaceView = null;
|
||||||
Log.d("*WEBRTC*", "onCreate called");
|
|
||||||
|
private LinearLayout _localSurface = null;
|
||||||
super.onCreate(savedInstanceState);
|
private GLSurfaceView _glLocalSurfaceView = null;
|
||||||
setContentView(R.layout.main);
|
private SurfaceView _localSurfaceView = null;
|
||||||
|
|
||||||
// Set the Start button action
|
/** Called when the activity is first created. */
|
||||||
final Button buttonStart = (Button) findViewById(R.id.Button01);
|
@Override
|
||||||
buttonStart.setOnClickListener(this);
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
// Set test spinner
|
Log.d("*WEBRTC*", "onCreate called");
|
||||||
_testSpinner = (Spinner) findViewById(R.id.testSpinner);
|
|
||||||
ArrayAdapter<CharSequence> adapter =
|
super.onCreate(savedInstanceState);
|
||||||
ArrayAdapter.createFromResource(this, R.array.test_array,
|
setContentView(R.layout.main);
|
||||||
android.R.layout.simple_spinner_item);
|
|
||||||
|
// Set the Start button action
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
final Button buttonStart = (Button) findViewById(R.id.Button01);
|
||||||
_testSpinner.setAdapter(adapter);
|
buttonStart.setOnClickListener(this);
|
||||||
_testSpinner.setOnItemSelectedListener(this);
|
|
||||||
|
// Set test spinner
|
||||||
|
_testSpinner = (Spinner) findViewById(R.id.testSpinner);
|
||||||
// Set sub test spinner
|
ArrayAdapter<CharSequence> adapter =
|
||||||
_subtestSpinner = (Spinner) findViewById(R.id.subtestSpinner);
|
ArrayAdapter.createFromResource(this, R.array.test_array,
|
||||||
ArrayAdapter<CharSequence> subtestAdapter =
|
android.R.layout.simple_spinner_item);
|
||||||
ArrayAdapter.createFromResource(this, R.array.subtest_array,
|
|
||||||
android.R.layout.simple_spinner_item);
|
int resource = android.R.layout.simple_spinner_dropdown_item;
|
||||||
|
adapter.setDropDownViewResource(resource);
|
||||||
subtestAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
_testSpinner.setAdapter(adapter);
|
||||||
_subtestSpinner.setAdapter(subtestAdapter);
|
_testSpinner.setOnItemSelectedListener(this);
|
||||||
_subtestSpinner.setOnItemSelectedListener(this);
|
|
||||||
|
// Set sub test spinner
|
||||||
_remoteSurface = (LinearLayout) findViewById(R.id.RemoteView);
|
_subtestSpinner = (Spinner) findViewById(R.id.subtestSpinner);
|
||||||
_surfaceView = new SurfaceView(this);
|
ArrayAdapter<CharSequence> subtestAdapter =
|
||||||
_remoteSurface.addView(_surfaceView);
|
ArrayAdapter.createFromResource(this, R.array.subtest_array,
|
||||||
|
android.R.layout.simple_spinner_item);
|
||||||
_localSurface = (LinearLayout) findViewById(R.id.LocalView);
|
|
||||||
_localSurfaceView = new SurfaceView(this);
|
subtestAdapter.setDropDownViewResource(resource);
|
||||||
_localSurfaceView.setZOrderMediaOverlay(true);
|
_subtestSpinner.setAdapter(subtestAdapter);
|
||||||
_localSurface.addView(_localSurfaceView);
|
_subtestSpinner.setOnItemSelectedListener(this);
|
||||||
|
|
||||||
|
_remoteSurface = (LinearLayout) findViewById(R.id.RemoteView);
|
||||||
// Set members
|
_surfaceView = new SurfaceView(this);
|
||||||
_testSelection = 0;
|
_remoteSurface.addView(_surfaceView);
|
||||||
_subTestSelection = 0;
|
|
||||||
}
|
_localSurface = (LinearLayout) findViewById(R.id.LocalView);
|
||||||
|
_localSurfaceView = new SurfaceView(this);
|
||||||
public void onClick(View v) {
|
_localSurfaceView.setZOrderMediaOverlay(true);
|
||||||
Log.d("*WEBRTC*", "Button clicked...");
|
_localSurface.addView(_localSurfaceView);
|
||||||
switch (v.getId()) {
|
|
||||||
case R.id.Button01:
|
// Set members
|
||||||
|
_testSelection = 0;
|
||||||
|
_subTestSelection = 0;
|
||||||
new Thread(new Runnable() {
|
}
|
||||||
public void run() {
|
|
||||||
//
|
public void onClick(View v) {
|
||||||
Log.d("*WEBRTC*", "Calling RunTest...");
|
Log.d("*WEBRTC*", "Button clicked...");
|
||||||
RunTest(_testSelection, _subTestSelection, _localSurfaceView, _surfaceView);//
|
switch (v.getId()) {
|
||||||
Log.d("*WEBRTC*", "RunTest done");
|
case R.id.Button01:
|
||||||
}
|
new Thread(new Runnable() {
|
||||||
}).start();
|
public void run() {
|
||||||
}
|
Log.d("*WEBRTC*", "Calling RunTest...");
|
||||||
};
|
RunTest(_testSelection, _subTestSelection,
|
||||||
|
_localSurfaceView, _surfaceView);
|
||||||
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
|
Log.d("*WEBRTC*", "RunTest done");
|
||||||
|
}
|
||||||
if (parent == (Spinner) findViewById(R.id.testSpinner)) {
|
}).start();
|
||||||
_testSelection = position;
|
}
|
||||||
} else {
|
}
|
||||||
_subTestSelection = position;
|
|
||||||
}
|
public void onItemSelected(AdapterView<?> parent, View v,
|
||||||
}
|
int position, long id) {
|
||||||
|
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
if (parent == (Spinner) findViewById(R.id.testSpinner)) {
|
||||||
;
|
_testSelection = position;
|
||||||
}
|
} else {
|
||||||
|
_subTestSelection = position;
|
||||||
@Override
|
}
|
||||||
protected void onStart() {
|
}
|
||||||
super.onStart();
|
|
||||||
}
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
@Override
|
||||||
super.onResume();
|
protected void onStart() {
|
||||||
}
|
super.onStart();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
@Override
|
||||||
super.onPause();
|
protected void onResume() {
|
||||||
}
|
super.onResume();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void onStop() {
|
@Override
|
||||||
super.onStop();
|
protected void onPause() {
|
||||||
}
|
super.onPause();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
super.onDestroy();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// C++ function performing the chosen test
|
@Override
|
||||||
// private native int RunTest(int testSelection, int subtestSelection,
|
protected void onDestroy() {
|
||||||
// GLSurfaceView window1, GLSurfaceView window2);
|
|
||||||
private native int RunTest(int testSelection, int subtestSelection, SurfaceView window1,
|
super.onDestroy();
|
||||||
SurfaceView window2);
|
}
|
||||||
|
|
||||||
|
// C++ function performing the chosen test
|
||||||
/*
|
// private native int RunTest(int testSelection, int subtestSelection,
|
||||||
* this is used to load the 'ViEAutotestJNIAPI' library on application
|
// GLSurfaceView window1, GLSurfaceView window2);
|
||||||
* startup.
|
private native int RunTest(int testSelection, int subtestSelection,
|
||||||
*/
|
SurfaceView window1, SurfaceView window2);
|
||||||
static {
|
|
||||||
Log.d("*WEBRTC*", "Loading ViEAutotest...");
|
// this is used to load the 'ViEAutotestJNIAPI' library on application
|
||||||
System.loadLibrary("ViEAutotestJNIAPI");
|
// startup.
|
||||||
}
|
static {
|
||||||
}
|
Log.d("*WEBRTC*", "Loading ViEAutotest...");
|
||||||
|
System.loadLibrary("webrtc-video-autotest-jni");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user