| 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> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/android/context_utils.h" | 9 #include "base/android/context_utils.h" |
| 10 #include "base/android/fifo_utils.h" | 10 #include "base/android/fifo_utils.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 return std::unique_ptr<base::MessagePump>( | 37 return std::unique_ptr<base::MessagePump>( |
| 38 new content::NestedMessagePumpAndroid()); | 38 new content::NestedMessagePumpAndroid()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 namespace content { | 43 namespace content { |
| 44 | 44 |
| 45 void EnsureInitializeForAndroidLayoutTests() { | 45 void EnsureInitializeForAndroidLayoutTests() { |
| 46 JNIEnv* env = base::android::AttachCurrentThread(); | 46 JNIEnv* env = base::android::AttachCurrentThread(); |
| 47 content::NestedMessagePumpAndroid::RegisterJni(env); | |
| 48 content::RegisterNativesImpl(env); | |
| 49 | 47 |
| 50 bool success = base::MessageLoop::InitMessagePumpForUIFactory( | 48 bool success = base::MessageLoop::InitMessagePumpForUIFactory( |
| 51 &CreateMessagePumpForUI); | 49 &CreateMessagePumpForUI); |
| 52 CHECK(success) << "Unable to initialize the message pump for Android."; | 50 CHECK(success) << "Unable to initialize the message pump for Android."; |
| 53 | 51 |
| 54 // Android will need three FIFOs to communicate with the Blink test runner, | 52 // Android will need three FIFOs to communicate with the Blink test runner, |
| 55 // one for each of [stdout, stderr, stdin]. | 53 // one for each of [stdout, stderr, stdin]. |
| 56 base::FilePath files_dir(GetTestFilesDirectory(env)); | 54 base::FilePath files_dir(GetTestFilesDirectory(env)); |
| 57 | 55 |
| 58 base::FilePath stdout_fifo(files_dir.Append(FILE_PATH_LITERAL("test.fifo"))); | 56 base::FilePath stdout_fifo(files_dir.Append(FILE_PATH_LITERAL("test.fifo"))); |
| 59 EnsureCreateFIFO(stdout_fifo); | 57 EnsureCreateFIFO(stdout_fifo); |
| 60 | 58 |
| 61 base::FilePath stderr_fifo( | 59 base::FilePath stderr_fifo( |
| 62 files_dir.Append(FILE_PATH_LITERAL("stderr.fifo"))); | 60 files_dir.Append(FILE_PATH_LITERAL("stderr.fifo"))); |
| 63 EnsureCreateFIFO(stderr_fifo); | 61 EnsureCreateFIFO(stderr_fifo); |
| 64 | 62 |
| 65 base::FilePath stdin_fifo(files_dir.Append(FILE_PATH_LITERAL("stdin.fifo"))); | 63 base::FilePath stdin_fifo(files_dir.Append(FILE_PATH_LITERAL("stdin.fifo"))); |
| 66 EnsureCreateFIFO(stdin_fifo); | 64 EnsureCreateFIFO(stdin_fifo); |
| 67 | 65 |
| 68 // Redirecting stdout needs to happen before redirecting stdin, which needs | 66 // Redirecting stdout needs to happen before redirecting stdin, which needs |
| 69 // to happen before redirecting stderr. | 67 // to happen before redirecting stderr. |
| 70 success = base::android::RedirectStream(stdout, stdout_fifo, "w") && | 68 success = base::android::RedirectStream(stdout, stdout_fifo, "w") && |
| 71 base::android::RedirectStream(stdin, stdin_fifo, "r") && | 69 base::android::RedirectStream(stdin, stdin_fifo, "r") && |
| 72 base::android::RedirectStream(stderr, stderr_fifo, "w"); | 70 base::android::RedirectStream(stderr, stderr_fifo, "w"); |
| 73 | 71 |
| 74 CHECK(success) << "Unable to initialize the Android FIFOs."; | 72 CHECK(success) << "Unable to initialize the Android FIFOs."; |
| 75 } | 73 } |
| 76 | 74 |
| 77 } // namespace content | 75 } // namespace content |
| OLD | NEW |