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 content browser tests | 5 // This class sets up the environment for running the content browser tests |
6 // inside an android application. | 6 // inside an android application. |
7 | 7 |
8 #include <android/log.h> | 8 #include <android/log.h> |
9 | 9 |
10 #include "base/android/base_jni_registrar.h" | 10 #include "base/android/base_jni_registrar.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 ParseArgsFromCommandLineFile(kCommandLineFilePath, &args); | 66 ParseArgsFromCommandLineFile(kCommandLineFilePath, &args); |
67 | 67 |
68 std::vector<char*> argv; | 68 std::vector<char*> argv; |
69 int argc = ArgsToArgv(args, &argv); | 69 int argc = ArgsToArgv(args, &argv); |
70 | 70 |
71 // Fully initialize command line with arguments. | 71 // Fully initialize command line with arguments. |
72 CommandLine::ForCurrentProcess()->AppendArguments( | 72 CommandLine::ForCurrentProcess()->AppendArguments( |
73 CommandLine(argc, &argv[0]), false); | 73 CommandLine(argc, &argv[0]), false); |
74 | 74 |
75 // Create fifo and redirect stdout and stderr to it. | 75 // Create fifo and redirect stdout and stderr to it. |
76 FilePath files_dir(base::android::ConvertJavaStringToUTF8(env, jfiles_dir)); | 76 base::FilePath files_dir( |
77 FilePath fifo_path(files_dir.Append(FilePath("test.fifo"))); | 77 base::android::ConvertJavaStringToUTF8(env, jfiles_dir)); |
| 78 base::FilePath fifo_path(files_dir.Append(base::FilePath("test.fifo"))); |
78 CreateFIFO(fifo_path.value().c_str()); | 79 CreateFIFO(fifo_path.value().c_str()); |
79 RedirectStream(stdout, fifo_path.value().c_str(), "w"); | 80 RedirectStream(stdout, fifo_path.value().c_str(), "w"); |
80 dup2(STDOUT_FILENO, STDERR_FILENO); | 81 dup2(STDOUT_FILENO, STDERR_FILENO); |
81 | 82 |
82 ScopedMainEntryLogger scoped_main_entry_logger; | 83 ScopedMainEntryLogger scoped_main_entry_logger; |
83 main(argc, &argv[0]); | 84 main(argc, &argv[0]); |
84 } | 85 } |
85 } // namespace content | 86 } // namespace content |
86 | 87 |
87 // This is called by the VM when the shared library is first loaded. | 88 // This is called by the VM when the shared library is first loaded. |
88 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { | 89 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { |
89 base::android::InitVM(vm); | 90 base::android::InitVM(vm); |
90 JNIEnv* env = base::android::AttachCurrentThread(); | 91 JNIEnv* env = base::android::AttachCurrentThread(); |
91 | 92 |
92 if (!content::RegisterLibraryLoaderEntryHook(env)) | 93 if (!content::RegisterLibraryLoaderEntryHook(env)) |
93 return -1; | 94 return -1; |
94 | 95 |
95 if (!content::android::RegisterShellJni(env)) | 96 if (!content::android::RegisterShellJni(env)) |
96 return -1; | 97 return -1; |
97 | 98 |
98 if (!content::BrowserTestMessagePumpAndroid::RegisterJni(env)) | 99 if (!content::BrowserTestMessagePumpAndroid::RegisterJni(env)) |
99 return -1; | 100 return -1; |
100 | 101 |
101 if (!content::RegisterNativesImpl(env)) | 102 if (!content::RegisterNativesImpl(env)) |
102 return -1; | 103 return -1; |
103 | 104 |
104 content::SetContentMainDelegate(new content::ShellMainDelegate()); | 105 content::SetContentMainDelegate(new content::ShellMainDelegate()); |
105 return JNI_VERSION_1_4; | 106 return JNI_VERSION_1_4; |
106 } | 107 } |
OLD | NEW |