| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/shell/browser/layout_test/layout_test_android.h" | 5 #include "content/shell/browser/layout_test/layout_test_android.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "base/android/context_utils.h" | 9 #include "base/android/context_utils.h" |
| 8 #include "base/android/fifo_utils.h" | 10 #include "base/android/fifo_utils.h" |
| 9 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
| 11 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 12 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 15 #include "content/public/test/nested_message_pump_android.h" | 16 #include "content/public/test/nested_message_pump_android.h" |
| 16 #include "content/shell/common/shell_switches.h" | 17 #include "content/shell/common/shell_switches.h" |
| 17 #include "jni/ShellLayoutTestUtils_jni.h" | 18 #include "jni/ShellLayoutTestUtils_jni.h" |
| 18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 base::FilePath GetTestFilesDirectory(JNIEnv* env) { | 23 base::FilePath GetTestFilesDirectory(JNIEnv* env) { |
| 23 ScopedJavaLocalRef<jstring> directory = | 24 ScopedJavaLocalRef<jstring> directory = |
| 24 content::Java_ShellLayoutTestUtils_getApplicationFilesDirectory( | 25 content::Java_ShellLayoutTestUtils_getApplicationFilesDirectory( |
| 25 env, base::android::GetApplicationContext()); | 26 env, base::android::GetApplicationContext()); |
| 26 return base::FilePath(ConvertJavaStringToUTF8(directory)); | 27 return base::FilePath(ConvertJavaStringToUTF8(directory)); |
| 27 } | 28 } |
| 28 | 29 |
| 29 void EnsureCreateFIFO(const base::FilePath& path) { | 30 void EnsureCreateFIFO(const base::FilePath& path) { |
| 30 unlink(path.value().c_str()); | 31 unlink(path.value().c_str()); |
| 31 CHECK(base::android::CreateFIFO(path, 0666)) | 32 CHECK(base::android::CreateFIFO(path, 0666)) |
| 32 << "Unable to create the Android's FIFO: " << path.value().c_str(); | 33 << "Unable to create the Android's FIFO: " << path.value().c_str(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 scoped_ptr<base::MessagePump> CreateMessagePumpForUI() { | 36 std::unique_ptr<base::MessagePump> CreateMessagePumpForUI() { |
| 36 return scoped_ptr<base::MessagePump>(new content::NestedMessagePumpAndroid()); | 37 return std::unique_ptr<base::MessagePump>( |
| 38 new content::NestedMessagePumpAndroid()); |
| 37 } | 39 } |
| 38 | 40 |
| 39 } // namespace | 41 } // namespace |
| 40 | 42 |
| 41 namespace content { | 43 namespace content { |
| 42 | 44 |
| 43 void EnsureInitializeForAndroidLayoutTests() { | 45 void EnsureInitializeForAndroidLayoutTests() { |
| 44 JNIEnv* env = base::android::AttachCurrentThread(); | 46 JNIEnv* env = base::android::AttachCurrentThread(); |
| 45 content::NestedMessagePumpAndroid::RegisterJni(env); | 47 content::NestedMessagePumpAndroid::RegisterJni(env); |
| 46 content::RegisterNativesImpl(env); | 48 content::RegisterNativesImpl(env); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 66 // Redirecting stdout needs to happen before redirecting stdin, which needs | 68 // Redirecting stdout needs to happen before redirecting stdin, which needs |
| 67 // to happen before redirecting stderr. | 69 // to happen before redirecting stderr. |
| 68 success = base::android::RedirectStream(stdout, stdout_fifo, "w") && | 70 success = base::android::RedirectStream(stdout, stdout_fifo, "w") && |
| 69 base::android::RedirectStream(stdin, stdin_fifo, "r") && | 71 base::android::RedirectStream(stdin, stdin_fifo, "r") && |
| 70 base::android::RedirectStream(stderr, stderr_fifo, "w"); | 72 base::android::RedirectStream(stderr, stderr_fifo, "w"); |
| 71 | 73 |
| 72 CHECK(success) << "Unable to initialize the Android FIFOs."; | 74 CHECK(success) << "Unable to initialize the Android FIFOs."; |
| 73 } | 75 } |
| 74 | 76 |
| 75 } // namespace content | 77 } // namespace content |
| OLD | NEW |