Chromium Code Reviews| Index: testing/android/native_test/java/src/org/chromium/native_test/NativeTestActivity.java |
| diff --git a/testing/android/native_test/java/src/org/chromium/native_test/NativeTestActivity.java b/testing/android/native_test/java/src/org/chromium/native_test/NativeTestActivity.java |
| index e8c4055722fb6f6fd4b9134ff38765ccd94c1d61..dee64d5d43a4f4869a1cd9592af96cb823e336b9 100644 |
| --- a/testing/android/native_test/java/src/org/chromium/native_test/NativeTestActivity.java |
| +++ b/testing/android/native_test/java/src/org/chromium/native_test/NativeTestActivity.java |
| @@ -6,15 +6,14 @@ package org.chromium.native_test; |
| import android.app.Activity; |
| import android.content.Context; |
| +import android.content.Intent; |
| import android.os.Bundle; |
| import android.os.Environment; |
| import android.os.Handler; |
| import org.chromium.base.CommandLine; |
| +import org.chromium.base.JNINamespace; |
| import org.chromium.base.Log; |
| -import org.chromium.base.PathUtils; |
| -import org.chromium.base.PowerMonitor; |
| -import org.chromium.base.ResourceExtractor; |
| import org.chromium.base.library_loader.NativeLibraries; |
| import java.io.File; |
| @@ -24,6 +23,7 @@ import java.io.File; |
| * Our tests need to go up to our own java classes, which is not possible using |
| * the native activity class loader. |
| */ |
| +@JNINamespace("testing::android") |
| public class NativeTestActivity extends Activity { |
| public static final String EXTRA_COMMAND_LINE_FILE = |
| "org.chromium.native_test.NativeTestActivity.CommandLineFile"; |
| @@ -37,25 +37,50 @@ public class NativeTestActivity extends Activity { |
| // We post a delayed task to run tests so that we do not block onCreate(). |
| private static final long RUN_TESTS_DELAY_IN_MS = 300; |
| + private String mCommandLineFilePath; |
| + private String mCommandLineFlags; |
| + private boolean mRunInSubThread = false; |
| + private boolean mStdoutFifo = false; |
| + private String mStdoutFilePath; |
| + |
| @Override |
| public void onCreate(Bundle savedInstanceState) { |
| super.onCreate(savedInstanceState); |
| CommandLine.init(new String[]{}); |
| - // Needed by path_utils_unittest.cc |
| - PathUtils.setPrivateDataDirectorySuffix("chrome", getApplicationContext()); |
| + parseArgumentsFromIntent(getIntent()); |
| + } |
| + |
| + private void parseArgumentsFromIntent(Intent intent) { |
| + mCommandLineFilePath = intent.getStringExtra(EXTRA_COMMAND_LINE_FILE); |
| + if (mCommandLineFilePath == null) { |
| + mCommandLineFilePath = ""; |
| + } else { |
| + File commandLineFile = new File(mCommandLineFilePath); |
| + if (!commandLineFile.isAbsolute()) { |
| + mCommandLineFilePath = Environment.getExternalStorageDirectory() + "/" |
| + + mCommandLineFilePath; |
| + } |
| + Log.i(TAG, "command line file path: %s", mCommandLineFilePath); |
| + } |
| + |
| + mCommandLineFlags = intent.getStringExtra(EXTRA_COMMAND_LINE_FLAGS); |
| + if (mCommandLineFlags == null) mCommandLineFlags = ""; |
| - ResourceExtractor resourceExtractor = ResourceExtractor.get(getApplicationContext()); |
| - resourceExtractor.setExtractAllPaksAndV8SnapshotForTesting(); |
| - resourceExtractor.startExtractingResources(); |
| - resourceExtractor.waitForCompletion(); |
| + mRunInSubThread = intent.hasExtra(EXTRA_RUN_IN_SUB_THREAD); |
| + |
| + mStdoutFilePath = intent.getStringExtra(EXTRA_STDOUT_FILE); |
| + if (mStdoutFilePath == null) { |
| + mStdoutFilePath = new File(getFilesDir(), "test.fifo").getAbsolutePath(); |
| + mStdoutFifo = true; |
| + } |
| + } |
| - // Needed by system_monitor_unittest.cc |
| - PowerMonitor.createForTests(this); |
| + @Override |
| + public void onStart() { |
| + super.onStart(); |
| - loadLibraries(); |
| - Bundle extras = this.getIntent().getExtras(); |
| - if (extras != null && extras.containsKey(EXTRA_RUN_IN_SUB_THREAD)) { |
| + if (mRunInSubThread) { |
| // Create a new thread and run tests on it. |
| new Thread() { |
| @Override |
| @@ -76,30 +101,7 @@ public class NativeTestActivity extends Activity { |
| } |
| private void runTests() { |
| - String commandLineFlags = getIntent().getStringExtra(EXTRA_COMMAND_LINE_FLAGS); |
| - if (commandLineFlags == null) commandLineFlags = ""; |
| - |
| - String commandLineFilePath = getIntent().getStringExtra(EXTRA_COMMAND_LINE_FILE); |
| - if (commandLineFilePath == null) { |
| - commandLineFilePath = ""; |
| - } else { |
| - File commandLineFile = new File(commandLineFilePath); |
| - if (!commandLineFile.isAbsolute()) { |
| - commandLineFilePath = Environment.getExternalStorageDirectory() + "/" |
| - + commandLineFilePath; |
| - } |
| - Log.i(TAG, "command line file path: %s", commandLineFilePath); |
| - } |
| - |
| - String stdoutFilePath = getIntent().getStringExtra(EXTRA_STDOUT_FILE); |
| - boolean stdoutFifo = false; |
| - if (stdoutFilePath == null) { |
| - stdoutFilePath = new File(getFilesDir(), "test.fifo").getAbsolutePath(); |
| - stdoutFifo = true; |
| - } |
| - |
| - // This directory is used by build/android/pylib/test_package_apk.py. |
| - nativeRunTests(commandLineFlags, commandLineFilePath, stdoutFilePath, stdoutFifo, |
| + nativeRunTests(mCommandLineFlags, mCommandLineFilePath, mStdoutFilePath, mStdoutFifo, |
| getApplicationContext()); |
| finish(); |
| } |
| @@ -111,7 +113,7 @@ public class NativeTestActivity extends Activity { |
| Log.e(TAG, "[ RUNNER_FAILED ] could not load native library"); |
| } |
| - private void loadLibraries() { |
| + protected void loadLibraries() { |
|
Ted C
2015/05/05 23:11:17
javadoc here as well.
jbudorick
2015/05/06 18:00:00
this is now private in NativeUnitTestActivity
|
| for (String library : NativeLibraries.LIBRARIES) { |
| Log.i(TAG, "loading: %s", library); |
| System.loadLibrary(library); |