Title: [118115] trunk
Revision
118115
Author
wangxian...@chromium.org
Date
2012-05-22 21:14:11 -0700 (Tue, 22 May 2012)

Log Message

[Chromium-Android] Run DumpRenderTree as an apk (C++ and gyp part)
https://bugs.webkit.org/show_bug.cgi?id=86922

Source/WebKit/chromium:

Reviewed by Kent Tamura.

* All.gyp: Added DumpRenderTree_apk into dependencies for Android.

Tools:

Because we have new platformInit() in TestShellAndroid.cpp, and
we still need the timeout part in TestShellLinux.cpp, TestShellLinux.cpp
is split into TestShellPosix.cpp and TestShellX11.cpp.

Reviewed by Kent Tamura.

* DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp:
* DumpRenderTree/DumpRenderTree.gypi:
* DumpRenderTree/chromium/TestShellAndroid.cpp: Added. Handles command lines to redirect stdin/stdout/stderr.
(platformInit):
* DumpRenderTree/chromium/TestShellGtk.cpp: Removed. Merged into TestShellX11.cpp
* DumpRenderTree/chromium/TestShellLinux.cpp: Removed. Split into TestShellPosix.cpp and TestShellX11.cpp.
* DumpRenderTree/chromium/TestShellPosix.cpp: Split from TestShellLinux.cpp, containing the timeout handling part, compiled when os_posix=1 (excluding mac).
(AlarmHandler):
(TestShell::waitTestFinished):
* DumpRenderTree/chromium/TestShellX11.cpp: Split from TestShellLinux.cpp, containing the fontconfig part, compiled when use_x11=1
(openStartupDialog): from TestShellGtk.cpp
(checkLayoutTestSystemDependencies): from TestShellGtk.cpp.
(setupFontconfig):
(platformInit):

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebKit/chromium/All.gyp (118114 => 118115)


--- trunk/Source/WebKit/chromium/All.gyp	2012-05-23 04:00:47 UTC (rev 118114)
+++ trunk/Source/WebKit/chromium/All.gyp	2012-05-23 04:14:11 UTC (rev 118115)
@@ -44,6 +44,13 @@
                 '../../../Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp:DumpRenderTree',
                 '../../../Tools/TestWebKitAPI/TestWebKitAPI.gyp/TestWebKitAPI.gyp:TestWebKitAPI',
             ],
+            'conditions': [
+                ['OS=="android"', {
+                    'dependencies': [
+                        '../../../Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp:DumpRenderTree_apk',
+                    ],
+                }],
+            ],
         }
     ],
 }

Modified: trunk/Source/WebKit/chromium/ChangeLog (118114 => 118115)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-05-23 04:00:47 UTC (rev 118114)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-05-23 04:14:11 UTC (rev 118115)
@@ -1,3 +1,12 @@
+2012-05-22  Xianzhu Wang  <wangxian...@chromium.org>
+
+        [Chromium-Android] Run DumpRenderTree as an apk (C++ and gyp part)
+        https://bugs.webkit.org/show_bug.cgi?id=86922
+
+        Reviewed by Kent Tamura.
+
+        * All.gyp: Added DumpRenderTree_apk into dependencies for Android.
+
 2012-05-22  Mark Pilgrim  <pilg...@chromium.org>
 
         [Chromium] Call canAccelerate2dCanvas directly

Modified: trunk/Tools/ChangeLog (118114 => 118115)


