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

Unified Diff: content/shell/shell_browser_main.cc

Issue 17265005: content_shell: Create the FIFOs needed for running Android layout tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/shell_browser_main.cc
diff --git a/content/shell/shell_browser_main.cc b/content/shell/shell_browser_main.cc
index b1f0e9f6f1d10a160b0c02acaa33b5252b151f70..1fb18e6bb3fa700d907c8d1e806a169e77f098b0 100644
--- a/content/shell/shell_browser_main.cc
+++ b/content/shell/shell_browser_main.cc
@@ -25,6 +25,7 @@
#include "webkit/support/webkit_support.h"
#if defined(OS_ANDROID)
+#include "base/android/fifo_utils.h"
#include "base/android/jni_android.h"
#include "base/run_loop.h"
#include "content/public/test/nested_message_pump_android.h"
@@ -33,6 +34,11 @@
namespace {
#if defined(OS_ANDROID)
+// Directory on the device where the FIFOs will be created. The value of this
+// constant must by synchronized with that in the chromium_android.py file.
+const char kAndroidFifoPath[] =
bulach 2013/06/19 14:42:14 see below, looks like we can gather this from java
jochen (gone - plz use gerrit) 2013/06/19 15:37:13 and it should be FILE_PATH_LITERAL(), no? also kAn
Peter Beverloo 2013/06/19 17:40:28 Done.
+ "/data/data/org.chromium.content_shell_apk/files/";
+
// Path to search for when translating a layout test path to an URL.
const char kAndroidLayoutTestPath[] =
"/data/local/tmp/third_party/WebKit/LayoutTests/";
@@ -40,6 +46,32 @@ const char kAndroidLayoutTestPath[] =
// The base URL from which layout tests are being served on Android.
const char kAndroidLayoutTestBase[] = "http://127.0.0.1:8000/all-tests/";
+void EnsureCreateFIFO(const base::FilePath& path) {
+ unlink(path.value().c_str());
+ CHECK(base::android::CreateFIFO(path, 0666))
+ << "Unable to create one of Android's FIFOs: " << path.value().c_str();
+}
+
+bool CreateAndroidFIFOs() {
+ // Android will need three FIFOs to communicate with the Blink test runner,
+ // one for each of [stdout, stderr, stdin]. Redirecting stdout needs to happen
+ // before redirecting stdin, which needs to happen before redirecting stderr.
+ base::FilePath files_dir(kAndroidFifoPath);
+
+ base::FilePath stdout_fifo(files_dir.Append(base::FilePath("test.fifo")));
jochen (gone - plz use gerrit) 2013/06/19 15:37:13 also FILE_PATH_LITERAL() instead of full filepath
Peter Beverloo 2013/06/19 17:40:28 Done.
+ EnsureCreateFIFO(stdout_fifo);
+
+ base::FilePath stderr_fifo(files_dir.Append(base::FilePath("stderr.fifo")));
+ EnsureCreateFIFO(stderr_fifo);
+
+ base::FilePath stdin_fifo(files_dir.Append(base::FilePath("stdin.fifo")));
+ EnsureCreateFIFO(stdin_fifo);
+
+ return base::android::RedirectStream(stdout, stdout_fifo, "w") &&
+ base::android::RedirectStream(stdin, stdin_fifo, "r") &&
+ base::android::RedirectStream(stderr, stderr_fifo, "w");
+}
+
base::MessagePump* CreateMessagePumpForUI() {
return new content::NestedMessagePumpAndroid();
}
bulach 2013/06/19 14:42:14 how about moving this entire block to a shell_layo
Peter Beverloo 2013/06/19 17:40:28 Done.
@@ -144,14 +176,14 @@ int ShellBrowserMain(const content::MainFunctionParams& parameters,
browser_context_path_for_layout_tests.path().MaybeAsASCII());
#if defined(OS_ANDROID)
- // TODO(beverloo): Create the FIFOs required for Android layout tests.
-
JNIEnv* env = base::android::AttachCurrentThread();
content::NestedMessagePumpAndroid::RegisterJni(env);
const bool success = base::MessageLoop::InitMessagePumpForUIFactory(
&CreateMessagePumpForUI);
CHECK(success) << "Unable to initialize the message pump for Android.";
+
+ CHECK(CreateAndroidFIFOs()) << "Unable to initialize the Android FIFOs.";
bulach 2013/06/19 14:42:14 since this one has JNI available, you can add a @C
Peter Beverloo 2013/06/19 17:40:28 Done.
#endif
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698