Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: testing/android/native_test_launcher.cc

Issue 10662056: Revert "Use a test specific macro to call JNI registrars during APK tests." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/net.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
17 #include "base/android/jni_android.h" 16 #include "base/android/jni_android.h"
18 #include "base/android/jni_string.h" 17 #include "base/android/jni_string.h"
18 #include "base/android/locale_utils.h"
19 #include "base/android/path_utils.h"
19 #include "base/android/scoped_java_ref.h" 20 #include "base/android/scoped_java_ref.h"
20 #include "base/at_exit.h" 21 #include "base/at_exit.h"
21 #include "base/command_line.h" 22 #include "base/command_line.h"
22 #include "base/file_path.h" 23 #include "base/file_path.h"
23 #include "base/file_util.h" 24 #include "base/file_util.h"
24 #include "base/logging.h" 25 #include "base/logging.h"
25 #include "base/stringprintf.h" 26 #include "base/stringprintf.h"
26 #include "base/string_tokenizer.h" 27 #include "base/string_tokenizer.h"
27 #include "base/string_util.h" 28 #include "base/string_util.h"
28 #include "gtest/gtest.h" 29 #include "gtest/gtest.h"
29 #include "testing/android/jni/chrome_native_test_activity_jni.h" 30 #include "testing/android/jni/chrome_native_test_activity_jni.h"
30 31
31 #if defined(REGISTER_NET_UNITTESTS_JNI)
32 #include "net/android/net_jni_registrar.h"
33 #endif
34
35 #if defined(REGISTER_CONTENT_UNITTESTS_JNI)
36 #include "content/app/android/content_jni_registrar.h"
37 #endif
38
39 // The main function of the program to be wrapped as a test apk. 32 // The main function of the program to be wrapped as a test apk.
40 extern int main(int argc, char** argv); 33 extern int main(int argc, char** argv);
41 34
42 namespace { 35 namespace {
43 36
44 // The list of signals which are considered to be crashes. 37 // The list of signals which are considered to be crashes.
45 const int kExceptionSignals[] = { 38 const int kExceptionSignals[] = {
46 SIGSEGV, SIGABRT, SIGFPE, SIGILL, SIGBUS, -1 39 SIGSEGV, SIGABRT, SIGFPE, SIGILL, SIGBUS, -1
47 }; 40 };
48 41
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 base::AtExitManager exit_manager; 169 base::AtExitManager exit_manager;
177 170
178 static const char* const kInitialArgv[] = { "ChromeTestActivity" }; 171 static const char* const kInitialArgv[] = { "ChromeTestActivity" };
179 CommandLine::Init(arraysize(kInitialArgv), kInitialArgv); 172 CommandLine::Init(arraysize(kInitialArgv), kInitialArgv);
180 173
181 // Set the application context in base. 174 // Set the application context in base.
182 base::android::ScopedJavaLocalRef<jobject> scoped_context( 175 base::android::ScopedJavaLocalRef<jobject> scoped_context(
183 env, env->NewLocalRef(app_context)); 176 env, env->NewLocalRef(app_context));
184 base::android::InitApplicationContext(scoped_context); 177 base::android::InitApplicationContext(scoped_context);
185 178
186 base::android::RegisterJni(env); 179 base::android::RegisterLocaleUtils(env);
187 180 base::android::RegisterPathUtils(env);
188 // A unittest target may define these macros to register JNI dependencies.
189 // These should only be defined if the target also depends on the
190 // corresponding registrar.
191 #if defined(REGISTER_NET_UNITTESTS_JNI)
192 net::android::RegisterJni(env);
193 #endif
194
195 #if defined(REGISTER_CONTENT_UNITTESTS_JNI)
196 content::android::RegisterJni(env);
197 #endif
198 181
199 FilePath files_dir(base::android::ConvertJavaStringToUTF8(env, jfiles_dir)); 182 FilePath files_dir(base::android::ConvertJavaStringToUTF8(env, jfiles_dir));
200 // A few options, such "--gtest_list_tests", will just use printf directly 183 // A few options, such "--gtest_list_tests", will just use printf directly
201 // and won't use the "AndroidLogPrinter". Redirect stdout to a known file. 184 // and won't use the "AndroidLogPrinter". Redirect stdout to a known file.
202 FilePath stdout_path(files_dir.Append(FilePath("stdout.txt"))); 185 FilePath stdout_path(files_dir.Append(FilePath("stdout.txt")));
203 freopen(stdout_path.value().c_str(), "w", stdout); 186 freopen(stdout_path.value().c_str(), "w", stdout);
204 187
205 std::vector<std::string> args; 188 std::vector<std::string> args;
206 ParseArgsFromCommandLineFile(&args); 189 ParseArgsFromCommandLineFile(&args);
207 190
(...skipping 15 matching lines...) Expand all
223 InstallHandlers(); 206 InstallHandlers();
224 207
225 base::android::InitVM(vm); 208 base::android::InitVM(vm);
226 JNIEnv* env = base::android::AttachCurrentThread(); 209 JNIEnv* env = base::android::AttachCurrentThread();
227 if (!RegisterNativesImpl(env)) { 210 if (!RegisterNativesImpl(env)) {
228 return -1; 211 return -1;
229 } 212 }
230 213
231 return JNI_VERSION_1_4; 214 return JNI_VERSION_1_4;
232 } 215 }
OLDNEW
« no previous file with comments | « net/net.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698