--- trunk/Tools/ChangeLog	2012-05-23 04:00:47 UTC (rev 118114)
+++ trunk/Tools/ChangeLog	2012-05-23 04:14:11 UTC (rev 118115)
@@ -1,3 +1,29 @@
+2012-05-22  Xianzhu Wang  <wangxian...@chromium.org>
+
+        [Chromium-Android] Run DumpRenderTree as an apk (C++ and gyp part)
+        https://bugs.webkit.org/show_bug.cgi?id=86922
+
+        Because we have new platformInit() in TestShellAndroid.cpp, and
+        we still need the timeout part in TestShellLinux.cpp, TestShellLinux.cpp
+        is split into TestShellPosix.cpp and TestShellX11.cpp.
+
+        Reviewed by Kent Tamura.
+
+        * DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp:
+        * DumpRenderTree/DumpRenderTree.gypi:
+        * DumpRenderTree/chromium/TestShellAndroid.cpp: Added. Handles command lines to redirect stdin/stdout/stderr.
+        (platformInit):
+        * DumpRenderTree/chromium/TestShellGtk.cpp: Removed. Merged into TestShellX11.cpp
+        * DumpRenderTree/chromium/TestShellLinux.cpp: Removed. Split into TestShellPosix.cpp and TestShellX11.cpp.
+        * DumpRenderTree/chromium/TestShellPosix.cpp: Split from TestShellLinux.cpp, containing the timeout handling part, compiled when os_posix=1 (excluding mac).
+        (AlarmHandler):
+        (TestShell::waitTestFinished):
+        * DumpRenderTree/chromium/TestShellX11.cpp: Split from TestShellLinux.cpp, containing the fontconfig part, compiled when use_x11=1
+        (openStartupDialog): from TestShellGtk.cpp
+        (checkLayoutTestSystemDependencies): from TestShellGtk.cpp.
+        (setupFontconfig):
+        (platformInit):
+
 2012-05-22  Kangil Han  <kangil....@samsung.com>
 
         [EFL][DRT] Implement touch event

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp (118114 => 118115)


--- trunk/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp	2012-05-23 04:00:47 UTC (rev 118114)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp	2012-05-23 04:14:11 UTC (rev 118115)
@@ -78,11 +78,14 @@
             'type': 'executable',
             'mac_bundle': 1,
             'dependencies': [
+                'ImageDiff',
+                'copy_TestNetscapePlugIn',
                 '<(source_dir)/WebKit/chromium/WebKit.gyp:inspector_resources',
                 '<(source_dir)/WebKit/chromium/WebKit.gyp:webkit',
                 '<(source_dir)/WTF/WTF.gyp/WTF.gyp:wtf',
                 '<(chromium_src_dir)/build/temp_gyp/googleurl.gyp:googleurl',
                 '<(chromium_src_dir)/third_party/icu/icu.gyp:icuuc',
+                '<(chromium_src_dir)/third_party/mesa/mesa.gyp:osmesa',
                 '<(chromium_src_dir)/v8/tools/gyp/v8.gyp:v8',
                 '<(chromium_src_dir)/base/base.gyp:test_support_base',
                 '<(chromium_src_dir)/webkit/support/webkit_support.gyp:blob',
@@ -117,7 +120,6 @@
                         '<(chromium_src_dir)/third_party/angle/src/build_angle.gyp:libEGL',
                         '<(chromium_src_dir)/third_party/angle/src/build_angle.gyp:libGLESv2',
                     ],
-
                     'resource_include_dirs': ['<(SHARED_INTERMEDIATE_DIR)/webkit'],
                     'sources': [
                         '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.rc',
@@ -194,6 +196,11 @@
                         ['exclude', 'Mac\\.cpp$'],
                     ],
                 }],
