Home | History | Annotate | Download | only in test
      1 package org.webrtc.voiceengine.test;
      2 
      3 import android.app.Activity;
      4 import android.media.AudioManager;
      5 import android.os.Bundle;
      6 import android.util.Log;
      7 import android.view.View;
      8 import android.widget.Button;
      9 
     10 public class AudioDeviceAndroidTest extends Activity {
     11     private Thread _testThread;
     12 
     13     /** Called when the activity is first created. */
     14     @Override
     15     public void onCreate(Bundle savedInstanceState) {
     16         super.onCreate(savedInstanceState);
     17         setContentView(R.layout.main);
     18 
     19         final Button buttonStart = (Button) findViewById(R.id.Button01);
     20         // buttonStart.setWidth(200);
     21         // button.layout(50, 50, 100, 40);
     22         buttonStart.setOnClickListener(new View.OnClickListener() {
     23             public void onClick(View v) {
     24                 _testThread = new Thread(_testProc);
     25                 _testThread.start();
     26             }
     27         });
     28 
     29         // Suggest to use the voice call audio stream for hardware volume
     30         // controls
     31         setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
     32 
     33         DoLog("Started WebRTC Android ADM Test");
     34     }
     35 
     36     private Runnable _testProc = new Runnable() {
     37         public void run() {
     38             // TODO(xians), choose test from GUI
     39             // Select test here, 0 for API test, 1-> for Func tests
     40             RunTest(5);
     41         }
     42     };
     43 
     44     private void DoLog(String msg) {
     45         Log.d("*WebRTC ADM*", msg);
     46     }
     47 
     48     // //////////////// Native function prototypes ////////////////////
     49 
     50     // Init wrapper
     51     private native static boolean NativeInit();
     52 
     53     // Function used to call test
     54     private native int RunTest(int testType);
     55 
     56     // Load native library
     57     static {
     58         Log.d("*WebRTC ADM*", "Loading audio_device_android_test...");
     59         System.loadLibrary("audio_device_android_test");
     60 
     61         Log.d("*WebRTC ADM*", "Calling native init...");
     62         if (!NativeInit()) {
     63             Log.e("*WebRTC ADM*", "Native init failed");
     64             throw new RuntimeException("Native init failed");
     65         } else {
     66             Log.d("*WebRTC ADM*", "Native init successful");
     67         }
     68     }
     69 }
     70