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

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

Issue 10804003: Android: fix test runners for non-rooted devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 8 years, 5 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/AndroidManifest.xml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // This directory is used by build/android/pylib/test_package_apk.py.
74 File filesDir = new File(Environment.getExternalStorageDirectory(),
75 "native_tests/");
76 filesDir.mkdirs();
77 nativeRunTests(filesDir.getAbsolutePath(), getApplicationContext());
71 Log.d(TAG, "<<nativeRunTests"); 78 Log.d(TAG, "<<nativeRunTests");
72 } 79 }
73 80
74 // Signal a failure of the native test loader to python scripts 81 // Signal a failure of the native test loader to python scripts
75 // which run tests. For example, we look for 82 // which run tests. For example, we look for
76 // RUNNER_FAILED build/android/test_package.py. 83 // RUNNER_FAILED build/android/test_package.py.
77 private void nativeTestFailed() { 84 private void nativeTestFailed() {
78 Log.e(TAG, "[ RUNNER_FAILED ] could not load native library"); 85 Log.e(TAG, "[ RUNNER_FAILED ] could not load native library");
79 } 86 }
80 87
81 private void loadLibrary() throws UnsatisfiedLinkError { 88 private void loadLibrary() throws UnsatisfiedLinkError {
82 Log.i(TAG, "loading: " + mLibrary); 89 Log.i(TAG, "loading: " + mLibrary);
83 System.loadLibrary(mLibrary); 90 System.loadLibrary(mLibrary);
84 Log.i(TAG, "loaded: " + mLibrary); 91 Log.i(TAG, "loaded: " + mLibrary);
85 } 92 }
86 93
87 private native void nativeRunTests(String filesDir, Context appContext); 94 private native void nativeRunTests(String filesDir, Context appContext);
88 } 95 }
OLDNEW
« no previous file with comments | « testing/android/AndroidManifest.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698