+                ['os_posix!=1 or OS=="mac"', {
+                    'sources/': [
+                        ['exclude', 'Posix\\.cpp$'],
+                    ],
+                }],
                 ['use_x11 == 1', {
                     'dependencies': [
                         '<(chromium_src_dir)/build/linux/system.gyp:fontconfig',
@@ -219,7 +226,7 @@
                     ],
                 },{ # use_x11 != 1
                     'sources/': [
-                        ['exclude', 'Linux\\.cpp$']
+                        ['exclude', 'X11\\.cpp$'],
                     ]
                 }],
                 ['toolkit_uses_gtk == 1', {
@@ -232,27 +239,31 @@
                     'include_dirs': [
                         '<(source_dir)/WebKit/chromium/public/gtk',
                     ],
-                },{ # toolkit_uses_gtk != 1
-                    'sources/': [
-                        ['exclude', 'Gtk\\.cpp$']
-                    ]
                 }],
                 ['OS=="android"', {
+                    'type': 'shared_library',
                     'dependencies': [
                         'ImageDiff#host',
+                        '<(chromium_src_dir)/base/base.gyp:test_support_base',
+                        '<(chromium_src_dir)/tools/android/forwarder/forwarder.gyp:forwarder',
+                        '<(chromium_src_dir)/testing/android/native_test.gyp:native_test_native_code',
                     ],
-                    'sources/': [
-                        ['include', 'chromium/TestShellLinux\\.cpp$'],
-                    ],
-                },{ # OS!="android"
-                    'sources/': [
-                        ['exclude', '(Android)\\.cpp$']
-                    ],
-                    'dependencies': [
+                    'dependencies!': [
                         'ImageDiff',
                         'copy_TestNetscapePlugIn',
                         '<(chromium_src_dir)/third_party/mesa/mesa.gyp:osmesa',
                     ],
+                    'copies': [{
+                        'destination': '<(PRODUCT_DIR)',
+                        'files': [
+                            '<(ahem_path)',
+                            '<(INTERMEDIATE_DIR)/repack/DumpRenderTree.pak',
+                        ]
+                    }],
+                }, { # OS!="android"
+                    'sources/': [
+                        ['exclude', 'Android\\.cpp$'],
+                    ],
                 }],
                 ['inside_chromium_build==1 and component=="shared_library"', {
                     'sources': [
@@ -390,5 +401,43 @@
                 'cflags_cc': ['-Wno-c++0x-compat'],
             },
         }],
+        ['OS=="android"', {
+            # Wrap libDumpRenderTree.so into an android apk for execution.
+            # See <(chromium_src_dir)/base/base.gyp for TODO(jrg)s about this strategy.
+            'targets': [{
+                'target_name': 'DumpRenderTree_apk',
+                'type': 'none',
+                'dependencies': [
+                    'DumpRenderTree',
+                ],
+                'actions': [{
+                    # Generate apk files (including source and antfile) from
+                    # a template, and builds them.
+                    'action_name': 'generate_and_build',
+                    'inputs': [
+                        '<(chromium_src_dir)/testing/android/generate_native_test.py',
+                        '<(PRODUCT_DIR)/lib.target/libDumpRenderTree.so',
+                        # FIXME: Build the jar for native tests with SDK.
+                        # For now we are using Android.mk to build the apk.
+                    ],
+                    'outputs': [
+                        '<(PRODUCT_DIR)/DumpRenderTree_apk/ChromeNativeTests-debug.apk',
+                    ],
+                    'action': [
+                        '<(chromium_src_dir)/testing/android/generate_native_test.py',
+                        '--native_library',
+                        '<(PRODUCT_DIR)/lib.target/libDumpRenderTree.so',
+                        # FIXME: Build the jar for native tests with SDK.
+                        # '--jar',
+                        # 'foo/bar.jar',
+                        '--output',
+                        '<(PRODUCT_DIR)/DumpRenderTree_apk',
+                        '--ant-args',
+                        '-DPRODUCT_DIR=<(PRODUCT_DIR)',
+                        '--ant-compile'
+                    ],
+                }],
+            }],
+        }],
     ], # conditions
 }

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.gypi (118114 => 118115)


--- trunk/Tools/DumpRenderTree/DumpRenderTree.gypi	2012-05-23 04:00:47 UTC (rev 118114)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.gypi	2012-05-23 04:14:11 UTC (rev 118115)
@@ -34,11 +34,12 @@
             'chromium/TestNavigationController.h',
             'chromium/TestShell.cpp',
             'chromium/TestShell.h',
-            'chromium/TestShellLinux.cpp',
-            'chromium/TestShellGtk.cpp',
+            'chromium/TestShellAndroid.cpp',
             'chromium/TestShellMac.mm',
+            'chromium/TestShellPosix.cpp',
             'chromium/TestShellStub.cpp',
             'chromium/TestShellWin.cpp',
+            'chromium/TestShellX11.cpp',
             'chromium/TestWebPlugin.cpp',
             'chromium/TestWebPlugin.h',
             'chromium/TextInputController.cpp',

Added: trunk/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp (0 => 118115)


