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 logcat) markers identifying the | 6 // android application. It outputs (to logcat) markers identifying the |
7 // START/END/CRASH of the test suite, FAILURE/SUCCESS of individual tests etc. | 7 // START/END/CRASH of the test suite, FAILURE/SUCCESS of individual tests etc. |
8 // These markers are read by the test runner script to generate test results. | 8 // These markers are read by the test runner script to generate test results. |
9 // It injects an event listener in gtest to detect various test stages and | 9 // It injects an event listener in gtest to detect various test stages and |
10 // installs signal handlers to detect crashes. | 10 // installs signal handlers to detect crashes. |
11 | 11 |
12 #include <android/log.h> | 12 #include <android/log.h> |
13 #include <signal.h> | 13 #include <signal.h> |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 | 15 |
| 16 #include "base/android/base_jni_registrar.h" |
16 #include "base/android/jni_android.h" | 17 #include "base/android/jni_android.h" |
17 #include "base/android/jni_string.h" | 18 #include "base/android/jni_string.h" |
18 #include "base/android/locale_utils.h" | 19 #include "base/android/locale_utils.h" |
19 #include "base/android/path_utils.h" | 20 #include "base/android/path_utils.h" |
20 #include "base/android/scoped_java_ref.h" | 21 #include "base/android/scoped_java_ref.h" |
21 #include "base/at_exit.h" | 22 #include "base/at_exit.h" |
22 #include "base/command_line.h" | 23 #include "base/command_line.h" |
23 #include "base/file_path.h" | 24 #include "base/file_path.h" |
24 #include "base/file_util.h" | 25 #include "base/file_util.h" |
25 #include "base/logging.h" | 26 #include "base/logging.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 jobject app_context) { | 169 jobject app_context) { |
169 base::AtExitManager exit_manager; | 170 base::AtExitManager exit_manager; |
170 | 171 |
171 static const char* const kInitialArgv[] = { "ChromeTestActivity" }; | 172 static const char* const kInitialArgv[] = { "ChromeTestActivity" }; |
172 CommandLine::Init(arraysize(kInitialArgv), kInitialArgv); | 173 CommandLine::Init(arraysize(kInitialArgv), kInitialArgv); |
173 | 174 |
174 // Set the application context in base. | 175 // Set the application context in base. |
175 base::android::ScopedJavaLocalRef<jobject> scoped_context( | 176 base::android::ScopedJavaLocalRef<jobject> scoped_context( |
176 env, env->NewLocalRef(app_context)); | 177 env, env->NewLocalRef(app_context)); |
177 base::android::InitApplicationContext(scoped_context); | 178 base::android::InitApplicationContext(scoped_context); |
178 | 179 base::android::RegisterJni(env); |
179 base::android::RegisterLocaleUtils(env); | |
180 base::android::RegisterPathUtils(env); | |
181 | 180 |
182 FilePath files_dir(base::android::ConvertJavaStringToUTF8(env, jfiles_dir)); | 181 FilePath files_dir(base::android::ConvertJavaStringToUTF8(env, jfiles_dir)); |
183 // A few options, such "--gtest_list_tests", will just use printf directly | 182 // A few options, such "--gtest_list_tests", will just use printf directly |
184 // and won't use the "AndroidLogPrinter". Redirect stdout to a known file. | 183 // and won't use the "AndroidLogPrinter". Redirect stdout to a known file. |
185 FilePath stdout_path(files_dir.Append(FilePath("stdout.txt"))); | 184 FilePath stdout_path(files_dir.Append(FilePath("stdout.txt"))); |
186 freopen(stdout_path.value().c_str(), "w", stdout); | 185 freopen(stdout_path.value().c_str(), "w", stdout); |
187 | 186 |
188 std::vector<std::string> args; | 187 std::vector<std::string> args; |
189 ParseArgsFromCommandLineFile(&args); | 188 ParseArgsFromCommandLineFile(&args); |
190 | 189 |
(...skipping 15 matching lines...) Expand all Loading... |
206 InstallHandlers(); | 205 InstallHandlers(); |
207 | 206 |
208 base::android::InitVM(vm); | 207 base::android::InitVM(vm); |
209 JNIEnv* env = base::android::AttachCurrentThread(); | 208 JNIEnv* env = base::android::AttachCurrentThread(); |
210 if (!RegisterNativesImpl(env)) { | 209 if (!RegisterNativesImpl(env)) { |
211 return -1; | 210 return -1; |
212 } | 211 } |
213 | 212 |
214 return JNI_VERSION_1_4; | 213 return JNI_VERSION_1_4; |
215 } | 214 } |
OLD | NEW |