This source file includes following definitions.
- onCreate
- runTests
- nativeTestFailed
- loadLibraries
- nativeRunTests
package org.chromium.native_test;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import org.chromium.base.PathUtils;
import org.chromium.base.PowerMonitor;
import org.chromium.base.library_loader.NativeLibraries;
public class ChromeNativeTestActivity extends Activity {
private static final String TAG = "ChromeNativeTestActivity";
private static final String EXTRA_RUN_IN_SUB_THREAD = "RunInSubThread";
private static final long RUN_TESTS_DELAY_IN_MS = 300;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PathUtils.setPrivateDataDirectorySuffix("chrome");
PowerMonitor.createForTests(this);
loadLibraries();
Bundle extras = this.getIntent().getExtras();
if (extras != null && extras.containsKey(EXTRA_RUN_IN_SUB_THREAD)) {
new Thread() {
@Override
public void run() {
runTests();
}
}.start();
} else {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
runTests();
}
}, RUN_TESTS_DELAY_IN_MS);
}
}
private void runTests() {
nativeRunTests(getFilesDir().getAbsolutePath(), getApplicationContext());
}
private void nativeTestFailed() {
Log.e(TAG, "[ RUNNER_FAILED ] could not load native library");
}
private void loadLibraries() {
for (String library : NativeLibraries.LIBRARIES) {
Log.i(TAG, "loading: " + library);
System.loadLibrary(library);
Log.i(TAG, "loaded: " + library);
}
}
private native void nativeRunTests(String filesDir, Context appContext);
}