Title: [101922] trunk/Tools
Revision
101922
Author
[email protected]
Date
2011-12-03 03:33:05 -0800 (Sat, 03 Dec 2011)

Log Message

[GTK][DRT] Normalize file:///tmp/LayoutTests in LayoutTestController::pathToLocalResource()
https://bugs.webkit.org/show_bug.cgi?id=67256

Patch by Martin Robinson <[email protected]> on 2011-12-03
Reviewed by Philippe Normand.

Implement LayoutTestController::pathToLocalResource for GTK+. Instead of passing
WEBKIT_TEST_FONTS to the GTK+ test harnesses, pass a more generic WEBKIT_TOP_LEVEL,
which points to the more generic top-level path of the WebKit checkout. This code is
duplicated between WK1 and WK2 harnesses because we do not currently have a way to
share code here.

If WEBKIT_TOP_LEVEL is not provided, we search for the top level based on the binary
location. This will cause the fallback to fail if you build into a non-typical location
or even fake it with a symlink. In this case it's important to use the environment variable.

* DumpRenderTree/gtk/DumpRenderTree.cpp:
(getTopLevelPath): Added.
(initializeFonts): Use the new helper to get the font path.
* DumpRenderTree/gtk/DumpRenderTreeGtk.h: Expose the new helper.
* DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
(LayoutTestController::pathToLocalResource):Use the new helper to normalize
test paths.
* Scripts/webkitpy/layout_tests/port/gtk.py:
(GtkPort.setup_environ_for_server):Pass the top-level path of the
checkout instead of passing the font path.
* WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp:
(WTR::getTopLevelPath): Added this helper.
(WTR::inititializeFontConfigSetting): Use the helper to find the font path.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (101921 => 101922)


--- trunk/Tools/ChangeLog	2011-12-03 11:06:21 UTC (rev 101921)
+++ trunk/Tools/ChangeLog	2011-12-03 11:33:05 UTC (rev 101922)
@@ -1,3 +1,34 @@
+2011-12-03  Martin Robinson  <[email protected]>
+
+        [GTK][DRT] Normalize file:///tmp/LayoutTests in LayoutTestController::pathToLocalResource()
+        https://bugs.webkit.org/show_bug.cgi?id=67256
+
+        Reviewed by Philippe Normand.
+
+        Implement LayoutTestController::pathToLocalResource for GTK+. Instead of passing 
+        WEBKIT_TEST_FONTS to the GTK+ test harnesses, pass a more generic WEBKIT_TOP_LEVEL,
+        which points to the more generic top-level path of the WebKit checkout. This code is
+        duplicated between WK1 and WK2 harnesses because we do not currently have a way to
+        share code here.
+
+        If WEBKIT_TOP_LEVEL is not provided, we search for the top level based on the binary
+        location. This will cause the fallback to fail if you build into a non-typical location
+        or even fake it with a symlink. In this case it's important to use the environment variable.
+
+        * DumpRenderTree/gtk/DumpRenderTree.cpp:
+        (getTopLevelPath): Added.
+        (initializeFonts): Use the new helper to get the font path.
+        * DumpRenderTree/gtk/DumpRenderTreeGtk.h: Expose the new helper.
+        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+        (LayoutTestController::pathToLocalResource):Use the new helper to normalize
+        test paths.
+        * Scripts/webkitpy/layout_tests/port/gtk.py:
+        (GtkPort.setup_environ_for_server):Pass the top-level path of the
+        checkout instead of passing the font path.
+        * WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp:
+        (WTR::getTopLevelPath): Added this helper.
+        (WTR::inititializeFontConfigSetting): Use the helper to find the font path.
+
 2011-12-02  David Levin  <[email protected]>
 
         Rename WTF class from TemporarilyChange to TemporaryChange.

Modified: trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp (101921 => 101922)


--- trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp	2011-12-03 11:06:21 UTC (rev 101921)
+++ trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp	2011-12-03 11:33:05 UTC (rev 101922)
@@ -157,6 +157,20 @@
         g_object_set(settings, "gtk-xft-rgba", "none", NULL);
 }
 
