From: carlosgc@webkit.org Date: Mon, 2 Jul 2012 16:10:49 +0000 (+0000) Subject: [GTK] Read fonts path when running layout tests from alternative fonts dir when main... X-Git-Tag: 070512121124~212 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=406ecd528a8196a0d20904ff227989e77f2a7de0;p=profile%2Fivi%2Fwebkit-efl.git [GTK] Read fonts path when running layout tests from alternative fonts dir when main dir doesn't exist https://bugs.webkit.org/show_bug.cgi?id=89437 Reviewed by Martin Robinson. If main fonts directory doesn't exist, try with an alternative fonts directory at build directory. * DumpRenderTree/gtk/DumpRenderTree.cpp: (getOutputDir): (getFontsPath): (initializeFonts): * WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp: (WTR::getOutputDir): (WTR): (WTR::getFontsPath): (WTR::inititializeFontConfigSetting): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121684 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Tools/ChangeLog b/Tools/ChangeLog index b56a0c8..c0c0bda 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,5 +1,25 @@ 2012-07-02 Carlos Garcia Campos + [GTK] Read fonts path when running layout tests from alternative fonts dir when main dir doesn't exist + https://bugs.webkit.org/show_bug.cgi?id=89437 + + Reviewed by Martin Robinson. + + If main fonts directory doesn't exist, try with an alternative + fonts directory at build directory. + + * DumpRenderTree/gtk/DumpRenderTree.cpp: + (getOutputDir): + (getFontsPath): + (initializeFonts): + * WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp: + (WTR::getOutputDir): + (WTR): + (WTR::getFontsPath): + (WTR::inititializeFontConfigSetting): + +2012-07-02 Carlos Garcia Campos + [GTK] Don't run the tests with jhbuild wrapper if it's already running under jhbuild https://bugs.webkit.org/show_bug.cgi?id=89435 diff --git a/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp b/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp index f7e9057..0bde652 100644 --- a/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp +++ b/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp @@ -169,6 +169,32 @@ CString getTopLevelPath() return TOP_LEVEL_DIR; } +CString getOutputDir() +{ + const char* webkitOutputDir = g_getenv("WEBKITOUTPUTDIR"); + if (webkitOutputDir) + return webkitOutputDir; + + CString topLevelPath = getTopLevelPath(); + GOwnPtr outputDir(g_build_filename(topLevelPath.data(), "WebKitBuild", NULL)); + return outputDir.get(); +} + +static CString getFontsPath() +{ + CString webkitOutputDir = getOutputDir(); + GOwnPtr fontsPath(g_build_filename(webkitOutputDir.data(), "Dependencies", "Root", "webkitgtk-test-fonts", NULL)); + if (g_file_test(fontsPath.get(), static_cast(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) + return fontsPath.get(); + + // Try alternative fonts path. + fontsPath.set(g_build_filename(webkitOutputDir.data(), "webkitgtk-test-fonts", NULL)); + if (g_file_test(fontsPath.get(), static_cast(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) + return fontsPath.get(); + + return CString(); +} + static void initializeFonts(const char* testURL = 0) { #if PLATFORM(X11) @@ -190,24 +216,16 @@ static void initializeFonts(const char* testURL = 0) if (!FcConfigParseAndLoad(config, reinterpret_cast(fontConfigFilename.get()), true)) g_error("Couldn't load font configuration file from: %s", fontConfigFilename.get()); - GOwnPtr fontsPath; - const char* webkitOutputDir = g_getenv("WEBKITOUTPUTDIR"); - if (webkitOutputDir) - fontsPath.set(g_build_filename(webkitOutputDir, "Dependencies", "Root", "webkitgtk-test-fonts", NULL)); - else { - CString topLevelPath = getTopLevelPath(); - fontsPath.set(g_build_filename(topLevelPath.data(), "WebKitBuild", "Dependencies", "Root", "webkitgtk-test-fonts", NULL)); - } - - if (!g_file_test(fontsPath.get(), static_cast(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()); + CString fontsPath = getFontsPath(); + if (fontsPath.isNull()) + g_error("Could not locate test fonts at %s. Is WEBKIT_TOP_LEVEL set?", fontsPath.data()); GOwnPtr error; - GOwnPtr fontsDirectory(g_dir_open(fontsPath.get(), 0, &error.outPtr())); + GOwnPtr fontsDirectory(g_dir_open(fontsPath.data(), 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 fontPath(g_build_filename(fontsPath.get(), directoryEntry, NULL)); + GOwnPtr fontPath(g_build_filename(fontsPath.data(), directoryEntry, NULL)); if (!FcConfigAppFontAddFile(config, reinterpret_cast(fontPath.get()))) g_error("Could not load font at %s!", fontPath.get()); diff --git a/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp b/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp index 19acfd8..c843591 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp @@ -66,6 +66,32 @@ static CString getTopLevelPath() return absoluteTopLevelPath.get(); } +CString getOutputDir() +{ + const char* webkitOutputDir = g_getenv("WEBKITOUTPUTDIR"); + if (webkitOutputDir) + return webkitOutputDir; + + CString topLevelPath = getTopLevelPath(); + GOwnPtr outputDir(g_build_filename(topLevelPath.data(), "WebKitBuild", NULL)); + return outputDir.get(); +} + +static CString getFontsPath() +{ + CString webkitOutputDir = getOutputDir(); + GOwnPtr fontsPath(g_build_filename(webkitOutputDir.data(), "Dependencies", "Root", "webkitgtk-test-fonts", NULL)); + if (g_file_test(fontsPath.get(), static_cast(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) + return fontsPath.get(); + + // Try alternative fonts path. + fontsPath.set(g_build_filename(webkitOutputDir.data(), "webkitgtk-test-fonts", NULL)); + if (g_file_test(fontsPath.get(), static_cast(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) + return fontsPath.get(); + + return CString(); +} + void inititializeFontConfigSetting() { FcInit(); @@ -86,24 +112,16 @@ void inititializeFontConfigSetting() if (!FcConfigParseAndLoad(config, reinterpret_cast(fontConfigFilename.get()), true)) g_error("Couldn't load font configuration file from: %s", fontConfigFilename.get()); - GOwnPtr fontsPath; - const char* webkitOutputDir = g_getenv("WEBKITOUTPUTDIR"); - if (webkitOutputDir) - fontsPath.set(g_build_filename(webkitOutputDir, "Dependencies", "Root", "webkitgtk-test-fonts", NULL)); - else { - CString topLevelPath = getTopLevelPath(); - fontsPath.set(g_build_filename(topLevelPath.data(), "WebKitBuild", "Dependencies", "Root", "webkitgtk-test-fonts", NULL)); - } - - if (!g_file_test(fontsPath.get(), static_cast(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()); + CString fontsPath = getFontsPath(); + if (fontsPath.isNull()) + g_error("Could not locate test fonts at %s. Is WEBKIT_TOP_LEVEL set?", fontsPath.data()); GOwnPtr error; - GOwnPtr fontsDirectory(g_dir_open(fontsPath.get(), 0, &error.outPtr())); + GOwnPtr fontsDirectory(g_dir_open(fontsPath.data(), 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 fontPath(g_build_filename(fontsPath.get(), directoryEntry, NULL)); + GOwnPtr fontPath(g_build_filename(fontsPath.data(), directoryEntry, NULL)); if (!FcConfigAppFontAddFile(config, reinterpret_cast(fontPath.get()))) g_error("Could not load font at %s!", fontPath.get()); }