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

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

Issue 1407233017: Define a Java-side global application context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // the levels defined in <android/log.h>. 57 // the levels defined in <android/log.h>.
58 void AndroidLog(int priority, const char* format, ...) { 58 void AndroidLog(int priority, const char* format, ...) {
59 va_list args; 59 va_list args;
60 va_start(args, format); 60 va_start(args, format);
61 __android_log_vprint(priority, kLogTag, format, args); 61 __android_log_vprint(priority, kLogTag, format, args);
62 va_end(args); 62 va_end(args);
63 } 63 }
64 64
65 } // namespace 65 } // namespace
66 66
67 static void InitBasicJNI(JNIEnv* env,
68 const JavaParamRef<jobject>& obj) {
69 base::android::RegisterJni(env);
70 }
71
67 static void RunTests(JNIEnv* env, 72 static void RunTests(JNIEnv* env,
68 const JavaParamRef<jobject>& obj, 73 const JavaParamRef<jobject>& obj,
69 const JavaParamRef<jstring>& jcommand_line_flags, 74 const JavaParamRef<jstring>& jcommand_line_flags,
70 const JavaParamRef<jstring>& jcommand_line_file_path, 75 const JavaParamRef<jstring>& jcommand_line_file_path,
71 const JavaParamRef<jstring>& jstdout_file_path, 76 const JavaParamRef<jstring>& jstdout_file_path,
72 jboolean jstdout_fifo, 77 jboolean jstdout_fifo) {
73 const JavaParamRef<jobject>& app_context) {
74 // Command line initialized basically, will be fully initialized later. 78 // Command line initialized basically, will be fully initialized later.
75 static const char* const kInitialArgv[] = { "ChromeTestActivity" }; 79 static const char* const kInitialArgv[] = { "ChromeTestActivity" };
76 base::CommandLine::Init(arraysize(kInitialArgv), kInitialArgv); 80 base::CommandLine::Init(arraysize(kInitialArgv), kInitialArgv);
77 81
78 // Set the application context in base.
79 base::android::InitApplicationContext(env, app_context);
80 base::android::RegisterJni(env);
81
82 std::vector<std::string> args; 82 std::vector<std::string> args;
83 83
84 const std::string command_line_file_path( 84 const std::string command_line_file_path(
85 base::android::ConvertJavaStringToUTF8(env, jcommand_line_file_path)); 85 base::android::ConvertJavaStringToUTF8(env, jcommand_line_file_path));
86 if (command_line_file_path.empty()) 86 if (command_line_file_path.empty())
87 args.push_back("_"); 87 args.push_back("_");
88 else 88 else
89 ParseArgsFromCommandLineFile(command_line_file_path.c_str(), &args); 89 ParseArgsFromCommandLineFile(command_line_file_path.c_str(), &args);
90 90
91 const std::string command_line_flags( 91 const std::string command_line_flags(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 sa.sa_sigaction = SignalHandler; 145 sa.sa_sigaction = SignalHandler;
146 sa.sa_flags = SA_SIGINFO; 146 sa.sa_flags = SA_SIGINFO;
147 147
148 for (unsigned int i = 0; kExceptionSignals[i] != -1; ++i) { 148 for (unsigned int i = 0; kExceptionSignals[i] != -1; ++i) {
149 sigaction(kExceptionSignals[i], &sa, &g_old_sa[kExceptionSignals[i]]); 149 sigaction(kExceptionSignals[i], &sa, &g_old_sa[kExceptionSignals[i]]);
150 } 150 }
151 } 151 }
152 152
153 } // namespace android 153 } // namespace android
154 } // namespace testing 154 } // namespace testing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698