+CString getTopLevelPath()
+{
+    if (const char* topLevelDirectory = g_getenv("WEBKIT_TOP_LEVEL"))
+        return topLevelDirectory;
+
+    // If the environment variable wasn't provided then assume we were built into
+    // WebKitBuild/Debug or WebKitBuild/Release. Obviously this will fail if the build
+    // directory is non-standard, but we can't do much more about this.
+    GOwnPtr<char> parentPath(g_path_get_dirname(getCurrentExecutablePath().data()));
+    GOwnPtr<char> layoutTestsPath(g_build_filename(parentPath.get(), "..", "..", "..", NULL));
+    GOwnPtr<char> absoluteTopLevelPath(realpath(layoutTestsPath.get(), 0));
+    return absoluteTopLevelPath.get();
+}
+
 static void initializeFonts(const char* testURL = 0)
 {
 #if PLATFORM(X11)
@@ -178,22 +192,18 @@
     if (!FcConfigParseAndLoad(config, reinterpret_cast<FcChar8*>(fontConfigFilename.get()), true))
         g_error("Couldn't load font configuration file from: %s", fontConfigFilename.get());
 
-    CString fontsPath = g_getenv("WEBKIT_TEST_FONTS");
-    if (fontsPath.isNull()) {
-        GOwnPtr<char> parentPath(g_path_get_dirname(getCurrentExecutablePath().data()));
-        GOwnPtr<char> alternatePath(g_build_filename(parentPath.get(), "..", "..",
-                                                     "Dependencies", "Root", "webkitgtk-test-fonts", NULL));
-        fontsPath = alternatePath.get();
-        if (!g_file_test(alternatePath.get(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
-            g_error("WEBKIT_TEST_FONTS environment variable not set and %s does not exist", alternatePath.get());
-    }
+    CString topLevelPath = getTopLevelPath();
+    GOwnPtr<char> fontsPath(g_build_filename(topLevelPath.data(), "WebKitBuild", "Dependencies",
+                                             "Root", "webkitgtk-test-fonts", NULL));
+    if (!g_file_test(fontsPath.get(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
+        g_error("Could not locate test fonts at %s. Is WEBKIT_TOP_LEVEL set?", fontsPath.get());
 
     GOwnPtr<GError> error;
-    GOwnPtr<GDir> fontsDirectory(g_dir_open(fontsPath.data(), 0, &error.outPtr()));
+    GOwnPtr<GDir> fontsDirectory(g_dir_open(fontsPath.get(), 0, &error.outPtr()));
     while (const char* directoryEntry = g_dir_read_name(fontsDirectory.get())) {
         if (!g_str_has_suffix(directoryEntry, ".ttf") && !g_str_has_suffix(directoryEntry, ".otf"))
             continue;
-        GOwnPtr<gchar> fontPath(g_build_filename(fontsPath.data(), directoryEntry, NULL));
+        GOwnPtr<gchar> fontPath(g_build_filename(fontsPath.get(), directoryEntry, NULL));
         if (!FcConfigAppFontAddFile(config, reinterpret_cast<const FcChar8*>(fontPath.get())))
             g_error("Could not load font at %s!", fontPath.get());
 

Modified: trunk/Tools/DumpRenderTree/gtk/DumpRenderTreeGtk.h (101921 => 101922)


--- trunk/Tools/DumpRenderTree/gtk/DumpRenderTreeGtk.h	2011-12-03 11:06:21 UTC (rev 101921)
+++ trunk/Tools/DumpRenderTree/gtk/DumpRenderTreeGtk.h	2011-12-03 11:33:05 UTC (rev 101922)
@@ -31,8 +31,8 @@
 
 #include <webkit/webkitdefines.h>
 #include <_javascript_Core/JSBase.h>
-
 #include <glib.h>
+#include <wtf/text/CString.h>
 
 extern WebKitWebFrame* mainFrame;
 extern WebKitWebFrame* topLoadingFrame;
@@ -41,5 +41,6 @@
 extern GSList* webViewList;
 
 gchar* JSStringCopyUTF8CString(JSStringRef jsString);
+CString getTopLevelPath();
 
 #endif // DumpRenderTreeGtk_h

Modified: trunk/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp (101921 => 101922)


--- trunk/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp	2011-12-03 11:06:21 UTC (rev 101921)
+++ trunk/Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp	2011-12-03 11:33:05 UTC (rev 101922)
@@ -201,8 +201,13 @@
 
 JSStringRef LayoutTestController::pathToLocalResource(JSContextRef context, JSStringRef url)
 {
-    // Function introduced in r28690. This may need special-casing on Windows.
-    return JSStringRetain(url); // Do nothing on Unix.
+    GOwnPtr<char> urlCString(JSStringCopyUTF8CString(url));
+    if (!g_str_has_prefix(urlCString.get(), "file:///tmp/LayoutTests/"))
+        return url;
+
+    const char* layoutTestsSuffix = urlCString.get() + strlen("file:///tmp/");
+    GOwnPtr<char> testPath(g_build_filename(getTopLevelPath().data(), layoutTestsSuffix));
+    return JSStringCreateWithUTF8CString(testPath.get());
 }
 
 void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target)

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py (101921 => 101922)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py	2011-12-03 11:06:21 UTC (rev 101921)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py	2011-12-03 11:33:05 UTC (rev 101922)
@@ -93,7 +93,7 @@
         environment['TEST_RUNNER_INJECTED_BUNDLE_FILENAME'] = self._build_path('Libraries', 'libTestRunnerInjectedBundle.la')
         environment['TEST_RUNNER_TEST_PLUGIN_PATH'] = self._build_path('TestNetscapePlugin', '.libs')
         environment['WEBKIT_INSPECTOR_PATH'] = self._build_path('Programs', 'resources', 'inspector')
-        environment['WEBKIT_TEST_FONTS'] = self._build_path('..', 'Dependencies', 'Root', 'webkitgtk-test-fonts')
+        environment['WEBKIT_TOP_LEVEL'] = self._config.webkit_base_dir()
         return environment
 
     def _generate_all_test_configurations(self):

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp (101921 => 101922)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp	2011-12-03 11:06:21 UTC (rev 101921)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp	2011-12-03 11:33:05 UTC (rev 101922)
@@ -52,6 +52,20 @@
                  "gtk-xft-rgba", "none", NULL);
 }
 
+static CString getTopLevelPath()
+{
+    if (const char* topLevelDirectory = g_getenv("WEBKIT_TOP_LEVEL"))
+        return topLevelDirectory;
+
+    // If the environment variable wasn't provided then assume we were built into
+    // WebKitBuild/Debug or WebKitBuild/Release. Obviously this will fail if the build
+    // directory is non-standard, but we can't do much more about this.
+    GOwnPtr<char> parentPath(g_path_get_dirname(getCurrentExecutablePath().data()));
+    GOwnPtr<char> layoutTestsPath(g_build_filename(parentPath.get(), "..", "..", "..", NULL));
+    GOwnPtr<char> absoluteTopLevelPath(realpath(layoutTestsPath.get(), 0));
+    return absoluteTopLevelPath.get();
+}
+
 void inititializeFontConfigSetting()
 {
     FcInit();
@@ -72,22 +86,18 @@
     if (!FcConfigParseAndLoad(config, reinterpret_cast<FcChar8*>(fontConfigFilename.get()), true))
         g_error("Couldn't load font configuration file from: %s", fontConfigFilename.get());
 
-    CString fontsPath = g_getenv("WEBKIT_TEST_FONTS");
-    if (fontsPath.isNull()) {
-        GOwnPtr<char> parentPath(g_path_get_dirname(getCurrentExecutablePath().data()));
-        GOwnPtr<char> alternatePath(g_build_filename(parentPath.get(), "..", "..",
-                                                     "Dependencies", "Root", "webkitgtk-test-fonts", NULL));
-        fontsPath = alternatePath.get();
-        if (!g_file_test(alternatePath.get(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
-            g_error("WEBKIT_TEST_FONTS environment variable not set and %s does not exist", alternatePath.get());
-    }
+    CString topLevelPath = getTopLevelPath();
+    GOwnPtr<char> fontsPath(g_build_filename(topLevelPath.data(), "WebKitBuild", "Dependencies",
+                                             "Root", "webkitgtk-test-fonts", NULL));
+    if (!g_file_test(fontsPath.get(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
+        g_error("Could not locate test fonts at %s. Is WEBKIT_TOP_LEVEL set?", fontsPath.get());
 
     GOwnPtr<GError> error;
-    GOwnPtr<GDir> fontsDirectory(g_dir_open(fontsPath.data(), 0, &error.outPtr()));
+    GOwnPtr<GDir> fontsDirectory(g_dir_open(fontsPath.get(), 0, &error.outPtr()));
     while (const char* directoryEntry = g_dir_read_name(fontsDirectory.get())) {
         if (!g_str_has_suffix(directoryEntry, ".ttf") && !g_str_has_suffix(directoryEntry, ".otf"))
             continue;
-        GOwnPtr<gchar> fontPath(g_build_filename(fontsPath.data(), directoryEntry, NULL));
+        GOwnPtr<gchar> fontPath(g_build_filename(fontsPath.get(), directoryEntry, NULL));
         if (!FcConfigAppFontAddFile(config, reinterpret_cast<const FcChar8*>(fontPath.get())))
             g_error("Could not load font at %s!", fontPath.get());
     }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to