[content shell] Add layout test specific font setup (for linux only right now)
BUG=111316 TEST=css1/basic/comments.html passes TBR=jam Review URL: https://codereview.chromium.org/11093068 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161351 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -105,6 +105,11 @@
|
||||
'shell/shell_web_contents_view_delegate_mac.mm',
|
||||
'shell/shell_web_contents_view_delegate_win.cc',
|
||||
'shell/shell_web_contents_view_delegate.h',
|
||||
'shell/webkit_test_platform_support.h',
|
||||
'shell/webkit_test_platform_support_android.cc',
|
||||
'shell/webkit_test_platform_support_linux.cc',
|
||||
'shell/webkit_test_platform_support_mac.mm',
|
||||
'shell/webkit_test_platform_support_win.cc',
|
||||
'shell/webkit_test_runner.cc',
|
||||
'shell/webkit_test_runner.h',
|
||||
'shell/webkit_test_runner_bindings.cc',
|
||||
|
@ -625,6 +625,9 @@
|
||||
'../ui/ui.gyp:ui',
|
||||
'../webkit/support/webkit_support.gyp:clearkeycdmplugin',
|
||||
'../webkit/support/webkit_support.gyp:glue',
|
||||
# TODO(jochen): Change this to DumpRenderTree_helpers once
|
||||
# http://wkb.ug/99023 has landed.
|
||||
'<(webkit_src_dir)/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp:DumpRenderTree',
|
||||
],
|
||||
'include_dirs': [
|
||||
'..',
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "content/shell/shell_content_browser_client.h"
|
||||
#include "content/shell/shell_content_renderer_client.h"
|
||||
#include "content/shell/shell_switches.h"
|
||||
#include "content/shell/webkit_test_platform_support.h"
|
||||
#include "net/cookies/cookie_monster.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
#include "ui/base/ui_base_paths.h"
|
||||
@ -91,6 +92,11 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
CommandLine::ForCurrentProcess()->AppendSwitch(
|
||||
switches::kForceCompositingMode);
|
||||
net::CookieMonster::EnableFileScheme();
|
||||
if (!WebKitTestPlatformInitialize()) {
|
||||
if (exit_code)
|
||||
*exit_code = 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
SetContentClient(&content_client_);
|
||||
return false;
|
||||
|
14
content/shell/webkit_test_platform_support.h
Normal file
14
content/shell/webkit_test_platform_support.h
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2012 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_WEBKIT_TEST_PLATFORM_SUPPORT_H_
|
||||
#define CONTENT_SHELL_WEBKIT_TEST_PLATFORM_SUPPORT_H_
|
||||
|
||||
namespace content {
|
||||
|
||||
bool WebKitTestPlatformInitialize();
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_SHELL_WEBKIT_TEST_PLATFORM_SUPPORT_H_
|
13
content/shell/webkit_test_platform_support_android.cc
Normal file
13
content/shell/webkit_test_platform_support_android.cc
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2012 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/webkit_test_platform_support.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
bool WebKitTestPlatformInitialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
144
content/shell/webkit_test_platform_support_linux.cc
Normal file
144
content/shell/webkit_test_platform_support_linux.cc
Normal file
@ -0,0 +1,144 @@
|
||||
// Copyright (c) 2012 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/webkit_test_platform_support.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <fontconfig/fontconfig.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "base/file_path.h"
|
||||
#include "base/file_path.h"
|
||||
#include "base/path_service.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
namespace {
|
||||
|
||||
bool CheckAndLoadFontFile(
|
||||
FcConfig* fontcfg, const char* path1, const char* path2) {
|
||||
const char* font = path1;
|
||||
if (access(font, R_OK) < 0) {
|
||||
font = path2;
|
||||
if (access(font, R_OK) < 0) {
|
||||
std::cerr << "Your are missing " << path1 << " or " << path2 << ". "
|
||||
<< "Without this, some layout tests may fail. See "
|
||||
<< "http://code.google.com/p/chromium/wiki/LayoutTestsLinux "
|
||||
<< "for more.\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!FcConfigAppFontAddFile(
|
||||
fontcfg, reinterpret_cast<const FcChar8*>(font))) {
|
||||
std::cerr << "Failed to load font " << font << "\n";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* const kFonts[] = {
|
||||
"/usr/share/fonts/truetype/kochi/kochi-gothic.ttf",
|
||||
"/usr/share/fonts/truetype/kochi/kochi-mincho.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Arial.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Georgia.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Georgia_Bold.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Georgia_Bold_Italic.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Georgia_Italic.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Impact.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS_Bold.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS_Bold_Italic.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS_Italic.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold_Italic.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Italic.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Verdana.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Verdana_Bold_Italic.ttf",
|
||||
"/usr/share/fonts/truetype/msttcorefonts/Verdana_Italic.ttf",
|
||||
// The DejaVuSans font is used by the css2.1 tests.
|
||||
"/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf",
|
||||
"/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_hi.ttf",
|
||||
"/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_ta.ttf",
|
||||
"/usr/share/fonts/truetype/ttf-indic-fonts-core/MuktiNarrow.ttf",
|
||||
};
|
||||
|
||||
bool SetupFontConfig() {
|
||||
FcInit();
|
||||
|
||||
FilePath base_path;
|
||||
PathService::Get(base::DIR_MODULE, &base_path);
|
||||
FilePath fonts_conf = base_path.Append(FILE_PATH_LITERAL("fonts.conf"));
|
||||
|
||||
FcConfig* font_config = FcConfigCreate();
|
||||
if (!FcConfigParseAndLoad(
|
||||
font_config,
|
||||
reinterpret_cast<const FcChar8*>(fonts_conf.value().c_str()),
|
||||
true)) {
|
||||
std::cerr << "Failed to parse fontconfig config file\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < arraysize(kFonts); ++i) {
|
||||
if (access(kFonts[i], R_OK) < 0) {
|
||||
std::cerr << "You are missing " << kFonts[i] << ". Try re-running "
|
||||
<< "build/install-build-deps.sh. Also see "
|
||||
<< "http://code.google.com/p/chromium/wiki/LayoutTestsLinux";
|
||||
return false;
|
||||
}
|
||||
if (!FcConfigAppFontAddFile(
|
||||
font_config, reinterpret_cast<const FcChar8*>(kFonts[i]))) {
|
||||
std::cerr << "Failed to load font " << kFonts[i] << "\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!CheckAndLoadFontFile(
|
||||
font_config,
|
||||
"/usr/share/fonts/truetype/thai/Garuda.ttf",
|
||||
"/usr/share/fonts/truetype/tlwg/Garuda.ttf")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We special case these fonts because they're only needed in a few layout
|
||||
// tests.
|
||||
CheckAndLoadFontFile(
|
||||
font_config,
|
||||
"/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf",
|
||||
"/usr/share/fonts/truetype/ttf-punjabi-fonts/lohit_pa.ttf");
|
||||
|
||||
FilePath ahem_font = base_path.Append("AHEM____.TTF");
|
||||
if (!FcConfigAppFontAddFile(
|
||||
font_config,
|
||||
reinterpret_cast<const FcChar8*>(ahem_font.value().c_str()))) {
|
||||
std::cerr << "Failed to load font " << ahem_font.value() << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FcConfigSetCurrent(font_config)) {
|
||||
std::cerr << "Failed to set the default font configuration\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool WebKitTestPlatformInitialize() {
|
||||
return SetupFontConfig();
|
||||
}
|
||||
|
||||
} // namespace content
|
13
content/shell/webkit_test_platform_support_mac.mm
Normal file
13
content/shell/webkit_test_platform_support_mac.mm
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2012 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/webkit_test_platform_support.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
bool WebKitTestPlatformInitialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
13
content/shell/webkit_test_platform_support_win.cc
Normal file
13
content/shell/webkit_test_platform_support_win.cc
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2012 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/webkit_test_platform_support.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
bool WebKitTestPlatformInitialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
Reference in New Issue
Block a user