| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/android/jni_array.h" | 7 #include "base/android/jni_array.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/posix/global_descriptors.h" | 9 #include "base/posix/global_descriptors.h" |
| 10 #include "jni/MainRunner_jni.h" | 10 #include "jni/MainRunner_jni.h" |
| 11 #include "testing/android/native_test/native_test_util.h" |
| 11 | 12 |
| 12 extern int main(int argc, char** argv); | 13 extern int main(int argc, char** argv); |
| 13 | 14 |
| 14 namespace testing { | 15 namespace testing { |
| 15 namespace android { | 16 namespace android { |
| 16 | 17 |
| 17 bool RegisterMainRunnerJni(JNIEnv* env) { | 18 bool RegisterMainRunnerJni(JNIEnv* env) { |
| 18 return RegisterNativesImpl(env); | 19 return RegisterNativesImpl(env); |
| 19 } | 20 } |
| 20 | 21 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 37 base::android::JavaIntArrayToIntVector(env, fds_to_map_fds, &fds); | 38 base::android::JavaIntArrayToIntVector(env, fds_to_map_fds, &fds); |
| 38 CHECK_EQ(keys.size(), fds.size()); | 39 CHECK_EQ(keys.size(), fds.size()); |
| 39 | 40 |
| 40 for (size_t i = 0; i < keys.size(); i++) { | 41 for (size_t i = 0; i < keys.size(); i++) { |
| 41 base::GlobalDescriptors::GetInstance()->Set(keys[i], fds[i]); | 42 base::GlobalDescriptors::GetInstance()->Set(keys[i], fds[i]); |
| 42 } | 43 } |
| 43 | 44 |
| 44 std::vector<std::string> cpp_command_line; | 45 std::vector<std::string> cpp_command_line; |
| 45 AppendJavaStringArrayToStringVector(env, command_line, &cpp_command_line); | 46 AppendJavaStringArrayToStringVector(env, command_line, &cpp_command_line); |
| 46 | 47 |
| 47 std::vector<char*> c_command_line; | 48 std::vector<char*> argv; |
| 48 for (auto& entry : cpp_command_line) { | 49 int argc = ArgsToArgv(cpp_command_line, &argv); |
| 49 c_command_line.push_back(&entry[0]); | 50 return main(argc, &argv[0]); |
| 50 } | |
| 51 | |
| 52 return main(c_command_line.size(), &c_command_line[0]); | |
| 53 } | 51 } |
| 54 | 52 |
| 55 } // namespace android | 53 } // namespace android |
| 56 } // namespace testing | 54 } // namespace testing |
| OLD | NEW |