blob: a6290b9476c6aa58b0f4e3c83dc44f0ba41aa631 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.native_test;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
// Android's NativeActivity is mostly useful for pure-native code.
// Our tests need to go up to our own java classes, which is not possible using
// the native activity class loader.
// We start a background thread in here to run the tests and avoid an ANR.
// TODO(bulach): watch out for tests that implicitly assume they run on the main
// thread.
public class ChromeNativeTestActivity extends Activity {
private final String TAG = "ChromeNativeTestActivity";
private final String LIBRARY = "native_tests";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
loadLibrary();
new Thread() {
@Override
public void run() {
Log.d(TAG, ">>nativeRunTests");
nativeRunTests(getFilesDir().getAbsolutePath());
Log.d(TAG, "<<nativeRunTests");
}
}.start();
} catch (UnsatisfiedLinkError e) {
Log.e(TAG, "Unable to load libnative_tests.so: " + e);
throw e;
}
}
private void loadLibrary() throws UnsatisfiedLinkError {
Log.i(TAG, "loading: " + LIBRARY);
System.loadLibrary(LIBRARY);
Log.i(TAG, "loaded: " + LIBRARY);
}
private native void nativeRunTests(String filesDir);
}
|