OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // This class sets up the environment for running the native tests inside an | 5 // This class sets up the environment for running the native tests inside an |
6 // android application. It outputs (to a fifo) markers identifying the | 6 // android application. It outputs (to a fifo) markers identifying the |
7 // START/PASSED/CRASH of the test suite, FAILURE/SUCCESS of individual tests, | 7 // START/PASSED/CRASH of the test suite, FAILURE/SUCCESS of individual tests, |
8 // etc. | 8 // etc. |
9 // These markers are read by the test runner script to generate test results. | 9 // These markers are read by the test runner script to generate test results. |
10 // It installs signal handlers to detect crashes. | 10 // It installs signal handlers to detect crashes. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 static void RunTests(JNIEnv* env, | 119 static void RunTests(JNIEnv* env, |
120 jobject obj, | 120 jobject obj, |
121 jstring jcommand_line_flags, | 121 jstring jcommand_line_flags, |
122 jstring jcommand_line_file_path, | 122 jstring jcommand_line_file_path, |
123 jstring jfiles_dir, | 123 jstring jfiles_dir, |
124 jobject app_context) { | 124 jobject app_context) { |
125 base::AtExitManager exit_manager; | 125 base::AtExitManager exit_manager; |
126 | 126 |
127 // Command line initialized basically, will be fully initialized later. | 127 // Command line initialized basically, will be fully initialized later. |
128 static const char* const kInitialArgv[] = { "ChromeTestActivity" }; | 128 static const char* const kInitialArgv[] = { "ChromeTestActivity" }; |
129 CommandLine::Init(arraysize(kInitialArgv), kInitialArgv); | 129 base::CommandLine::Init(arraysize(kInitialArgv), kInitialArgv); |
130 | 130 |
131 // Set the application context in base. | 131 // Set the application context in base. |
132 base::android::ScopedJavaLocalRef<jobject> scoped_context( | 132 base::android::ScopedJavaLocalRef<jobject> scoped_context( |
133 env, env->NewLocalRef(app_context)); | 133 env, env->NewLocalRef(app_context)); |
134 base::android::InitApplicationContext(env, scoped_context); | 134 base::android::InitApplicationContext(env, scoped_context); |
135 base::android::RegisterJni(env); | 135 base::android::RegisterJni(env); |
136 | 136 |
137 std::vector<std::string> args; | 137 std::vector<std::string> args; |
138 | 138 |
139 const std::string command_line_file_path( | 139 const std::string command_line_file_path( |
140 base::android::ConvertJavaStringToUTF8(env, jcommand_line_file_path)); | 140 base::android::ConvertJavaStringToUTF8(env, jcommand_line_file_path)); |
141 if (command_line_file_path.empty()) | 141 if (command_line_file_path.empty()) |
142 ParseArgsFromCommandLineFile(kCommandLineFilePath, &args); | 142 ParseArgsFromCommandLineFile(kCommandLineFilePath, &args); |
143 else | 143 else |
144 ParseArgsFromCommandLineFile(command_line_file_path.c_str(), &args); | 144 ParseArgsFromCommandLineFile(command_line_file_path.c_str(), &args); |
145 | 145 |
146 const std::string command_line_flags( | 146 const std::string command_line_flags( |
147 base::android::ConvertJavaStringToUTF8(env, jcommand_line_flags)); | 147 base::android::ConvertJavaStringToUTF8(env, jcommand_line_flags)); |
148 ParseArgsFromString(command_line_flags, &args); | 148 ParseArgsFromString(command_line_flags, &args); |
149 | 149 |
150 std::vector<char*> argv; | 150 std::vector<char*> argv; |
151 int argc = ArgsToArgv(args, &argv); | 151 int argc = ArgsToArgv(args, &argv); |
152 | 152 |
153 // Fully initialize command line with arguments. | 153 // Fully initialize command line with arguments. |
154 CommandLine::ForCurrentProcess()->AppendArguments( | 154 base::CommandLine::ForCurrentProcess()->AppendArguments( |
155 CommandLine(argc, &argv[0]), false); | 155 base::CommandLine(argc, &argv[0]), false); |
156 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 156 const base::CommandLine& command_line = |
| 157 *base::CommandLine::ForCurrentProcess(); |
157 | 158 |
158 base::FilePath files_dir( | 159 base::FilePath files_dir( |
159 base::android::ConvertJavaStringToUTF8(env, jfiles_dir)); | 160 base::android::ConvertJavaStringToUTF8(env, jfiles_dir)); |
160 | 161 |
161 // A few options, such "--gtest_list_tests", will just use printf directly | 162 // A few options, such "--gtest_list_tests", will just use printf directly |
162 // Always redirect stdout to a known file. | 163 // Always redirect stdout to a known file. |
163 base::FilePath fifo_path(files_dir.Append(base::FilePath("test.fifo"))); | 164 base::FilePath fifo_path(files_dir.Append(base::FilePath("test.fifo"))); |
164 EnsureCreateFIFO(fifo_path); | 165 EnsureCreateFIFO(fifo_path); |
165 | 166 |
166 base::FilePath stderr_fifo_path, stdin_fifo_path; | 167 base::FilePath stderr_fifo_path, stdin_fifo_path; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 InstallHandlers(); | 205 InstallHandlers(); |
205 | 206 |
206 base::android::InitVM(vm); | 207 base::android::InitVM(vm); |
207 JNIEnv* env = base::android::AttachCurrentThread(); | 208 JNIEnv* env = base::android::AttachCurrentThread(); |
208 if (!RegisterNativesImpl(env)) { | 209 if (!RegisterNativesImpl(env)) { |
209 return -1; | 210 return -1; |
210 } | 211 } |
211 | 212 |
212 return JNI_VERSION_1_4; | 213 return JNI_VERSION_1_4; |
213 } | 214 } |
OLD | NEW |