Commit 6e636a2e authored by danakj's avatar danakj Committed by Commit Bot

Remove Android specific code from the web_test harness.

See discussion thread:
https://groups.google.com/a/chromium.org/d/topic/blink-dev/338WKwWPbPI/discussion

Removes OS_ANDROID support for running web tests since we are no longer
running them on Android bots.

Depends on https://chromium-review.googlesource.com/c/chromium/src/+/1629049
which disabled the test suite on bots.

R=avi@chromium.org, dpranke@chromium.org

Bug: 567947
Change-Id: Ia0420056e3a7982b24c29f94945fb1034523d7af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1628956Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663781}
parent 87cc97e3
...@@ -404,10 +404,6 @@ jumbo_static_library("content_shell_lib") { ...@@ -404,10 +404,6 @@ jumbo_static_library("content_shell_lib") {
} }
if (is_android) { if (is_android) {
sources += [
"browser/web_test/scoped_android_configuration.cc",
"browser/web_test/scoped_android_configuration.h",
]
deps += [ deps += [
"//base/test:test_support", "//base/test:test_support",
"//components/embedder_support/android:view", "//components/embedder_support/android:view",
......
...@@ -85,10 +85,6 @@ ...@@ -85,10 +85,6 @@
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#endif #endif
#if defined(OS_ANDROID)
#include "ui/android/view_android.h"
#endif
namespace content { namespace content {
namespace { namespace {
...@@ -545,12 +541,6 @@ bool BlinkTestController::ResetAfterWebTest() { ...@@ -545,12 +541,6 @@ bool BlinkTestController::ResetAfterWebTest() {
composite_all_frames_node_storage_.clear(); composite_all_frames_node_storage_.clear();
weak_factory_.InvalidateWeakPtrs(); weak_factory_.InvalidateWeakPtrs();
#if defined(OS_ANDROID)
// Re-using the shell's main window on Android causes issues with networking
// requests never succeeding. See http://crbug.com/277652.
DiscardMainWindow();
#endif
return true; return true;
} }
...@@ -979,17 +969,6 @@ void BlinkTestController::HandleNewRenderFrameHost(RenderFrameHost* frame) { ...@@ -979,17 +969,6 @@ void BlinkTestController::HandleNewRenderFrameHost(RenderFrameHost* frame) {
!base::ContainsKey(main_window_render_process_hosts_, process_host)) { !base::ContainsKey(main_window_render_process_hosts_, process_host)) {
main_window_render_process_hosts_.insert(process_host); main_window_render_process_hosts_.insert(process_host);
#if defined(OS_ANDROID)
// On Android the native view doesn't automatically know its size. This
// causes problems with Viz, where the view/renderer synchronize sizes
// frequently. Make sure the view hosting the renderer has the same size
// that we're about to send.
main_window_->web_contents()->GetNativeView()->OnSizeChanged(
initial_size_.width(), initial_size_.height());
main_window_->web_contents()->GetNativeView()->OnPhysicalBackingSizeChanged(
initial_size_);
#endif
// Make sure the new renderer process_host has a test configuration shared // Make sure the new renderer process_host has a test configuration shared
// with other renderers. // with other renderers.
mojom::ShellTestConfigurationPtr params = mojom::ShellTestConfigurationPtr params =
......
...@@ -38,6 +38,8 @@ class DevToolsProtocolTestBindings : public WebContentsObserver, ...@@ -38,6 +38,8 @@ class DevToolsProtocolTestBindings : public WebContentsObserver,
scoped_refptr<DevToolsAgentHost> agent_host_; scoped_refptr<DevToolsAgentHost> agent_host_;
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
// DevToolsFrontendHost does not exist on Android, but we also don't run web
// tests natively on Android.
std::unique_ptr<DevToolsFrontendHost> frontend_host_; std::unique_ptr<DevToolsFrontendHost> frontend_host_;
#endif #endif
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/shell/browser/web_test/scoped_android_configuration.h"
#include <fcntl.h>
#include <iostream>
#include <memory>
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/post_task.h"
#include "base/test/android/url_utils.h"
#include "base/test/test_support_android.h"
#include "base/threading/thread_restrictions.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/shell/browser/web_test/blink_test_controller.h"
#include "content/shell/common/shell_switches.h"
#include "content/shell/common/web_test/web_test_switches.h"
#include "net/base/completion_once_callback.h"
#include "net/base/completion_repeating_callback.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/base/sockaddr_storage.h"
#include "net/socket/socket_posix.h"
#include "url/gurl.h"
using base::android::ScopedJavaLocalRef;
namespace content {
namespace {
void ConnectCompleted(base::OnceClosure socket_connected, int rv) {
LOG_IF(FATAL, net::OK != rv)
<< " Failed to redirect to socket: " << net::ErrorToString(rv);
std::move(socket_connected).Run();
}
void CreateAndConnectSocket(
uint16_t port,
base::OnceCallback<void(std::unique_ptr<net::SocketPosix>)>
socket_connected) {
net::SockaddrStorage storage;
net::IPAddress address;
LOG_IF(FATAL, !address.AssignFromIPLiteral("127.0.0.1"))
<< "Failed to create IPAddress from IP literal 127.0.0.1.";
net::IPEndPoint endpoint(address, port);
LOG_IF(FATAL, !endpoint.ToSockAddr(storage.addr, &storage.addr_len))
<< "Failed to convert " << endpoint.ToString() << " to sockaddr.";
std::unique_ptr<net::SocketPosix> socket(
std::make_unique<net::SocketPosix>());
int result = socket->Open(AF_INET);
LOG_IF(FATAL, net::OK != result)
<< "Failed to open socket for " << endpoint.ToString() << ": "
<< net::ErrorToString(result);
// Set the socket as blocking.
const int flags = fcntl(socket->socket_fd(), F_GETFL);
LOG_IF(FATAL, flags == -1);
if (flags & O_NONBLOCK) {
fcntl(socket->socket_fd(), F_SETFL, flags & ~O_NONBLOCK);
}
net::SocketPosix* socket_ptr = socket.get();
net::CompletionRepeatingCallback connect_completed =
base::AdaptCallbackForRepeating(base::BindOnce(
&ConnectCompleted,
base::BindOnce(std::move(socket_connected), std::move(socket))));
result = socket_ptr->Connect(storage, connect_completed);
if (result != net::ERR_IO_PENDING) {
connect_completed.Run(result);
}
}
void RedirectStdout(int fd) {
LOG_IF(FATAL, dup2(fd, STDOUT_FILENO) == -1)
<< "Failed to dup2 stdout: " << strerror(errno);
}
void RedirectStdin(int fd) {
LOG_IF(FATAL, dup2(fd, STDIN_FILENO) == -1)
<< "Failed to dup2 stdin: " << strerror(errno);
}
void RedirectStderr(int fd) {
LOG_IF(FATAL, dup2(fd, STDERR_FILENO) == -1)
<< "Failed to dup2 stderr: " << strerror(errno);
}
void FinishRedirection(
base::OnceCallback<void(int)> redirect,
base::OnceCallback<void(std::unique_ptr<net::SocketPosix>)> transfer_socket,
base::WaitableEvent* event,
std::unique_ptr<net::SocketPosix> socket) {
std::move(redirect).Run(socket->socket_fd());
std::move(transfer_socket).Run(std::move(socket));
event->Signal();
}
void RedirectStream(uint16_t port,
base::OnceCallback<void(base::WaitableEvent*,
std::unique_ptr<net::SocketPosix>)>
finish_redirection) {
base::WaitableEvent redirected(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(
&CreateAndConnectSocket, port,
base::BindOnce(std::move(finish_redirection), &redirected)));
base::ScopedAllowBaseSyncPrimitivesForTesting allow_wait;
while (!redirected.IsSignaled())
redirected.Wait();
}
} // namespace
ScopedAndroidConfiguration::ScopedAndroidConfiguration() : sockets_() {
base::InitAndroidTestPaths(base::android::GetIsolatedTestRoot());
}
ScopedAndroidConfiguration::~ScopedAndroidConfiguration() = default;
void ScopedAndroidConfiguration::RedirectStreams() {
std::string stdout_port_str =
base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
switches::kAndroidStdoutPort);
unsigned stdout_port = 0;
if (base::StringToUint(stdout_port_str, &stdout_port)) {
auto redirect_callback = base::BindOnce(&RedirectStdout);
// Unretained is safe here because all executions of transfer_callback
// finish before this function returns.
auto transfer_callback = base::BindOnce(
&ScopedAndroidConfiguration::AddSocket, base::Unretained(this));
RedirectStream(
base::checked_cast<uint16_t>(stdout_port),
base::BindOnce(&FinishRedirection, std::move(redirect_callback),
std::move(transfer_callback)));
}
std::string stdin_port_str =
base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
switches::kAndroidStdinPort);
unsigned stdin_port = 0;
if (base::StringToUint(stdin_port_str, &stdin_port)) {
auto redirect_callback = base::BindOnce(&RedirectStdin);
// Unretained is safe here because all executions of transfer_callback
// finish before this function returns.
auto transfer_callback = base::BindOnce(
&ScopedAndroidConfiguration::AddSocket, base::Unretained(this));
RedirectStream(
base::checked_cast<uint16_t>(stdin_port),
base::BindOnce(&FinishRedirection, std::move(redirect_callback),
std::move(transfer_callback)));
}
std::string stderr_port_str =
base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
switches::kAndroidStderrPort);
unsigned stderr_port = 0;
if (base::StringToUint(stderr_port_str, &stderr_port)) {
auto redirect_callback = base::BindOnce(&RedirectStderr);
// Unretained is safe here because all executions of transfer_callback
// finish before this function returns.
auto transfer_callback = base::BindOnce(
&ScopedAndroidConfiguration::AddSocket, base::Unretained(this));
RedirectStream(
base::checked_cast<uint16_t>(stderr_port),
base::BindOnce(&FinishRedirection, std::move(redirect_callback),
std::move(transfer_callback)));
}
}
void ScopedAndroidConfiguration::AddSocket(
std::unique_ptr<net::SocketPosix> socket) {
sockets_.push_back(std::move(socket));
}
} // namespace content
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_SHELL_BROWSER_WEB_TEST_SCOPED_ANDROID_CONFIGURATION_H_
#define CONTENT_SHELL_BROWSER_WEB_TEST_SCOPED_ANDROID_CONFIGURATION_H_
#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
namespace net {
class SocketPosix;
}
namespace content {
class ScopedAndroidConfiguration {
public:
ScopedAndroidConfiguration();
~ScopedAndroidConfiguration();
// Redirects stdin, stdout, and stderr to the ports specified on the command
// line.
void RedirectStreams();
private:
// Adds |socket| to |sockets_|.
void AddSocket(std::unique_ptr<net::SocketPosix> socket);
// The sockets to which the IO streams are being redirected.
std::vector<std::unique_ptr<net::SocketPosix>> sockets_;
DISALLOW_COPY_AND_ASSIGN(ScopedAndroidConfiguration);
};
} // namespace content
#endif // CONTENT_SHELL_BROWSER_WEB_TEST_SCOPED_ANDROID_CONFIGURATION_H_
...@@ -33,11 +33,6 @@ ...@@ -33,11 +33,6 @@
#include "gpu/config/gpu_switches.h" #include "gpu/config/gpu_switches.h"
#include "net/base/filename_util.h" #include "net/base/filename_util.h"
#if defined(OS_ANDROID)
#include "base/run_loop.h"
#include "content/shell/browser/web_test/scoped_android_configuration.h"
#endif
namespace { namespace {
bool RunOneTest(const content::TestInfo& test_info, bool RunOneTest(const content::TestInfo& test_info,
...@@ -48,26 +43,9 @@ bool RunOneTest(const content::TestInfo& test_info, ...@@ -48,26 +43,9 @@ bool RunOneTest(const content::TestInfo& test_info,
if (!blink_test_controller->PrepareForWebTest(test_info)) if (!blink_test_controller->PrepareForWebTest(test_info))
return false; return false;
#if defined(OS_ANDROID)
// The message loop on Android is provided by the system, and does not
// offer a blocking Run() method. For web tests, use a nested loop
// together with a base::RunLoop so it can block until a QuitClosure.
base::RunLoop run_loop;
content::Shell::SetMainMessageLoopQuitClosure(run_loop.QuitClosure());
run_loop.Run();
#else
main_runner->Run(); main_runner->Run();
#endif
if (!blink_test_controller->ResetAfterWebTest()) return blink_test_controller->ResetAfterWebTest();
return false;
#if defined(OS_ANDROID)
// There will be left-over tasks in the queue for Android because the
// main window is being destroyed. Run them before starting the next test.
base::RunLoop().RunUntilIdle();
#endif
return true;
} }
void RunTests(content::BrowserMainRunner* main_runner) { void RunTests(content::BrowserMainRunner* main_runner) {
...@@ -98,13 +76,6 @@ void RunTests(content::BrowserMainRunner* main_runner) { ...@@ -98,13 +76,6 @@ void RunTests(content::BrowserMainRunner* main_runner) {
FROM_HERE, base::BindOnce(&content::Shell::CloseAllWindows)); FROM_HERE, base::BindOnce(&content::Shell::CloseAllWindows));
main_runner->Run(); main_runner->Run();
} }
#if defined(OS_ANDROID)
// We need to execute 'main_runner->Shutdown()' before the test_controller
// destructs when running on Android, and after it destructs when running
// anywhere else.
main_runner->Shutdown();
#endif
} }
} // namespace } // namespace
...@@ -130,27 +101,14 @@ void WebTestBrowserMain(const content::MainFunctionParams& parameters) { ...@@ -130,27 +101,14 @@ void WebTestBrowserMain(const content::MainFunctionParams& parameters) {
base::CommandLine::ForCurrentProcess()->AppendSwitch( base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kDisableGpuProcessForDX12VulkanInfoCollection); switches::kDisableGpuProcessForDX12VulkanInfoCollection);
#if defined(OS_ANDROID)
content::ScopedAndroidConfiguration android_configuration;
#endif
int initialize_exit_code = main_runner->Initialize(parameters); int initialize_exit_code = main_runner->Initialize(parameters);
DCHECK_LT(initialize_exit_code, 0) DCHECK_LT(initialize_exit_code, 0)
<< "BrowserMainRunner::Initialize failed in WebTestBrowserMain"; << "BrowserMainRunner::Initialize failed in WebTestBrowserMain";
#if defined(OS_ANDROID)
main_runner->SynchronouslyFlushStartupTasks();
android_configuration.RedirectStreams();
#endif
RunTests(main_runner.get()); RunTests(main_runner.get());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
content::Shell::CloseAllWindows(); content::Shell::CloseAllWindows();
#if !defined(OS_ANDROID)
// This Shutdown() is done earlier on Android. Generally BrowserMainRunner
// shutdown does not work on Android but it does for the WebTest harness.
main_runner->Shutdown(); main_runner->Shutdown();
#endif
} }
...@@ -34,11 +34,6 @@ ...@@ -34,11 +34,6 @@
#include "content/shell/browser/shell_plugin_service_filter.h" #include "content/shell/browser/shell_plugin_service_filter.h"
#endif #endif
#if defined(OS_ANDROID)
#include "net/android/network_change_notifier_factory_android.h"
#include "net/base/network_change_notifier.h"
#endif
#if defined(USE_AURA) && defined(USE_X11) #if defined(USE_AURA) && defined(USE_X11)
#include "ui/events/devices/x11/touch_factory_x11.h" // nogncheck #include "ui/events/devices/x11/touch_factory_x11.h" // nogncheck
#endif #endif
......
...@@ -9,17 +9,6 @@ namespace switches { ...@@ -9,17 +9,6 @@ namespace switches {
// Allow access to external pages during web tests. // Allow access to external pages during web tests.
const char kAllowExternalPages[] = "allow-external-pages"; const char kAllowExternalPages[] = "allow-external-pages";
#if defined(OS_ANDROID)
// Redirect stderr to the given port. Only supported on Android.
const char kAndroidStderrPort[] = "android-stderr-port";
// Redirect stdin to the given port. Only supported on Android.
const char kAndroidStdinPort[] = "android-stdin-port";
// Redirect stdout to the given port. Only supported on Android.
const char kAndroidStdoutPort[] = "android-stdout-port";
#endif // defined(OS_ANDROID)
// When specified to "enable-leak-detection" command-line option, // When specified to "enable-leak-detection" command-line option,
// causes the leak detector to cause immediate crash when found leak. // causes the leak detector to cause immediate crash when found leak.
const char kCrashOnFailure[] = "crash-on-failure"; const char kCrashOnFailure[] = "crash-on-failure";
......
...@@ -15,11 +15,6 @@ ...@@ -15,11 +15,6 @@
namespace switches { namespace switches {
extern const char kAllowExternalPages[]; extern const char kAllowExternalPages[];
#if defined(OS_ANDROID)
extern const char kAndroidStderrPort[];
extern const char kAndroidStdinPort[];
extern const char kAndroidStdoutPort[];
#endif // defined(OS_ANDROID)
extern const char kCrashOnFailure[]; extern const char kCrashOnFailure[];
extern const char kCustomDevToolsFrontend[]; extern const char kCustomDevToolsFrontend[];
extern const char kDebugDevTools[]; extern const char kDebugDevTools[];
......
...@@ -144,9 +144,6 @@ void ApplyWebTestDefaultPreferences(WebPreferences* prefs) { ...@@ -144,9 +144,6 @@ void ApplyWebTestDefaultPreferences(WebPreferences* prefs) {
prefs->mock_scrollbars_enabled = false; prefs->mock_scrollbars_enabled = false;
prefs->smart_insert_delete_enabled = true; prefs->smart_insert_delete_enabled = true;
prefs->minimum_accelerated_2d_canvas_size = 0; prefs->minimum_accelerated_2d_canvas_size = 0;
#if defined(OS_ANDROID)
prefs->text_autosizing_enabled = false;
#endif
prefs->viewport_enabled = command_line.HasSwitch(switches::kEnableViewport); prefs->viewport_enabled = command_line.HasSwitch(switches::kEnableViewport);
prefs->default_minimum_page_scale_factor = 1.f; prefs->default_minimum_page_scale_factor = 1.f;
prefs->default_maximum_page_scale_factor = 4.f; prefs->default_maximum_page_scale_factor = 4.f;
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_FUCHSIA) #if defined(OS_LINUX) || defined(OS_FUCHSIA)
#include "third_party/blink/public/platform/web_font_render_style.h" #include "third_party/blink/public/platform/web_font_render_style.h"
#endif #endif
...@@ -1538,7 +1538,7 @@ void TestRunner::Reset() { ...@@ -1538,7 +1538,7 @@ void TestRunner::Reset() {
drag_image_.reset(); drag_image_.reset();
blink::WebSecurityPolicy::ClearOriginAccessList(); blink::WebSecurityPolicy::ClearOriginAccessList();
#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_FUCHSIA) #if defined(OS_LINUX) || defined(OS_FUCHSIA)
blink::WebFontRenderStyle::SetSubpixelPositioning(false); blink::WebFontRenderStyle::SetSubpixelPositioning(false);
#endif #endif
...@@ -2065,7 +2065,7 @@ void TestRunner::AddOriginAccessAllowListEntry( ...@@ -2065,7 +2065,7 @@ void TestRunner::AddOriginAccessAllowListEntry(
} }
void TestRunner::SetTextSubpixelPositioning(bool value) { void TestRunner::SetTextSubpixelPositioning(bool value) {
#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_FUCHSIA) #if defined(OS_LINUX) || defined(OS_FUCHSIA)
// Since FontConfig doesn't provide a variable to control subpixel // Since FontConfig doesn't provide a variable to control subpixel
// positioning, we'll fall back to setting it globally for all fonts. // positioning, we'll fall back to setting it globally for all fonts.
blink::WebFontRenderStyle::SetSubpixelPositioning(value); blink::WebFontRenderStyle::SetSubpixelPositioning(value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment