diff options
author | peter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-19 12:01:42 +0000 |
---|---|---|
committer | peter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-19 12:01:42 +0000 |
commit | c48fece0c35a6bfdf73ee9ba6e6f18263d0748d8 (patch) | |
tree | 5f76db37d370bf3d07d8bd7ba548732c00adc769 /content/shell/shell_browser_main.cc | |
parent | 80b11694c00a7ed19e29b03cb00696f4e6b66752 (diff) | |
download | chromium_src-c48fece0c35a6bfdf73ee9ba6e6f18263d0748d8.zip chromium_src-c48fece0c35a6bfdf73ee9ba6e6f18263d0748d8.tar.gz chromium_src-c48fece0c35a6bfdf73ee9ba6e6f18263d0748d8.tar.bz2 |
content_shell: Move BrowserTestSystemMessageHandler and use it in layout tests
for Android
Android needs to use a nested message loop in order to execute the
layout tests. We have an implementation of this for content_browsertests
as BrowserTestSystemMessageHandler, but this lives in /content/test/
which content_shell cannot depend on.
Move it to /content/public/test/ as NestedSystemMessageHandler and
update content_browsertests to depend on that instead. For content_shell,
implement support of starting the nested loop, and use it when running
layout tests.
BUG=232044
Review URL: https://chromiumcodereview.appspot.com/17076008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207215 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell/shell_browser_main.cc')
-rw-r--r-- | content/shell/shell_browser_main.cc | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/content/shell/shell_browser_main.cc b/content/shell/shell_browser_main.cc index d2b43b5..b1f0e9f 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/nested_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::NestedMessagePumpAndroid(); +} + #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::NestedMessagePumpAndroid::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,15 @@ int ShellBrowserMain(const content::MainFunctionParams& parameters, } ran_at_least_once = true; +#if defined(OS_ANDROID) + // The message loop on Android is provided by the system, and does not + // offer a blocking Run() method. For layout tests, use a nested loop + // together with a base::RunLoop so it can block until a QuitClosure. + base::RunLoop run_loop; + run_loop.Run(); +#else main_runner->Run(); +#endif if (!content::WebKitTestController::Get()->ResetAfterLayoutTest()) break; |