summaryrefslogtreecommitdiffstats
path: root/content/shell
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-11 15:53:06 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-11 15:53:06 +0000
commit8771512b6e74d415dac5377b3b80e5f21de710b4 (patch)
tree08de5adf9e81992ec91866947bb4c9ff1a3446de /content/shell
parent09eb7a0b3608589632ddcdbd3bd009481cbf216d (diff)
downloadchromium_src-8771512b6e74d415dac5377b3b80e5f21de710b4.zip
chromium_src-8771512b6e74d415dac5377b3b80e5f21de710b4.tar.gz
chromium_src-8771512b6e74d415dac5377b3b80e5f21de710b4.tar.bz2
[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
Diffstat (limited to 'content/shell')
-rw-r--r--content/shell/shell_main_delegate.cc6
-rw-r--r--content/shell/webkit_test_platform_support.h14
-rw-r--r--content/shell/webkit_test_platform_support_android.cc13
-rw-r--r--content/shell/webkit_test_platform_support_linux.cc144
-rw-r--r--content/shell/webkit_test_platform_support_mac.mm13
-rw-r--r--content/shell/webkit_test_platform_support_win.cc13
6 files changed, 203 insertions, 0 deletions
diff --git a/content/shell/shell_main_delegate.cc b/content/shell/shell_main_delegate.cc
index 6ddd6f0..ad1abcc 100644
--- a/content/shell/shell_main_delegate.cc
+++ b/content/shell/shell_main_delegate.cc
@@ -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;
diff --git a/content/shell/webkit_test_platform_support.h b/content/shell/webkit_test_platform_support.h
new file mode 100644
index 0000000..a03d20b
--- /dev/null
+++ b/content/shell/webkit_test_platform_support.h
@@ -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_
diff --git a/content/shell/webkit_test_platform_support_android.cc b/content/shell/webkit_test_platform_support_android.cc
new file mode 100644
index 0000000..dc7320e
--- /dev/null
+++ b/content/shell/webkit_test_platform_support_android.cc
@@ -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
diff --git a/content/shell/webkit_test_platform_support_linux.cc b/content/shell/webkit_test_platform_support_linux.cc
new file mode 100644
index 0000000..0e32e4d
--- /dev/null
+++ b/content/shell/webkit_test_platform_support_linux.cc
@@ -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
diff --git a/content/shell/webkit_test_platform_support_mac.mm b/content/shell/webkit_test_platform_support_mac.mm
new file mode 100644
index 0000000..dc7320e
--- /dev/null
+++ b/content/shell/webkit_test_platform_support_mac.mm
@@ -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
diff --git a/content/shell/webkit_test_platform_support_win.cc b/content/shell/webkit_test_platform_support_win.cc
new file mode 100644
index 0000000..dc7320e
--- /dev/null
+++ b/content/shell/webkit_test_platform_support_win.cc
@@ -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