Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
|
Satish
2012/03/27 13:53:24
could change year to 2012
| |
| 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; | |
|
Satish
2012/03/27 13:53:24
should this file be under a 'org/chromium/native_t
klobag.chromium
2012/03/28 00:28:57
For future proof where we may add resources, we sh
| |
| 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 private final String LIBRARY = "native_tests"; | |
| 20 | |
| 21 @Override | |
| 22 public void onCreate(Bundle savedInstanceState) { | |
| 23 super.onCreate(savedInstanceState); | |
| 24 try { | |
| 25 loadLibrary(); | |
| 26 new Thread() { | |
| 27 @Override | |
| 28 public void run() { | |
| 29 Log.d(TAG, ">>nativeRunTests"); | |
| 30 nativeRunTests(getFilesDir().getAbsolutePath()); | |
| 31 Log.d(TAG, "<<nativeRunTests"); | |
| 32 } | |
| 33 }.start(); | |
| 34 } catch (UnsatisfiedLinkError e) { | |
| 35 Log.e(TAG, "Unable to load libnative_tests.so: " + e); | |
| 36 throw e; | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 private void loadLibrary() throws UnsatisfiedLinkError { | |
| 41 Log.i(TAG, "loading: " + LIBRARY); | |
| 42 System.loadLibrary(LIBRARY); | |
| 43 Log.i(TAG, "loaded: " + LIBRARY); | |
| 44 } | |
| 45 | |
| 46 private native void nativeRunTests(String filesDir); | |
| 47 } | |
| OLD | NEW |