Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java

Issue 10051021: apk-based test runner work for android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « testing/android/generate_native_test.py ('k') | testing/android/native_test.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.native_test;
6
7 import android.app.Activity;
8 import android.os.Bundle;
9 import android.util.Log;
10
11 // Android's NativeActivity is mostly useful for pure-native code.
12 // Our tests need to go up to our own java classes, which is not possible using
13 // the native activity class loader.
14 // We start a background thread in here to run the tests and avoid an ANR.
15 // TODO(bulach): watch out for tests that implicitly assume they run on the main
16 // thread.
17 public class ChromeNativeTestActivity extends Activity {
18 private final String TAG = "ChromeNativeTestActivity";
19
20 // Name of our shlib as obtained from a string resource.
21 private String mLibrary;
22
23 @Override
24 public void onCreate(Bundle savedInstanceState) {
25 super.onCreate(savedInstanceState);
26
27 mLibrary = getResources().getString(R.string.native_library);
28 if ((mLibrary == null) || mLibrary.startsWith("replace")) {
29 nativeTestFailed();
30 return;
31 }
32
33 try {
34 loadLibrary();
35 new Thread() {
36 @Override
37 public void run() {
38 Log.d(TAG, ">>nativeRunTests");
39 nativeRunTests(getFilesDir().getAbsolutePath());
40 // TODO(jrg): make sure a crash in native code
41 // triggers nativeTestFailed().
42 Log.d(TAG, "<<nativeRunTests");
43 }
44 }.start();
45 } catch (UnsatisfiedLinkError e) {
46 Log.e(TAG, "Unable to load lib" + mLibrary + ".so: " + e);
47 nativeTestFailed();
48 throw e;
49 }
50 }
51
52 // Signal a failure of the native test loader to python scripts
53 // which run tests. For example, we look for
54 // RUNNER_FAILED build/android/test_package.py.
55 private void nativeTestFailed() {
56 Log.e(TAG, "[ RUNNER_FAILED ] could not load native library");
57 }
58
59 private void loadLibrary() throws UnsatisfiedLinkError {
60 Log.i(TAG, "loading: " + mLibrary);
61 System.loadLibrary(mLibrary);
62 Log.i(TAG, "loaded: " + mLibrary);
63 }
64
65 private native void nativeRunTests(String filesDir);
66 }
OLDNEW
« no previous file with comments | « testing/android/generate_native_test.py ('k') | testing/android/native_test.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698