Commit def62d54 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Copy fonts from the host for layout tests

Now layout tests runner copies fonts from the host to the target
machine. This is the same approach that is used for Android. It will
allow to reuse layout tests expectations from Linux/Android.

Bug: 778467
Change-Id: Id878966c435476b8fb22441441108a74c9e40f1b
Reviewed-on: https://chromium-review.googlesource.com/887745
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarBrian Salomon <bsalomon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534133}
parent 801862cf
...@@ -63,14 +63,14 @@ def RunPipedSsh(config_path, host, port, command, **kwargs): ...@@ -63,14 +63,14 @@ def RunPipedSsh(config_path, host, port, command, **kwargs):
return subprocess.Popen(ssh_command, **kwargs) return subprocess.Popen(ssh_command, **kwargs)
def RunScp(config_path, host, port, source, dest, direction): def RunScp(config_path, host, port, sources, dest, direction):
"""Copies a file to or from a remote host using SCP and blocks until """Copies a file to or from a remote host using SCP and blocks until
completion. completion.
config_path: Full path to SSH configuration. config_path: Full path to SSH configuration.
host: The hostname or IP address of the remote host. host: The hostname or IP address of the remote host.
port: The port to connect to. port: The port to connect to.
source: The path of the file to be copied. sources: Paths of the files to be copied.
dest: The path that |source| will be copied to. dest: The path that |source| will be copied to.
direction: Indicates whether the file should be copied to direction: Indicates whether the file should be copied to
or from the remote side. or from the remote side.
...@@ -88,8 +88,11 @@ def RunScp(config_path, host, port, source, dest, direction): ...@@ -88,8 +88,11 @@ def RunScp(config_path, host, port, source, dest, direction):
if direction == COPY_TO_TARGET: if direction == COPY_TO_TARGET:
dest = "%s:%s" % (host, dest) dest = "%s:%s" % (host, dest)
else: else:
source = "%s:%s" % (host, source) sources = sources.map(lambda source : "%s:%s" % (host, source))
scp_command += ['-F', config_path, '-P', str(port), source, dest]
scp_command += ['-F', config_path, '-P', str(port)]
scp_command += sources
scp_command += [dest]
logging.debug(' '.join(scp_command)) logging.debug(' '.join(scp_command))
subprocess.check_call(scp_command, stdout=open(os.devnull, 'w')) subprocess.check_call(scp_command, stdout=open(os.devnull, 'w'))
...@@ -81,22 +81,41 @@ class Target(object): ...@@ -81,22 +81,41 @@ class Target(object):
source: The path of the file being copied. source: The path of the file being copied.
dest: The path on the remote filesystem which will be copied to.""" dest: The path on the remote filesystem which will be copied to."""
assert type(source) is str
self.PutFiles([source], dest)
def PutFiles(self, sources, dest):
"""Copies files from the local filesystem to the target filesystem.
sources: List of local file paths to copy from, or a single path.
dest: The path on the remote filesystem which will be copied to."""
assert type(sources) is tuple or type(sources) is list
self._AssertIsStarted() self._AssertIsStarted()
host, port = self._GetEndpoint() host, port = self._GetEndpoint()
logging.debug('copy local:%s => remote:%s' % (source, dest)) logging.debug('copy local:%s => remote:%s' % (sources, dest))
command = remote_cmd.RunScp(self._GetSshConfigPath(), host, port, command = remote_cmd.RunScp(self._GetSshConfigPath(), host, port,
source, dest, remote_cmd.COPY_TO_TARGET) sources, dest, remote_cmd.COPY_TO_TARGET)
def GetFile(self, source, dest): def GetFile(self, source, dest):
"""Copies a file from the target filesystem to the local filesystem. """Copies a file from the target filesystem to the local filesystem.
source: The path of the file being copied. source: The path of the file being copied.
dest: The path on the local filesystem which will be copied to.""" dest: The path on the local filesystem which will be copied to."""
assert type(source) is str
self.GetFiles([source], dest)
def GetFiles(self, sources, dest):
"""Copies files from the target filesystem to the local filesystem.
sources: List of remote file paths to copy.
dest: The path on the local filesystem which will be copied to."""
assert type(sources) is tuple or type(sources) is list
self._AssertIsStarted() self._AssertIsStarted()
host, port = self._GetEndpoint() host, port = self._GetEndpoint()
logging.debug('copy remote:%s => local:%s' % (source, dest)) logging.debug('copy remote:%s => local:%s' % (sources, dest))
return remote_cmd.RunScp(self._GetSshConfigPath(), host, port, return remote_cmd.RunScp(self._GetSshConfigPath(), host, port,
source, dest, remote_cmd.COPY_FROM_TARGET) sources, dest, remote_cmd.COPY_FROM_TARGET)
def _GetEndpoint(self): def _GetEndpoint(self):
"""Returns a (host, port) tuple for the SSH connection to the target.""" """Returns a (host, port) tuple for the SSH connection to the target."""
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
#include "content/shell/app/blink_test_platform_support.h" #include "content/shell/app/blink_test_platform_support.h"
#include "skia/ext/fontmgr_default_android.h"
#include "third_party/skia/include/ports/SkFontMgr.h"
#include "third_party/skia/include/ports/SkFontMgr_android.h"
namespace content { namespace content {
bool CheckLayoutSystemDeps() { bool CheckLayoutSystemDeps() {
...@@ -11,6 +15,16 @@ bool CheckLayoutSystemDeps() { ...@@ -11,6 +15,16 @@ bool CheckLayoutSystemDeps() {
} }
bool BlinkTestPlatformInitialize() { bool BlinkTestPlatformInitialize() {
// Initialize Skia with the font configuration files crafted for layout tests.
SkFontMgr_Android_CustomFonts custom;
custom.fSystemFontUse = SkFontMgr_Android_CustomFonts::kOnlyCustom;
custom.fBasePath = "/system/fonts/";
custom.fFontsXml = "/system/fonts/fonts.xml";
custom.fFallbackFontsXml = "/system/fonts/fonts_fallback.xml";
custom.fIsolated = false;
SetDefaultSkiaFactory(SkFontMgr_New_Android(&custom));
return true; return true;
} }
......
...@@ -422,7 +422,7 @@ component("skia") { ...@@ -422,7 +422,7 @@ component("skia") {
] ]
} }
if (is_linux || is_android) { if (is_linux || is_android || is_fuchsia) {
sources += [ sources += [
# Retain the files for the SkFontMgr_Android on linux to emulate android # Retain the files for the SkFontMgr_Android on linux to emulate android
# fonts. See content/zygote/zygote_main_linux.cc # fonts. See content/zygote/zygote_main_linux.cc
...@@ -444,7 +444,7 @@ component("skia") { ...@@ -444,7 +444,7 @@ component("skia") {
sources += [ sources += [
"//third_party/skia/src/ports/SkFontMgr_custom.cpp", "//third_party/skia/src/ports/SkFontMgr_custom.cpp",
"//third_party/skia/src/ports/SkFontMgr_custom_empty.cpp", "//third_party/skia/src/ports/SkFontMgr_custom_empty.cpp",
"//third_party/skia/src/ports/SkFontMgr_custom_empty_factory.cpp", "ext/fontmgr_default_fuchsia.cc",
] ]
} }
...@@ -533,6 +533,10 @@ component("skia") { ...@@ -533,6 +533,10 @@ component("skia") {
sources += [ "//third_party/skia/src/utils/mac/SkCreateCGImageRef.cpp" ] sources += [ "//third_party/skia/src/utils/mac/SkCreateCGImageRef.cpp" ]
set_sources_assignment_filter(sources_assignment_filter) set_sources_assignment_filter(sources_assignment_filter)
} }
if (is_fuchsia) {
deps += [ "//third_party/expat" ]
}
} }
# Separated out so it can be compiled with different flags for SSE. # Separated out so it can be compiled with different flags for SSE.
......
// Copyright 2018 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 "skia/ext/fontmgr_default_fuchsia.h"
#include "third_party/skia/include/ports/SkFontConfigInterface.h"
#include "third_party/skia/include/ports/SkFontMgr.h"
#include "third_party/skia/include/ports/SkFontMgr_empty.h"
namespace {
// This is a purposefully leaky pointer that has ownership of the FontMgr.
SkFontMgr* g_default_fontmgr;
} // namespace
void SetDefaultSkiaFactory(sk_sp<SkFontMgr> fontmgr) {
SkASSERT(g_default_fontmgr == nullptr);
g_default_fontmgr = fontmgr.release();
}
SK_API sk_sp<SkFontMgr> SkFontMgr::Factory() {
if (g_default_fontmgr) {
return sk_ref_sp(g_default_fontmgr);
}
return SkFontMgr_New_Custom_Empty();
}
// Copyright 2018 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 SKIA_EXT_FONTMGR_DEFAULT_FUCHSIA_H_
#define SKIA_EXT_FONTMGR_DEFAULT_FUCHSIA_H_
#include "third_party/skia/include/core/SkTypes.h"
class SkFontMgr;
template <typename T>
class sk_sp;
void SK_API SetDefaultSkiaFactory(sk_sp<SkFontMgr> fontmgr);
#endif // SKIA_EXT_FONTMGR_DEFAULT_FUCHSIA_H_
...@@ -121,55 +121,9 @@ LAYOUT_TEST_PATH_PREFIX = '/all-tests' ...@@ -121,55 +121,9 @@ LAYOUT_TEST_PATH_PREFIX = '/all-tests'
# completely arbitrary. # completely arbitrary.
FIRST_NETCAT_PORT = 10201 FIRST_NETCAT_PORT = 10201
MS_TRUETYPE_FONTS_DIR = '/usr/share/fonts/truetype/msttcorefonts/'
MS_TRUETYPE_FONTS_PACKAGE = 'ttf-mscorefonts-installer'
# Timeout in seconds to wait for starting/stopping the driver. # Timeout in seconds to wait for starting/stopping the driver.
DRIVER_START_STOP_TIMEOUT_SECS = 10 DRIVER_START_STOP_TIMEOUT_SECS = 10
HOST_FONT_FILES = [
[[MS_TRUETYPE_FONTS_DIR], 'Arial.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Arial_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Arial_Bold_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Arial_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Comic_Sans_MS.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Comic_Sans_MS_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Courier_New.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Courier_New_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Courier_New_Bold_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Courier_New_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Georgia.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Georgia_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Georgia_Bold_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Georgia_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Impact.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Trebuchet_MS.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Trebuchet_MS_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Trebuchet_MS_Bold_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Trebuchet_MS_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Times_New_Roman.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Times_New_Roman_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Times_New_Roman_Bold_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Times_New_Roman_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Verdana.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Verdana_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Verdana_Bold_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Verdana_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
# The Microsoft font EULA
[['/usr/share/doc/ttf-mscorefonts-installer/'], 'READ_ME!.gz', MS_TRUETYPE_FONTS_PACKAGE],
# Other fonts: Arabic, CJK, Indic, Thai, etc.
[['/usr/share/fonts/truetype/ttf-dejavu/'], 'DejaVuSans.ttf', 'ttf-dejavu'],
[['/usr/share/fonts/truetype/kochi/'], 'kochi-mincho.ttf', 'ttf-kochi-mincho'],
[['/usr/share/fonts/truetype/ttf-indic-fonts-core/'], 'lohit_hi.ttf', 'ttf-indic-fonts-core'],
[['/usr/share/fonts/truetype/ttf-indic-fonts-core/'], 'lohit_ta.ttf', 'ttf-indic-fonts-core'],
[['/usr/share/fonts/truetype/ttf-indic-fonts-core/'], 'MuktiNarrow.ttf', 'ttf-indic-fonts-core'],
[['/usr/share/fonts/truetype/thai/', '/usr/share/fonts/truetype/tlwg/'], 'Garuda.ttf', 'fonts-tlwg-garuda'],
[['/usr/share/fonts/truetype/ttf-indic-fonts-core/',
'/usr/share/fonts/truetype/ttf-punjabi-fonts/'],
'lohit_pa.ttf',
'ttf-indic-fonts-core'],
]
# Test resources that need to be accessed as files directly. # Test resources that need to be accessed as files directly.
# Each item can be the relative path of a directory or a file. # Each item can be the relative path of a directory or a file.
TEST_RESOURCES_TO_PUSH = [ TEST_RESOURCES_TO_PUSH = [
...@@ -433,22 +387,17 @@ class AndroidPort(base.Port): ...@@ -433,22 +387,17 @@ class AndroidPort(base.Port):
host_device_tuples = [] host_device_tuples = []
# - the custom font files # - the custom font files
# TODO(sergeyu): Rename these files, they can be used on platforms
# other than Android.
host_device_tuples.append( host_device_tuples.append(
(self._build_path('android_main_fonts.xml'), (self._build_path('android_main_fonts.xml'),
device_path('android_main_fonts.xml'))) device_path('android_main_fonts.xml')))
host_device_tuples.append( host_device_tuples.append(
(self._build_path('android_fallback_fonts.xml'), (self._build_path('android_fallback_fonts.xml'),
device_path('android_fallback_fonts.xml'))) device_path('android_fallback_fonts.xml')))
host_device_tuples.append( for font_file in self._get_font_files():
(self._build_path('AHEM____.TTF'), host_device_tuples.append(
device_path('fonts', 'AHEM____.TTF'))) (font_file, device_path('fonts', os.path.basename(font_file))))
for (host_dirs, font_file, _) in HOST_FONT_FILES:
for host_dir in host_dirs:
host_font_path = host_dir + font_file
if self._check_file_exists(host_font_path, '', more_logging=False):
host_device_tuples.append(
(host_font_path,
device_path('fonts', font_file)))
# - the test resources # - the test resources
host_device_tuples.extend( host_device_tuples.extend(
...@@ -509,17 +458,8 @@ class AndroidPort(base.Port): ...@@ -509,17 +458,8 @@ class AndroidPort(base.Port):
return min(len(self._options.prepared_devices), requested_num_workers) return min(len(self._options.prepared_devices), requested_num_workers)
def check_sys_deps(self, needs_http): def check_sys_deps(self, needs_http):
for (font_dirs, font_file, package) in HOST_FONT_FILES: # _get_font_files() will throw if any of the required fonts is missing.
exists = False self._get_font_files()
for font_dir in font_dirs:
font_path = font_dir + font_file
if self._check_file_exists(font_path, '', more_logging=False):
exists = True
break
if not exists:
_log.error('You are missing %s under %s. Try installing %s. See build instructions.',
font_file, font_dirs, package)
return exit_codes.SYS_DEPS_EXIT_STATUS
return exit_codes.OK_EXIT_STATUS return exit_codes.OK_EXIT_STATUS
def requires_http_server(self): def requires_http_server(self):
......
...@@ -52,6 +52,7 @@ from webkitpy.common.system.path import abspath_to_uri ...@@ -52,6 +52,7 @@ from webkitpy.common.system.path import abspath_to_uri
from webkitpy.layout_tests.layout_package.bot_test_expectations import BotTestExpectationsFactory from webkitpy.layout_tests.layout_package.bot_test_expectations import BotTestExpectationsFactory
from webkitpy.layout_tests.models.test_configuration import TestConfiguration from webkitpy.layout_tests.models.test_configuration import TestConfiguration
from webkitpy.layout_tests.models.test_expectations import TestExpectationParser from webkitpy.layout_tests.models.test_expectations import TestExpectationParser
from webkitpy.layout_tests.models.test_run_results import TestRunException
from webkitpy.layout_tests.port import driver from webkitpy.layout_tests.port import driver
from webkitpy.layout_tests.port import server_process from webkitpy.layout_tests.port import server_process
from webkitpy.layout_tests.port.factory import PortFactory from webkitpy.layout_tests.port.factory import PortFactory
...@@ -63,6 +64,53 @@ from webkitpy.w3c.wpt_manifest import WPTManifest ...@@ -63,6 +64,53 @@ from webkitpy.w3c.wpt_manifest import WPTManifest
_log = logging.getLogger(__name__) _log = logging.getLogger(__name__)
MS_TRUETYPE_FONTS_DIR = '/usr/share/fonts/truetype/msttcorefonts/'
MS_TRUETYPE_FONTS_PACKAGE = 'ttf-mscorefonts-installer'
FONT_FILES = [
[[MS_TRUETYPE_FONTS_DIR], 'Arial.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Arial_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Arial_Bold_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Arial_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Comic_Sans_MS.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Comic_Sans_MS_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Courier_New.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Courier_New_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Courier_New_Bold_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Courier_New_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Georgia.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Georgia_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Georgia_Bold_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Georgia_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Impact.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Trebuchet_MS.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Trebuchet_MS_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Trebuchet_MS_Bold_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Trebuchet_MS_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Times_New_Roman.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Times_New_Roman_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Times_New_Roman_Bold_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Times_New_Roman_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Verdana.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Verdana_Bold.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Verdana_Bold_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
[[MS_TRUETYPE_FONTS_DIR], 'Verdana_Italic.ttf', MS_TRUETYPE_FONTS_PACKAGE],
# The Microsoft font EULA
[['/usr/share/doc/ttf-mscorefonts-installer/'], 'READ_ME!.gz', MS_TRUETYPE_FONTS_PACKAGE],
# Other fonts: Arabic, CJK, Indic, Thai, etc.
# [['/usr/share/fonts/truetype/ttf-dejavu/'], 'DejaVuSans.ttf', 'ttf-dejavu'],
# [['/usr/share/fonts/truetype/kochi/'], 'kochi-mincho.ttf', 'ttf-kochi-mincho'],
# [['/usr/share/fonts/truetype/ttf-indic-fonts-core/'], 'lohit_hi.ttf', 'ttf-indic-fonts-core'],
# [['/usr/share/fonts/truetype/ttf-indic-fonts-core/'], 'lohit_ta.ttf', 'ttf-indic-fonts-core'],
# [['/usr/share/fonts/truetype/ttf-indic-fonts-core/'], 'MuktiNarrow.ttf', 'ttf-indic-fonts-core'],
# [['/usr/share/fonts/truetype/thai/', '/usr/share/fonts/truetype/tlwg/'], 'Garuda.ttf', 'fonts-tlwg-garuda'],
# [['/usr/share/fonts/truetype/ttf-indic-fonts-core/',
# '/usr/share/fonts/truetype/ttf-punjabi-fonts/'],
# 'lohit_pa.ttf',
# 'ttf-indic-fonts-core'],
]
class Port(object): class Port(object):
"""Abstract class for Port-specific hooks for the layout_test package.""" """Abstract class for Port-specific hooks for the layout_test package."""
...@@ -1809,6 +1857,27 @@ class Port(object): ...@@ -1809,6 +1857,27 @@ class Port(object):
pass pass
return True return True
def _get_font_files(self):
"""Returns list of font files that should be used by the test."""
# TODO(sergeyu): Currently FONT_FILES is valid only on Linux. Make it
# usable on other platforms if necessary.
result = [self._build_path('AHEM____.TTF')]
for (font_dirs, font_file, package) in FONT_FILES:
exists = False
for font_dir in font_dirs:
font_path = font_dir + font_file
if self._check_file_exists(font_path, '', more_logging=False):
result.append(font_path)
exists = True
break
if not exists:
message = 'You are missing %s under %s. Try installing %s. See build instructions.' % \
(font_file, font_dirs, package)
_log.error(message)
raise TestRunException(exit_codes.SYS_DEPS_EXIT_STATUS, message)
return result
class VirtualTestSuite(object): class VirtualTestSuite(object):
......
...@@ -38,6 +38,7 @@ from webkitpy.common import exit_codes ...@@ -38,6 +38,7 @@ from webkitpy.common import exit_codes
from webkitpy.layout_tests.port import base from webkitpy.layout_tests.port import base
from webkitpy.layout_tests.port import driver from webkitpy.layout_tests.port import driver
from webkitpy.layout_tests.port import factory from webkitpy.layout_tests.port import factory
from webkitpy.layout_tests.port import linux
from webkitpy.layout_tests.port import server_process from webkitpy.layout_tests.port import server_process
...@@ -70,6 +71,10 @@ def _import_fuchsia_runner(): ...@@ -70,6 +71,10 @@ def _import_fuchsia_runner():
PERF_TEST_PATH_PREFIX = '/all-perf-tests' PERF_TEST_PATH_PREFIX = '/all-perf-tests'
LAYOUT_TEST_PATH_PREFIX = '/all-tests' LAYOUT_TEST_PATH_PREFIX = '/all-tests'
# Paths to the directory where the fonts are copied to. Must match the path in
# content/shell/app/blink_test_platform_support_fuchsia.cc .
FONTS_DEVICE_PATH = '/system/fonts'
# Number of content_shell instances to run in parallel. # Number of content_shell instances to run in parallel.
MAX_WORKERS = 8 MAX_WORKERS = 8
...@@ -107,27 +112,25 @@ class SubprocessOutputLogger(object): ...@@ -107,27 +112,25 @@ class SubprocessOutputLogger(object):
class _TargetHost(object): class _TargetHost(object):
def __init__(self, build_path, ports_to_forward): def __init__(self, build_path, ports_to_forward, fonts):
try: try:
self._target = None self._target = None
self._target = qemu_target.QemuTarget( self._target = qemu_target.QemuTarget(
build_path, 'x64', ram_size_mb=8192) build_path, 'x64', ram_size_mb=8192)
self._target.Start() self._target.Start()
self._setup_target(build_path, ports_to_forward) self._setup_target(build_path, ports_to_forward, fonts)
except: except:
self.cleanup() self.cleanup()
raise raise
def _setup_target(self, build_path, ports_to_forward): def _setup_target(self, build_path, ports_to_forward, fonts):
# Run a proxy to forward all server ports from the Fuchsia device to # Run a proxy to forward all server ports from the Fuchsia device to
# the host. # the host.
# TODO(sergeyu): Potentially this can be implemented using port # TODO(sergeyu): Potentially this can be implemented using port
# forwarding in SSH, but that feature is currently broken on Fuchsia, # forwarding in SSH, but that feature is currently broken on Fuchsia,
# see ZX-1555. Remove layout_test_proxy once that SSH bug is fixed. # see ZX-1555. Remove layout_test_proxy once that SSH bug is fixed.
self._target.PutFile( self._target.PutFile(
os.path.join( os.path.join(build_path, 'package/layout_test_proxy.far'),
build_path,
'gen/build/fuchsia/layout_test_proxy/layout_test_proxy/layout_test_proxy.far'),
'/tmp') '/tmp')
command = ['run', '/tmp/layout_test_proxy.far', command = ['run', '/tmp/layout_test_proxy.far',
'--remote-address=' + qemu_target.HOST_IP_ADDRESS, '--remote-address=' + qemu_target.HOST_IP_ADDRESS,
...@@ -138,13 +141,30 @@ class _TargetHost(object): ...@@ -138,13 +141,30 @@ class _TargetHost(object):
# Copy content_shell package to the device. # Copy content_shell package to the device.
self._target.PutFile( self._target.PutFile(
os.path.join(build_path, 'gen/content/shell/content_shell.far'), '/tmp') os.path.join(build_path, 'package/content_shell.far'), '/tmp')
# Currently dynamic library loading is not implemented for packaged # Currently dynamic library loading is not implemented for packaged
# apps. Copy libosmesa.so to /system/lib as a workaround. # apps. Copy libosmesa.so to /system/lib as a workaround.
self._target.PutFile( self._target.PutFile(
os.path.join(build_path, 'libosmesa.so'), '/system/lib') os.path.join(build_path, 'libosmesa.so'), '/system/lib')
# Copy fonts.
self._target.RunCommand(['mkdir', '/system/fonts'])
self._target.PutFile(
os.path.join(build_path,
'../../content/shell/test_runner/resources/fonts',
'android_main_fonts.xml'),
FONTS_DEVICE_PATH + '/fonts.xml')
self._target.PutFile(
os.path.join(build_path,
'../../content/shell/test_runner/resources/fonts',
'android_fallback_fonts.xml'),
FONTS_DEVICE_PATH + '/fonts_fallback.xml')
self._target.PutFiles(fonts, FONTS_DEVICE_PATH)
def run_command(self, *args, **kvargs): def run_command(self, *args, **kvargs):
return self._target.RunCommandPiped(*args, return self._target.RunCommandPiped(*args,
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
...@@ -165,7 +185,7 @@ class FuchsiaPort(base.Port): ...@@ -165,7 +185,7 @@ class FuchsiaPort(base.Port):
SUPPORTED_VERSIONS = ('sdk',) SUPPORTED_VERSIONS = ('sdk',)
FALLBACK_PATHS = {'sdk': ['fuchsia']} FALLBACK_PATHS = {'sdk': ['fuchsia'] + linux.LinuxPort.latest_platform_fallback_path()}
def __init__(self, host, port_name, **kwargs): def __init__(self, host, port_name, **kwargs):
_import_fuchsia_runner() _import_fuchsia_runner()
...@@ -189,8 +209,7 @@ class FuchsiaPort(base.Port): ...@@ -189,8 +209,7 @@ class FuchsiaPort(base.Port):
return ChromiumFuchsiaDriver return ChromiumFuchsiaDriver
def _path_to_driver(self, target=None): def _path_to_driver(self, target=None):
return self._build_path_with_target(target, return self._build_path_with_target(target, 'package/content_shell.far')
'gen/content/shell/content_shell.far')
def __del__(self): def __del__(self):
if self._zircon_logger: if self._zircon_logger:
...@@ -199,8 +218,8 @@ class FuchsiaPort(base.Port): ...@@ -199,8 +218,8 @@ class FuchsiaPort(base.Port):
def setup_test_run(self): def setup_test_run(self):
super(FuchsiaPort, self).setup_test_run() super(FuchsiaPort, self).setup_test_run()
try: try:
self._target_host = \ self._target_host = _TargetHost(
_TargetHost(self._build_path(), self.SERVER_PORTS) self._build_path(), self.SERVER_PORTS, self._get_font_files())
if self.get_option('zircon_logging'): if self.get_option('zircon_logging'):
self._zircon_logger = SubprocessOutputLogger( self._zircon_logger = SubprocessOutputLogger(
...@@ -225,6 +244,8 @@ class FuchsiaPort(base.Port): ...@@ -225,6 +244,8 @@ class FuchsiaPort(base.Port):
return min(MAX_WORKERS, requested_num_workers) return min(MAX_WORKERS, requested_num_workers)
def check_sys_deps(self, needs_http): def check_sys_deps(self, needs_http):
# _get_font_files() will throw if any of the required fonts is missing.
self._get_font_files()
# TODO(sergeyu): Implement this. # TODO(sergeyu): Implement this.
return exit_codes.OK_EXIT_STATUS return exit_codes.OK_EXIT_STATUS
......
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