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

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

Issue 10696172: Allow unit tests to run in a sub thread for chrome on android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
diff --git a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
index ec978c453ed6501215bfa7b7a2eb0e5fc7e4855a..3046eb7eb2676edc086109f78f12017101653ce9 100644
--- a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
+++ b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
@@ -15,6 +15,7 @@ import android.util.Log;
// the native activity class loader.
public class ChromeNativeTestActivity extends Activity {
private final String TAG = "ChromeNativeTestActivity";
+ private final String EXTRA_RUN_IN_SUB_THREAD = "RunInSubThread";
// We post a delayed task to run tests so that we do not block onCreate().
private static long RUN_TESTS_DELAY_IN_MS = 300;
@@ -33,14 +34,25 @@ public class ChromeNativeTestActivity extends Activity {
try {
loadLibrary();
- // Post a task to run the tests. This allows us to not block onCreate and
- // still run tests on the main thread.
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- runTests();
- }
- }, RUN_TESTS_DELAY_IN_MS);
+ Bundle extras = this.getIntent().getExtras();
+ if (extras != null && extras.containsKey(EXTRA_RUN_IN_SUB_THREAD)) {
+ // Create a new thread and run tests on it.
+ new Thread() {
+ @Override
+ public void run() {
+ runTests();
+ }
+ }.start();
+ } else {
+ // Post a task to run the tests. This allows us to not block
+ // onCreate and still run tests on the main thread.
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ runTests();
+ }
+ }, RUN_TESTS_DELAY_IN_MS);
+ }
} catch (UnsatisfiedLinkError e) {
Log.e(TAG, "Unable to load lib" + mLibrary + ".so: " + e);
nativeTestFailed();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698