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

Unified Diff: content/shell/shell_browser_main.cc

Issue 17076008: content_shell: Move BrowserTestSystemMessageHandler and use it in layout tests for Android (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
Index: content/shell/shell_browser_main.cc
diff --git a/content/shell/shell_browser_main.cc b/content/shell/shell_browser_main.cc
index d2b43b54a840a4db239e241edec3d4ddb6c4aa1c..27936f6780bd0d6c99cb216fc735beaadc67225c 100644
--- a/content/shell/shell_browser_main.cc
+++ b/content/shell/shell_browser_main.cc
@@ -24,6 +24,12 @@
#include "net/base/net_util.h"
#include "webkit/support/webkit_support.h"
+#if defined(OS_ANDROID)
+#include "base/android/jni_android.h"
+#include "base/run_loop.h"
+#include "content/public/test/browser_test_message_pump_android.h"
+#endif
+
namespace {
#if defined(OS_ANDROID)
@@ -33,6 +39,11 @@ 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/";
+
+base::MessagePump* CreateMessagePumpForUI() {
+ return new content::BrowserTestMessagePumpAndroid();
+}
+
#endif
GURL GetURLForLayoutTest(const std::string& test_name,
@@ -125,14 +136,23 @@ int ShellBrowserMain(const content::MainFunctionParams& parameters,
CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree);
base::ScopedTempDir browser_context_path_for_layout_tests;
- // TODO(beverloo): Create the FIFOs required for Android layout tests.
-
if (layout_test_mode) {
CHECK(browser_context_path_for_layout_tests.CreateUniqueTempDir());
CHECK(!browser_context_path_for_layout_tests.path().MaybeAsASCII().empty());
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kContentShellDataPath,
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::BrowserTestMessagePumpAndroid::RegisterJni(env);
+
+ const bool success = base::MessageLoop::InitMessagePumpForUIFactory(
+ &CreateMessagePumpForUI);
+ CHECK(success) << "Unable to initialize the message pump for Android.";
+#endif
}
int exit_code = main_runner->Initialize(parameters);
@@ -189,7 +209,14 @@ int ShellBrowserMain(const content::MainFunctionParams& parameters,
}
ran_at_least_once = true;
+#if defined(OS_ANDROID)
+ // Android never invokes BrowserMainRunner::Run(). Instead, use a bare
+ // base::RunLoop which is closer to what's being used.
bulach 2013/06/17 17:41:22 I guess this deserves a slightly more detailed exp
Peter Beverloo 2013/06/17 18:41:56 I clarified the comment. I also agree that this c
+ base::RunLoop run_loop;
+ run_loop.Run();
+#else
main_runner->Run();
+#endif
if (!content::WebKitTestController::Get()->ResetAfterLayoutTest())
break;

Powered by Google App Engine
This is Rietveld 408576698