--- trunk/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp	2012-05-23 04:14:11 UTC (rev 118115)
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2012 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 <android/log.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <wtf/Assertions.h>
+
+namespace {
+
+const char optionInFIFO[] = "--in-fifo=";
+const char optionOutFIFO[] = "--out-fifo=";
+const char optionErrFile[] = "--err-file=";
+
+void androidLogError(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2);
+
+void androidLogError(const char* format, ...)
+{
+    va_list args;
+    va_start(args, format);
+    __android_log_vprint(ANDROID_LOG_ERROR, "DumpRenderTree", format, args);
+    va_end(args);
+}
+
+void removeArg(int index, int* argc, char*** argv)
+{
+    for (int i = index; i < *argc; ++i)
+        (*argv)[i] = (*argv)[i + 1];
+    --*argc;
+}
+
+void createFIFO(const char* fifoPath)
+{
+    unlink(fifoPath);
+    if (mkfifo(fifoPath, 0600)) {
+        androidLogError("Failed to create fifo %s: %s\n", fifoPath, strerror(errno));
+        exit(EXIT_FAILURE);
+    }
+}
+
+void createFile(const char* filePath)
+{
+    unlink(filePath);
+    int fd = creat(filePath, 0600);
+    if (fd < 0) {
+        androidLogError("Failed to create file %s: %s\n", filePath, strerror(errno));
+        exit(EXIT_FAILURE);
+    }
+    close(fd);
+}
+
+void redirectToFile(FILE* stream, const char* path, const char* mode)
+{
+    if (!freopen(path, mode, stream)) {
+        androidLogError("Failed to redirect stream to file: %s: %s\n", path, strerror(errno));
+        exit(EXIT_FAILURE);
+    }
+}
+
+} // namespace
+
+void platformInit(int* argc, char*** argv)
+{
+    const char* inFIFO = 0;
+    const char* outFIFO = 0;
+    const char* errFile = 0;
+    for (int i = 1; i < *argc; ) {
+        const char* argument = (*argv)[i];
+        if (strstr(argument, optionInFIFO) == argument) {
+            inFIFO = argument + WTF_ARRAY_LENGTH(optionInFIFO) - 1;
+            createFIFO(inFIFO);
+            removeArg(i, argc, argv);
+        } else if (strstr(argument, optionOutFIFO) == argument) {
+            outFIFO = argument + WTF_ARRAY_LENGTH(optionOutFIFO) - 1;
+            createFIFO(outFIFO);
+            removeArg(i, argc, argv);
+        } else if (strstr(argument, optionErrFile) == argument) {
+            errFile = argument + WTF_ARRAY_LENGTH(optionErrFile) - 1;
+            createFile(errFile);
+            removeArg(i, argc, argv);
+        } else
+            ++i;
+    }
+
+    // The order of createFIFO() and redirectToFIFO() is important to avoid deadlock.
+    if (outFIFO)
+        redirectToFile(stdout, outFIFO, "w");
+    if (inFIFO)
+        redirectToFile(stdin, inFIFO, "r");
+    if (errFile)
+        redirectToFile(stderr, errFile, "w");
+    else {
+        // Redirect stderr to stdout.
+        dup2(1, 2);
+    }
+}

Deleted: trunk/Tools/DumpRenderTree/chromium/TestShellGtk.cpp (118114 => 118115)


