| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.Handler; | 10 import android.os.Handler; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 new Thread() { | 47 new Thread() { |
| 48 @Override | 48 @Override |
| 49 public void run() { | 49 public void run() { |
| 50 runTests(); | 50 runTests(); |
| 51 } | 51 } |
| 52 }.start(); | 52 }.start(); |
| 53 } else { | 53 } else { |
| 54 // Post a task to run the tests. This allows us to not block | 54 // Post a task to run the tests. This allows us to not block |
| 55 // onCreate and still run tests on the main thread. | 55 // onCreate and still run tests on the main thread. |
| 56 new Handler().postDelayed(new Runnable() { | 56 new Handler().postDelayed(new Runnable() { |
| 57 @Override | 57 @Override |
| 58 public void run() { | 58 public void run() { |
| 59 runTests(); | 59 runTests(); |
| 60 } | 60 } |
| 61 }, RUN_TESTS_DELAY_IN_MS); | 61 }, RUN_TESTS_DELAY_IN_MS); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 private void runTests() { | 65 private void runTests() { |
| 66 // This directory is used by build/android/pylib/test_package_apk.py. | 66 // This directory is used by build/android/pylib/test_package_apk.py. |
| 67 nativeRunTests(getFilesDir().getAbsolutePath(), getApplicationContext())
; | 67 nativeRunTests(getFilesDir().getAbsolutePath(), getApplicationContext())
; |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Signal a failure of the native test loader to python scripts | 70 // Signal a failure of the native test loader to python scripts |
| 71 // which run tests. For example, we look for | 71 // which run tests. For example, we look for |
| 72 // RUNNER_FAILED build/android/test_package.py. | 72 // RUNNER_FAILED build/android/test_package.py. |
| 73 private void nativeTestFailed() { | 73 private void nativeTestFailed() { |
| 74 Log.e(TAG, "[ RUNNER_FAILED ] could not load native library"); | 74 Log.e(TAG, "[ RUNNER_FAILED ] could not load native library"); |
| 75 } | 75 } |
| 76 | 76 |
| 77 private void loadLibraries() { | 77 private void loadLibraries() { |
| 78 for (String library : NativeLibraries.LIBRARIES) { | 78 for (String library : NativeLibraries.LIBRARIES) { |
| 79 Log.i(TAG, "loading: " + library); | 79 Log.i(TAG, "loading: " + library); |
| 80 System.loadLibrary(library); | 80 System.loadLibrary(library); |
| 81 Log.i(TAG, "loaded: " + library); | 81 Log.i(TAG, "loaded: " + library); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 private native void nativeRunTests(String filesDir, Context appContext); | 85 private native void nativeRunTests(String filesDir, Context appContext); |
| 86 } | 86 } |
| OLD | NEW |