[Chromium] Fix broken DRT build for Aura Linux
authorfsamuel@chromium.org <fsamuel@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Nov 2011 20:21:23 +0000 (20:21 +0000)
committerfsamuel@chromium.org <fsamuel@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Nov 2011 20:21:23 +0000 (20:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=72667

Reviewed by Tony Chang.

Source/WebKit/chromium:

* WebKit.gyp:

Tools:

DRT now builds for Aura Linux. This, more or less, shares the same code as Android.

The following changes have been made:

  1. Renamed TestShellAndroid to TestShellLinux.
  2. Stub code moved added in TestShellStub that will only compile on non-GTK Linux builds.
  3. Code common to Gtk, Aura, and Android moved to TestShellLinux.

* DumpRenderTree/DumpRenderTree.gypi:
* DumpRenderTree/chromium/EventSender.cpp:
(EventSender::keyDown):
* DumpRenderTree/chromium/TestShellAndroid.cpp: Removed.
* DumpRenderTree/chromium/TestShellGtk.cpp:
* DumpRenderTree/chromium/TestShellLinux.cpp: Copied from Tools/DumpRenderTree/chromium/TestShellGtk.cpp.
(AlarmHandler):
(TestShell::waitTestFinished):
(setupFontconfig):
(platformInit):
* DumpRenderTree/chromium/TestShellStub.cpp: Added.
(checkLayoutTestSystemDependencies):
(openStartupDialog):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@101273 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gyp
Tools/ChangeLog
Tools/DumpRenderTree/DumpRenderTree.gypi
Tools/DumpRenderTree/chromium/EventSender.cpp
Tools/DumpRenderTree/chromium/TestShellGtk.cpp
Tools/DumpRenderTree/chromium/TestShellLinux.cpp [new file with mode: 0644]
Tools/DumpRenderTree/chromium/TestShellStub.cpp [moved from Tools/DumpRenderTree/chromium/TestShellAndroid.cpp with 59% similarity]

index 47fa324..db9a5a3 100644 (file)
@@ -1,3 +1,12 @@
+2011-11-28  Fady Samuel  <fsamuel@chromium.org>
+
+        [Chromium] Fix broken DRT build for Aura Linux
+        https://bugs.webkit.org/show_bug.cgi?id=72667
+
+        Reviewed by Tony Chang.
+
+        * WebKit.gyp:
+
 2011-11-28  Adam Barth  <abarth@webkit.org>
 
         [Chromium] Move "final" batch of headers into public/platform
index 8b03e4a..307388a 100644 (file)
                     ],
                 }],
                 ['toolkit_uses_gtk == 1', {
+                    'defines': [
+                        'WTF_USE_GTK=1'
+                    ],
                     'dependencies': [
                         '<(chromium_src_dir)/build/linux/system.gyp:gtk',
                     ],
index 40117fe..6c43a26 100644 (file)
@@ -1,3 +1,32 @@
+2011-11-28  Fady Samuel  <fsamuel@chromium.org>
+
+        [Chromium] Fix broken DRT build for Aura Linux
+        https://bugs.webkit.org/show_bug.cgi?id=72667
+
+        Reviewed by Tony Chang.
+
+        DRT now builds for Aura Linux. This, more or less, shares the same code as Android.
+
+        The following changes have been made:
+
+          1. Renamed TestShellAndroid to TestShellLinux.
+          2. Stub code moved added in TestShellStub that will only compile on non-GTK Linux builds.
+          3. Code common to Gtk, Aura, and Android moved to TestShellLinux.
+
+        * DumpRenderTree/DumpRenderTree.gypi:
+        * DumpRenderTree/chromium/EventSender.cpp:
+        (EventSender::keyDown):
+        * DumpRenderTree/chromium/TestShellAndroid.cpp: Removed.
+        * DumpRenderTree/chromium/TestShellGtk.cpp:
+        * DumpRenderTree/chromium/TestShellLinux.cpp: Copied from Tools/DumpRenderTree/chromium/TestShellGtk.cpp.
+        (AlarmHandler):
+        (TestShell::waitTestFinished):
+        (setupFontconfig):
+        (platformInit):
+        * DumpRenderTree/chromium/TestShellStub.cpp: Added.
+        (checkLayoutTestSystemDependencies):
+        (openStartupDialog):
+
 2011-11-28  Eric Seidel  <eric@webkit.org>
 
         Add Environment object to Host and fix the GCC smartquotes trouble seen on the commit-queue
index b19be22..47442bf 100644 (file)
@@ -34,7 +34,7 @@
             'chromium/TestNavigationController.h',
             'chromium/TestShell.cpp',
             'chromium/TestShell.h',
-            'chromium/TestShellAndroid.cpp',
+            'chromium/TestShellLinux.cpp',
             'chromium/TestShellGtk.cpp',
             'chromium/TestShellMac.mm',
             'chromium/TestShellWin.cpp',
             'TestNetscapePlugIn/main.cpp',
         ],
         'conditions': [
+            ['(OS=="linux" and toolkit_uses_gtk!=1) or OS=="android"', {
+                'drt_files': [
+                    'chromium/TestShellStub.cpp',
+                ],
+            }],
             ['OS=="win"', {
                 'drt_files': [
                     'chromium/WebThemeControlDRTWin.cpp',
index 20d77a7..8d546f1 100644 (file)
@@ -576,7 +576,7 @@ void EventSender::keyDown(const CppArgumentList& arguments, CppVariant* result)
     eventDown.type = WebInputEvent::RawKeyDown;
     eventDown.modifiers = 0;
     eventDown.windowsKeyCode = code;
-#if OS(LINUX)
+#if OS(LINUX) && USE(GTK)
     eventDown.nativeKeyCode = webkit_support::NativeKeyCodeForWindowsKeyCode(code, needsShiftKeyModifier);
 #endif
 
index 33bde9a..4228f2a 100644 (file)
 #include <gtk/gtk.h>
 #include <signal.h>
 
-static void AlarmHandler(int)
-{
-    // If the alarm alarmed, kill the process since we have a really bad hang.
-    puts("\n#TEST_TIMED_OUT\n");
-    puts("#EOF\n");
-    fflush(stdout);
-    exit(0);
-}
-
-static void setupFontconfig()
-{
-    // We wish to make the layout tests reproducable with respect to fonts. Skia
-    // uses fontconfig to resolve font family names from WebKit into actual font
-    // files found on the current system. This means that fonts vary based on the
-    // system and also on the fontconfig configuration.
-    //
-    // To avoid this we initialise fontconfig here and install a configuration
-    // which only knows about a few, select, fonts.
-
-    // We have fontconfig parse a config file from our resources file. This
-    // sets a number of aliases ("sans"->"Arial" etc), but doesn't include any
-    // font directories.
-    FcInit();
-
-    char drtPath[PATH_MAX + 1];
-    int drtPathSize = readlink("/proc/self/exe", drtPath, PATH_MAX);
-    if (drtPathSize < 0 || drtPathSize > PATH_MAX) {
-        fputs("Unable to resolve /proc/self/exe.", stderr);
-        exit(1);
-    }
-    drtPath[drtPathSize] = 0;
-    std::string drtDirPath(drtPath);
-    size_t lastPathPos = drtDirPath.rfind("/");
-    ASSERT(lastPathPos != std::string::npos);
-    drtDirPath.erase(lastPathPos + 1);
-
-    FcConfig* fontcfg = FcConfigCreate();
-    std::string fontconfigPath = drtDirPath + "fonts.conf";
-    if (!FcConfigParseAndLoad(fontcfg, reinterpret_cast<const FcChar8*>(fontconfigPath.c_str()), true)) {
-        fputs("Failed to parse fontconfig config file\n", stderr);
-        exit(1);
-    }
-
-    // This is the list of fonts that fontconfig will know about. It
-    // will try its best to match based only on the fonts here in. The
-    // paths are where these fonts are found on our Ubuntu boxes.
-    static const char *const fonts[] = {
-        "/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",
-        "/usr/share/fonts/truetype/thai/Garuda.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",
-    };
-    for (size_t i = 0; i < arraysize(fonts); ++i) {
-        if (access(fonts[i], R_OK)) {
-            fprintf(stderr, "You are missing %s. Try re-running build/install-build-deps.sh. Also see "
-                            "http://code.google.com/p/chromium/wiki/LayoutTestsLinux",
-                            fonts[i]);
-            exit(1);
-        }
-        if (!FcConfigAppFontAddFile(fontcfg, (FcChar8 *) fonts[i])) {
-            fprintf(stderr, "Failed to load font %s\n", fonts[i]);
-            exit(1);
-        }
-    }
-
-    // We special case these fonts because they're only needed in a
-    // few layout tests.
-    static const char* const optionalFonts[] = {
-        "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf",
-    };
-    for (size_t i = 0; i < arraysize(optionalFonts); ++i) {
-        const char* font = optionalFonts[i];
-
-        // This font changed paths across Ubuntu releases, so try checking in both locations.
-        if (!strcmp(font, "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf")
-            && access(font, R_OK) < 0)
-            font = "/usr/share/fonts/truetype/ttf-punjabi-fonts/lohit_pa.ttf";
-
-        if (access(font, R_OK) < 0) {
-            fprintf(stderr, "You are missing %s. Without this, some layout tests may fail. "
-                            "See http://code.google.com/p/chromium/wiki/LayoutTestsLinux "
-                            "for more.\n", font);
-        } else if (!FcConfigAppFontAddFile(fontcfg, (FcChar8 *) font)) {
-            fprintf(stderr, "Failed to load font %s\n", font);
-            exit(1);
-        }
-    }
-
-    // Also load the layout-test-specific "Ahem" font.
-    std::string ahemPath = drtDirPath + "AHEM____.TTF";
-    if (!FcConfigAppFontAddFile(fontcfg, reinterpret_cast<const FcChar8*>(ahemPath.c_str()))) {
-        fprintf(stderr, "Failed to load font %s\n", ahemPath.c_str());
-        exit(1);
-    }
-
-    if (!FcConfigSetCurrent(fontcfg)) {
-        fputs("Failed to set the default font configuration\n", stderr);
-        exit(1);
-    }
-}
-
-void TestShell::waitTestFinished()
-{
-    ASSERT(!m_testIsPending);
-    m_testIsPending = true;
-
-    // Install an alarm signal handler that will kill us if we time out.
-    struct sigaction alarmAction;
-    alarmAction.sa_handler = AlarmHandler;
-    sigemptyset(&alarmAction.sa_mask);
-    alarmAction.sa_flags = 0;
-
-    struct sigaction oldAction;
-    sigaction(SIGALRM, &alarmAction, &oldAction);
-    alarm(layoutTestTimeoutForWatchDog() / 1000);
-
-    // TestFinished() will post a quit message to break this loop when the page
-    // finishes loading.
-    while (m_testIsPending)
-        webkit_support::RunMessageLoop();
-
-    // Remove the alarm.
-    alarm(0);
-    sigaction(SIGALRM, &oldAction, 0);
-}
-
-void platformInit(int* argc, char*** argv)
-{
-    // FIXME: It's better call gtk_init() only when we run plugin tests.
-    // See http://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/633ea167cde196ca#
-    gtk_init(argc, argv);
-
-    setupFontconfig();
-}
 
 void openStartupDialog()
 {
diff --git a/Tools/DumpRenderTree/chromium/TestShellLinux.cpp b/Tools/DumpRenderTree/chromium/TestShellLinux.cpp
new file mode 100644 (file)
index 0000000..f8d0bbf
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TestShell.h"
+
+#include "SkTypeface.h"
+#include "WebView.h"
+#include "webkit/support/webkit_support.h"
+
+#if !OS(ANDROID)
+#include <fontconfig/fontconfig.h>
+#endif
+#include <signal.h>
+#include <unistd.h>
+
+static void AlarmHandler(int)
+{
+    // If the alarm alarmed, kill the process since we have a really bad hang.
+    puts("\n#TEST_TIMED_OUT\n");
+    puts("#EOF\n");
+    fflush(stdout);
+    exit(0);
+}
+
+void TestShell::waitTestFinished()
+{
+    ASSERT(!m_testIsPending);
+    m_testIsPending = true;
+
+    // Install an alarm signal handler that will kill us if we time out.
+    struct sigaction alarmAction;
+    alarmAction.sa_handler = AlarmHandler;
+    sigemptyset(&alarmAction.sa_mask);
+    alarmAction.sa_flags = 0;
+
+    struct sigaction oldAction;
+    sigaction(SIGALRM, &alarmAction, &oldAction);
+    alarm(layoutTestTimeoutForWatchDog() / 1000);
+
+    // TestFinished() will post a quit message to break this loop when the page
+    // finishes loading.
+    while (m_testIsPending)
+        webkit_support::RunMessageLoop();
+
+    // Remove the alarm.
+    alarm(0);
+    sigaction(SIGALRM, &oldAction, 0);
+}
+
+#if !OS(ANDROID)
+static void setupFontconfig()
+{
+    // We wish to make the layout tests reproducable with respect to fonts. Skia
+    // uses fontconfig to resolve font family names from WebKit into actual font
+    // files found on the current system. This means that fonts vary based on the
+    // system and also on the fontconfig configuration.
+    //
+    // To avoid this we initialise fontconfig here and install a configuration
+    // which only knows about a few, select, fonts.
+
+    // We have fontconfig parse a config file from our resources file. This
+    // sets a number of aliases ("sans"->"Arial" etc), but doesn't include any
+    // font directories.
+    FcInit();
+
+    char drtPath[PATH_MAX + 1];
+    int drtPathSize = readlink("/proc/self/exe", drtPath, PATH_MAX);
+    if (drtPathSize < 0 || drtPathSize > PATH_MAX) {
+        fputs("Unable to resolve /proc/self/exe.", stderr);
+        exit(1);
+    }
+    drtPath[drtPathSize] = 0;
+    std::string drtDirPath(drtPath);
+    size_t lastPathPos = drtDirPath.rfind("/");
+    ASSERT(lastPathPos != std::string::npos);
+    drtDirPath.erase(lastPathPos + 1);
+
+    FcConfig* fontcfg = FcConfigCreate();
+    std::string fontconfigPath = drtDirPath + "fonts.conf";
+    if (!FcConfigParseAndLoad(fontcfg, reinterpret_cast<const FcChar8*>(fontconfigPath.c_str()), true)) {
+        fputs("Failed to parse fontconfig config file\n", stderr);
+        exit(1);
+    }
+
+    // This is the list of fonts that fontconfig will know about. It
+    // will try its best to match based only on the fonts here in. The
+    // paths are where these fonts are found on our Ubuntu boxes.
+    static const char *const fonts[] = {
+        "/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",
+        "/usr/share/fonts/truetype/thai/Garuda.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",
+    };
+    for (size_t i = 0; i < arraysize(fonts); ++i) {
+        if (access(fonts[i], R_OK)) {
+            fprintf(stderr, "You are missing %s. Try re-running build/install-build-deps.sh. Also see "
+                            "http://code.google.com/p/chromium/wiki/LayoutTestsLinux",
+                            fonts[i]);
+            exit(1);
+        }
+        if (!FcConfigAppFontAddFile(fontcfg, (FcChar8 *) fonts[i])) {
+            fprintf(stderr, "Failed to load font %s\n", fonts[i]);
+            exit(1);
+        }
+    }
+
+    // We special case these fonts because they're only needed in a
+    // few layout tests.
+    static const char* const optionalFonts[] = {
+        "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf",
+    };
+    for (size_t i = 0; i < arraysize(optionalFonts); ++i) {
+        const char* font = optionalFonts[i];
+
+        // This font changed paths across Ubuntu releases, so try checking in both locations.
+        if (!strcmp(font, "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf")
+            && access(font, R_OK) < 0)
+            font = "/usr/share/fonts/truetype/ttf-punjabi-fonts/lohit_pa.ttf";
+
+        if (access(font, R_OK) < 0) {
+            fprintf(stderr, "You are missing %s. Without this, some layout tests may fail. "
+                            "See http://code.google.com/p/chromium/wiki/LayoutTestsLinux "
+                            "for more.\n", font);
+        } else if (!FcConfigAppFontAddFile(fontcfg, (FcChar8 *) font)) {
+            fprintf(stderr, "Failed to load font %s\n", font);
+            exit(1);
+        }
+    }
+
+    // Also load the layout-test-specific "Ahem" font.
+    std::string ahemPath = drtDirPath + "AHEM____.TTF";
+    if (!FcConfigAppFontAddFile(fontcfg, reinterpret_cast<const FcChar8*>(ahemPath.c_str()))) {
+        fprintf(stderr, "Failed to load font %s\n", ahemPath.c_str());
+        exit(1);
+    }
+
+    if (!FcConfigSetCurrent(fontcfg)) {
+        fputs("Failed to set the default font configuration\n", stderr);
+        exit(1);
+    }
+}
+#endif // !OS(ANDROID)
+
+void platformInit(int* argc, char*** argv)
+{
+    // FIXME: It's better call gtk_init() only when we run plugin tests.
+    // See http://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/633ea167cde196ca#
+#if USE(GTK)
+    gtk_init(argc, argv);
+#endif
+
+#if !OS(ANDROID)
+    setupFontconfig();
+#endif
+}
+
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#include "TestShell.h"
-
-#include "SkTypeface.h"
-#include "WebView.h"
-#include "webkit/support/webkit_support.h"
-
-#include <signal.h>
-#include <unistd.h>
-
-static void AlarmHandler(int)
-{
-    // If the alarm alarmed, kill the process since we have a really bad hang.
-    puts("\n#TEST_TIMED_OUT\n");
-    puts("#EOF\n");
-    fflush(stdout);
-    webkit_support::TearDownTestEnvironment();
-    exit(0);
-}
-
-void TestShell::waitTestFinished()
-{
-    ASSERT(!m_testIsPending);
-    m_testIsPending = true;
-
-    // Install an alarm signal handler that will kill us if we time out.
-    struct sigaction alarmAction;
-    alarmAction.sa_handler = AlarmHandler;
-    sigemptyset(&alarmAction.sa_mask);
-    alarmAction.sa_flags = 0;
 
-    struct sigaction oldAction;
-    sigaction(SIGALRM, &alarmAction, &oldAction);
-    alarm(layoutTestTimeoutForWatchDog() / 1000);
-
-    // TestFinished() will post a quit message to break this loop when the page
-    // finishes loading.
-    while (m_testIsPending)
-        webkit_support::RunMessageLoop();
+#include "config.h"
 
-    // Remove the alarm.
-    alarm(0);
-    sigaction(SIGALRM, &oldAction, 0);
-}
+#include "TestShell.h"
 
-void platformInit(int* argc, char*** argv)
+bool checkLayoutTestSystemDependencies()
 {
-    // Nothing to do here.
+    return true;
 }
 
 void openStartupDialog()
@@ -83,8 +43,3 @@ void openStartupDialog()
     // FIXME: Not implemented.
 }
 
-bool checkLayoutTestSystemDependencies()
-{
-    // Nothing to do here.
-    return true;
-}