--- trunk/Tools/DumpRenderTree/chromium/TestShellGtk.cpp	2012-05-23 04:00:47 UTC (rev 118114)
+++ trunk/Tools/DumpRenderTree/chromium/TestShellGtk.cpp	2012-05-23 04:14:11 UTC (rev 118115)
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2010 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 "webkit/support/webkit_support.h"
-#include <fontconfig/fontconfig.h>
-#include <gtk/gtk.h>
-#include <signal.h>
-
-
-void openStartupDialog()
-{
-    GtkWidget* dialog = gtk_message_dialog_new(
-        0, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Attach to me?");
-    gtk_window_set_title(GTK_WINDOW(dialog), "DumpRenderTree");
-    gtk_dialog_run(GTK_DIALOG(dialog)); // Runs a nested message loop.
-    gtk_widget_destroy(dialog);
-}
-
-bool checkLayoutTestSystemDependencies()
-{
-    return true;
-}

Deleted: trunk/Tools/DumpRenderTree/chromium/TestShellLinux.cpp (118114 => 118115)


--- trunk/Tools/DumpRenderTree/chromium/TestShellLinux.cpp	2012-05-23 04:00:47 UTC (rev 118114)
+++ trunk/Tools/DumpRenderTree/chromium/TestShellLinux.cpp	2012-05-23 04:14:11 UTC (rev 118115)
@@ -1,223 +0,0 @@
-/*
- * 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
-
-#if USE(GTK)
-#include <gtk/gtk.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 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) {
-            fprintf(stderr, "You are missing %s or %s. Without this, some layout tests may fail. "
-                            "See http://code.google.com/p/chromium/wiki/LayoutTestsLinux "
-                            "for more.\n", path1, path2);
-            return false;
-        }
-    }
-    if (!FcConfigAppFontAddFile(fontcfg, (FcChar8 *) font)) {
-        fprintf(stderr, "Failed to load font %s\n", font);
-        return false;
-    }
-    return true;
-}
-
-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",
-        // 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);
-        }
-    }
-
-    if (!checkAndLoadFontFile(fontcfg, "/usr/share/fonts/truetype/thai/Garuda.ttf",
-                              "/usr/share/fonts/truetype/tlwg/Garuda.ttf"))
-        exit(1);
-
-    // We special case these fonts because they're only needed in a
-    // few layout tests.
-    checkAndLoadFontFile(fontcfg, "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf", 
-                         "/usr/share/fonts/truetype/ttf-punjabi-fonts/lohit_pa.ttf");
-
-    // 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
-}
-

Copied: trunk/Tools/DumpRenderTree/chromium/TestShellPosix.cpp (from rev 118114, trunk/Tools/DumpRenderTree/chromium/TestShellGtk.cpp) (0 => 118115)


--- trunk/Tools/DumpRenderTree/chromium/TestShellPosix.cpp	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/chromium/TestShellPosix.cpp	2012-05-23 04:14:11 UTC (rev 118115)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 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 "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);
+    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);
+}

Copied: trunk/Tools/DumpRenderTree/chromium/TestShellX11.cpp (from rev 118114, trunk/Tools/DumpRenderTree/chromium/TestShellLinux.cpp) (0 => 118115)


--- trunk/Tools/DumpRenderTree/chromium/TestShellX11.cpp	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/chromium/TestShellX11.cpp	2012-05-23 04:14:11 UTC (rev 118115)
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2012 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 <fontconfig/fontconfig.h>
+
+#if USE(GTK)
+#include <gtk/gtk.h>
+
+void openStartupDialog()
+{
+    GtkWidget* dialog = gtk_message_dialog_new(
+        0, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Attach to me?");
+    gtk_window_set_title(GTK_WINDOW(dialog), "DumpRenderTree");
+    gtk_dialog_run(GTK_DIALOG(dialog)); // Runs a nested message loop.
+    gtk_widget_destroy(dialog);
+}
+
+bool checkLayoutTestSystemDependencies()
+{
+    return true;
+}
+#endif // USE(GTK)
+
+static 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) {
+            fprintf(stderr, "You are missing %s or %s. Without this, some layout tests may fail. "
+                            "See http://code.google.com/p/chromium/wiki/LayoutTestsLinux "
+                            "for more.\n", path1, path2);
+            return false;
+        }
+    }
+    if (!FcConfigAppFontAddFile(fontcfg, (FcChar8 *) font)) {
+        fprintf(stderr, "Failed to load font %s\n", font);
+        return false;
+    }
+    return true;
+}
+
+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",
+        // 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);
+        }
+    }
+
+    if (!checkAndLoadFontFile(fontcfg, "/usr/share/fonts/truetype/thai/Garuda.ttf",
+                              "/usr/share/fonts/truetype/tlwg/Garuda.ttf"))
+        exit(1);
+
+    // We special case these fonts because they're only needed in a
+    // few layout tests.
+    checkAndLoadFontFile(fontcfg, "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf", 
+                         "/usr/share/fonts/truetype/ttf-punjabi-fonts/lohit_pa.ttf");
+
+    // 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 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
+
+    setupFontconfig();
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to