| Index: content/shell/android/browsertests_apk/content_browser_tests_android.cc
|
| diff --git a/content/shell/android/browsertests_apk/content_browser_tests_android.cc b/content/shell/android/browsertests_apk/content_browser_tests_android.cc
|
| index 83f24f6d5f483032950229329d4832ebd3525d9d..fd8563f06669ea908558e4397116a17fc12045bb 100644
|
| --- a/content/shell/android/browsertests_apk/content_browser_tests_android.cc
|
| +++ b/content/shell/android/browsertests_apk/content_browser_tests_android.cc
|
| @@ -22,60 +22,19 @@
|
| #include "content/public/app/android_library_loader_hooks.h"
|
| #include "content/shell/android/shell_jni_registrar.h"
|
| #include "jni/ContentBrowserTestsActivity_jni.h"
|
| +#include "testing/android/native_test_util.h"
|
| +
|
| +using testing::NativeTestUtil;
|
|
|
| // The main function of the program to be wrapped as an apk.
|
| extern int main(int argc, char** argv);
|
|
|
| namespace {
|
|
|
| -void ParseArgsFromString(const std::string& command_line,
|
| - std::vector<std::string>* args) {
|
| - base::StringTokenizer tokenizer(command_line, kWhitespaceASCII);
|
| - tokenizer.set_quote_chars("\"");
|
| - while (tokenizer.GetNext()) {
|
| - std::string token;
|
| - RemoveChars(tokenizer.token(), "\"", &token);
|
| - args->push_back(token);
|
| - }
|
| -}
|
| -
|
| -void ParseArgsFromCommandLineFile(std::vector<std::string>* args) {
|
| - // The test runner script writes the command line file in
|
| - // "/data/local/tmp".
|
| - static const char kCommandLineFilePath[] =
|
| - "/data/local/tmp/content-browser-tests-command-line";
|
| - FilePath command_line(kCommandLineFilePath);
|
| - std::string command_line_string;
|
| - if (file_util::ReadFileToString(command_line, &command_line_string)) {
|
| - ParseArgsFromString(command_line_string, args);
|
| - }
|
| -}
|
| -
|
| -int ArgsToArgv(const std::vector<std::string>& args,
|
| - std::vector<char*>* argv) {
|
| - // We need to pass in a non-const char**.
|
| - int argc = args.size();
|
| -
|
| - argv->resize(argc + 1);
|
| - for (int i = 0; i < argc; ++i)
|
| - (*argv)[i] = const_cast<char*>(args[i].c_str());
|
| - (*argv)[argc] = NULL; // argv must be NULL terminated.
|
| -
|
| - return argc;
|
| -}
|
| -
|
| -class ScopedMainEntryLogger {
|
| - public:
|
| - ScopedMainEntryLogger() {
|
| - printf(">>ScopedMainEntryLogger\n");
|
| - }
|
| -
|
| - ~ScopedMainEntryLogger() {
|
| - printf("<<ScopedMainEntryLogger\n");
|
| - fflush(stdout);
|
| - fflush(stderr);
|
| - }
|
| -};
|
| +// The test runner script writes the command line file in
|
| +// "/data/local/tmp".
|
| +static const char kCommandLineFilePath[] =
|
| + "/data/local/tmp/content-browser-tests-command-line";
|
|
|
| } // namespace
|
|
|
| @@ -95,17 +54,16 @@ static void RunTests(JNIEnv* env,
|
| base::android::RegisterJni(env);
|
|
|
| std::vector<std::string> args;
|
| - ParseArgsFromCommandLineFile(&args);
|
| + NativeTestUtil::ParseArgsFromCommandLineFile(kCommandLineFilePath, &args);
|
|
|
| - // We need to pass in a non-const char**.
|
| std::vector<char*> argv;
|
| - int argc = ArgsToArgv(args, &argv);
|
| + int argc = NativeTestUtil::ArgsToArgv(args, &argv);
|
|
|
| // Fully initialize command line with arguments.
|
| CommandLine::ForCurrentProcess()->AppendArguments(
|
| CommandLine(argc, &argv[0]), false);
|
|
|
| - ScopedMainEntryLogger scoped_main_entry_logger;
|
| + NativeTestUtil::ScopedMainEntryLogger scoped_main_entry_logger;
|
| main(argc, &argv[0]);
|
| }
|
|
|
|
|