| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 const JavaParamRef<jobject>& obj, | 68 const JavaParamRef<jobject>& obj, |
| 69 const JavaParamRef<jstring>& jcommand_line_flags, | 69 const JavaParamRef<jstring>& jcommand_line_flags, |
| 70 const JavaParamRef<jstring>& jcommand_line_file_path, | 70 const JavaParamRef<jstring>& jcommand_line_file_path, |
| 71 const JavaParamRef<jstring>& jstdout_file_path, | 71 const JavaParamRef<jstring>& jstdout_file_path, |
| 72 jboolean jstdout_fifo, | 72 jboolean jstdout_fifo, |
| 73 const JavaParamRef<jobject>& app_context) { | 73 const JavaParamRef<jobject>& app_context) { |
| 74 // Command line initialized basically, will be fully initialized later. | 74 // Command line initialized basically, will be fully initialized later. |
| 75 static const char* const kInitialArgv[] = { "ChromeTestActivity" }; | 75 static const char* const kInitialArgv[] = { "ChromeTestActivity" }; |
| 76 base::CommandLine::Init(arraysize(kInitialArgv), kInitialArgv); | 76 base::CommandLine::Init(arraysize(kInitialArgv), kInitialArgv); |
| 77 | 77 |
| 78 // Set the application context in base. | |
| 79 base::android::RegisterJni(env); | |
| 80 base::android::InitApplicationContext(env, app_context); | |
| 81 | |
| 82 std::vector<std::string> args; | 78 std::vector<std::string> args; |
| 83 | 79 |
| 84 const std::string command_line_file_path( | 80 const std::string command_line_file_path( |
| 85 base::android::ConvertJavaStringToUTF8(env, jcommand_line_file_path)); | 81 base::android::ConvertJavaStringToUTF8(env, jcommand_line_file_path)); |
| 86 if (command_line_file_path.empty()) | 82 if (command_line_file_path.empty()) |
| 87 args.push_back("_"); | 83 args.push_back("_"); |
| 88 else | 84 else |
| 89 ParseArgsFromCommandLineFile(command_line_file_path.c_str(), &args); | 85 ParseArgsFromCommandLineFile(command_line_file_path.c_str(), &args); |
| 90 | 86 |
| 91 const std::string command_line_flags( | 87 const std::string command_line_flags( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 "Native test waiting for GDB because flag %s was supplied", | 122 "Native test waiting for GDB because flag %s was supplied", |
| 127 switches::kWaitForDebugger); | 123 switches::kWaitForDebugger); |
| 128 base::debug::WaitForDebugger(24 * 60 * 60, false); | 124 base::debug::WaitForDebugger(24 * 60 * 60, false); |
| 129 } | 125 } |
| 130 | 126 |
| 131 ScopedMainEntryLogger scoped_main_entry_logger; | 127 ScopedMainEntryLogger scoped_main_entry_logger; |
| 132 main(argc, &argv[0]); | 128 main(argc, &argv[0]); |
| 133 } | 129 } |
| 134 | 130 |
| 135 bool RegisterNativeTestJNI(JNIEnv* env) { | 131 bool RegisterNativeTestJNI(JNIEnv* env) { |
| 132 if (!base::android::RegisterJni(env)) { |
| 133 return false; |
| 134 } |
| 136 return RegisterNativesImpl(env); | 135 return RegisterNativesImpl(env); |
| 137 } | 136 } |
| 138 | 137 |
| 139 // TODO(nileshagrawal): now that we're using FIFO, test scripts can detect EOF. | 138 // TODO(nileshagrawal): now that we're using FIFO, test scripts can detect EOF. |
| 140 // Remove the signal handlers. | 139 // Remove the signal handlers. |
| 141 void InstallHandlers() { | 140 void InstallHandlers() { |
| 142 struct sigaction sa; | 141 struct sigaction sa; |
| 143 memset(&sa, 0, sizeof(sa)); | 142 memset(&sa, 0, sizeof(sa)); |
| 144 | 143 |
| 145 sa.sa_sigaction = SignalHandler; | 144 sa.sa_sigaction = SignalHandler; |
| 146 sa.sa_flags = SA_SIGINFO; | 145 sa.sa_flags = SA_SIGINFO; |
| 147 | 146 |
| 148 for (unsigned int i = 0; kExceptionSignals[i] != -1; ++i) { | 147 for (unsigned int i = 0; kExceptionSignals[i] != -1; ++i) { |
| 149 sigaction(kExceptionSignals[i], &sa, &g_old_sa[kExceptionSignals[i]]); | 148 sigaction(kExceptionSignals[i], &sa, &g_old_sa[kExceptionSignals[i]]); |
| 150 } | 149 } |
| 151 } | 150 } |
| 152 | 151 |
| 153 } // namespace android | 152 } // namespace android |
| 154 } // namespace testing | 153 } // namespace testing |
| OLD | NEW |