OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.native_test; | 5 package org.chromium.native_test; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.os.Bundle; | 9 import android.os.Bundle; |
10 import android.os.Environment; | |
10 import android.os.Handler; | 11 import android.os.Handler; |
11 import android.util.Log; | 12 import android.util.Log; |
12 | 13 |
13 import org.chromium.base.PathUtils; | 14 import org.chromium.base.PathUtils; |
14 | 15 |
16 import java.io.File; | |
17 | |
15 // Android's NativeActivity is mostly useful for pure-native code. | 18 // Android's NativeActivity is mostly useful for pure-native code. |
16 // Our tests need to go up to our own java classes, which is not possible using | 19 // Our tests need to go up to our own java classes, which is not possible using |
17 // the native activity class loader. | 20 // the native activity class loader. |
18 public class ChromeNativeTestActivity extends Activity { | 21 public class ChromeNativeTestActivity extends Activity { |
19 private final String TAG = "ChromeNativeTestActivity"; | 22 private final String TAG = "ChromeNativeTestActivity"; |
20 private final String EXTRA_RUN_IN_SUB_THREAD = "RunInSubThread"; | 23 private final String EXTRA_RUN_IN_SUB_THREAD = "RunInSubThread"; |
21 // We post a delayed task to run tests so that we do not block onCreate(). | 24 // We post a delayed task to run tests so that we do not block onCreate(). |
22 private static long RUN_TESTS_DELAY_IN_MS = 300; | 25 private static long RUN_TESTS_DELAY_IN_MS = 300; |
23 | 26 |
24 // Name of our shlib as obtained from a string resource. | 27 // Name of our shlib as obtained from a string resource. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 } | 63 } |
61 } catch (UnsatisfiedLinkError e) { | 64 } catch (UnsatisfiedLinkError e) { |
62 Log.e(TAG, "Unable to load lib" + mLibrary + ".so: " + e); | 65 Log.e(TAG, "Unable to load lib" + mLibrary + ".so: " + e); |
63 nativeTestFailed(); | 66 nativeTestFailed(); |
64 throw e; | 67 throw e; |
65 } | 68 } |
66 } | 69 } |
67 | 70 |
68 private void runTests() { | 71 private void runTests() { |
69 Log.d(TAG, ">>nativeRunTests"); | 72 Log.d(TAG, ">>nativeRunTests"); |
70 nativeRunTests(getFilesDir().getAbsolutePath(), getApplicationContext()) ; | 73 File filesDir = new File(Environment.getExternalStorageDirectory(), |
John Grabowski
2012/07/18 20:40:49
Add reference to test_package_apk.py
bulach
2012/07/19 08:14:33
good point! done.
| |
74 "native_tests/"); | |
75 filesDir.mkdirs(); | |
76 nativeRunTests(filesDir.getAbsolutePath(), getApplicationContext()); | |
71 Log.d(TAG, "<<nativeRunTests"); | 77 Log.d(TAG, "<<nativeRunTests"); |
72 } | 78 } |
73 | 79 |
74 // Signal a failure of the native test loader to python scripts | 80 // Signal a failure of the native test loader to python scripts |
75 // which run tests. For example, we look for | 81 // which run tests. For example, we look for |
76 // RUNNER_FAILED build/android/test_package.py. | 82 // RUNNER_FAILED build/android/test_package.py. |
77 private void nativeTestFailed() { | 83 private void nativeTestFailed() { |
78 Log.e(TAG, "[ RUNNER_FAILED ] could not load native library"); | 84 Log.e(TAG, "[ RUNNER_FAILED ] could not load native library"); |
79 } | 85 } |
80 | 86 |
81 private void loadLibrary() throws UnsatisfiedLinkError { | 87 private void loadLibrary() throws UnsatisfiedLinkError { |
82 Log.i(TAG, "loading: " + mLibrary); | 88 Log.i(TAG, "loading: " + mLibrary); |
83 System.loadLibrary(mLibrary); | 89 System.loadLibrary(mLibrary); |
84 Log.i(TAG, "loaded: " + mLibrary); | 90 Log.i(TAG, "loaded: " + mLibrary); |
85 } | 91 } |
86 | 92 |
87 private native void nativeRunTests(String filesDir, Context appContext); | 93 private native void nativeRunTests(String filesDir, Context appContext); |
88 } | 94 } |
OLD | NEW |