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

Unified Diff: base/test/android/java/org/chromium/ChromeNativeTestActivity.java

Issue 9834037: apk-based test runner work. Not enabled yet. This CL is a combination of upstreaming, ndk/ant-ifi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: base/test/android/java/org/chromium/ChromeNativeTestActivity.java
diff --git a/base/test/android/java/org/chromium/ChromeNativeTestActivity.java b/base/test/android/java/org/chromium/ChromeNativeTestActivity.java
new file mode 100644
index 0000000000000000000000000000000000000000..db3b25b4d6c4ed4161d0922ef2f4cdca6a732819
--- /dev/null
+++ b/base/test/android/java/org/chromium/ChromeNativeTestActivity.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
bulach 2012/03/23 10:30:48 nit: 2012
John Grabowski 2012/03/24 01:59:18 Technically this was written in 2011... but ok.
+// 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);
+}

Powered by Google App Engine
This is Rietveld 408576698