Title: [121086] trunk/Tools
Revision
121086
Author
[email protected]
Date
2012-06-22 19:32:51 -0700 (Fri, 22 Jun 2012)

Log Message

[Chromium] DumpRenderTree on Android needs to configure fonts for testing
https://bugs.webkit.org/show_bug.cgi?id=89721

Reviewed by Nate Chapin.

This patch teaches DumpRenderTree to configure Skia to use the fallback
fonts that the LayoutTests assume. This patch reduces the number result
differences between chromium-android and chromium-linux.

* DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp:
* DumpRenderTree/chromium/TestShellAndroid.cpp:
(platformInit):
* DumpRenderTree/chromium/android_fallback_fonts.xml: Added.
* DumpRenderTree/chromium/android_main_fonts.xml: Added.
* Scripts/webkitpy/layout_tests/port/chromium_android.py:

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (121085 => 121086)


--- trunk/Tools/ChangeLog	2012-06-23 02:02:28 UTC (rev 121085)
+++ trunk/Tools/ChangeLog	2012-06-23 02:32:51 UTC (rev 121086)
@@ -1,3 +1,21 @@
+2012-06-22  Adam Barth  <[email protected]>
+
+        [Chromium] DumpRenderTree on Android needs to configure fonts for testing
+        https://bugs.webkit.org/show_bug.cgi?id=89721
+
+        Reviewed by Nate Chapin.
+
+        This patch teaches DumpRenderTree to configure Skia to use the fallback
+        fonts that the LayoutTests assume. This patch reduces the number result
+        differences between chromium-android and chromium-linux.
+
+        * DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp:
+        * DumpRenderTree/chromium/TestShellAndroid.cpp:
+        (platformInit):
+        * DumpRenderTree/chromium/android_fallback_fonts.xml: Added.
+        * DumpRenderTree/chromium/android_main_fonts.xml: Added.
+        * Scripts/webkitpy/layout_tests/port/chromium_android.py:
+
 2012-06-22  Alexandru Chiculita  <[email protected]>
 
         [CSS Shaders] Re-enable the CSS Shaders compile time flag on Safari Mac

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp (121085 => 121086)


--- trunk/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp	2012-06-23 02:02:28 UTC (rev 121085)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp	2012-06-23 02:32:51 UTC (rev 121086)
@@ -256,6 +256,8 @@
                         'destination': '<(PRODUCT_DIR)',
                         'files': [
                             '<(ahem_path)',
+                            '<(tools_dir)/DumpRenderTree/chromium/android_main_fonts.xml',
+                            '<(tools_dir)/DumpRenderTree/chromium/android_fallback_fonts.xml',
                             '<(INTERMEDIATE_DIR)/repack/DumpRenderTree.pak',
                         ]
                     }],

Modified: trunk/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp (121085 => 121086)


--- trunk/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp	2012-06-23 02:02:28 UTC (rev 121085)
+++ trunk/Tools/DumpRenderTree/chromium/TestShellAndroid.cpp	2012-06-23 02:32:51 UTC (rev 121086)
@@ -32,6 +32,7 @@
 #include "TestShell.h"
 
 #include "linux/WebFontRendering.h"
+#include "third_party/skia/include/ports/SkTypeface_android.h"
 #include <android/log.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -43,6 +44,10 @@
 
 namespace {
 
+const char fontMainConfigFile[] = "/data/drt/android_main_fonts.xml";
+const char fontFallbackConfigFile[] = "/data/drt/android_fallback_fonts.xml";
+const char fontsDir[] = "/data/drt/fonts/";
+
 const char optionInFIFO[] = "--in-fifo=";
 const char optionOutFIFO[] = "--out-fifo=";
 const char optionErrFile[] = "--err-file=";
@@ -96,6 +101,11 @@
 
 void platformInit(int* argc, char*** argv)
 {
+    // Initialize skia with customized font config files.
+    // FIXME: Add this call once SkUseTestFontConfigFile is added to Skia and
+    // visible to WebKit. See https://bugs.webkit.org/show_bug.cgi?id=89801
+    // SkUseTestFontConfigFile(fontMainConfigFile, fontFallbackConfigFile, fontsDir);
+
     const char* inFIFO = 0;
     const char* outFIFO = 0;
     const char* errFile = 0;

Added: trunk/Tools/DumpRenderTree/chromium/android_fallback_fonts.xml (0 => 121086)


--- trunk/Tools/DumpRenderTree/chromium/android_fallback_fonts.xml	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/chromium/android_fallback_fonts.xml	2012-06-23 02:32:51 UTC (rev 121086)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<familyset>
+    <family>
+        <fileset>
+            <file>DejaVuSans.ttf</file>
+        </fileset>
+    </family>
+    <family>
+        <fileset>
+            <file>DroidSansFallback.ttf</file>
+        </fileset>
+    </family>
+</familyset>
\ No newline at end of file

Added: trunk/Tools/DumpRenderTree/chromium/android_main_fonts.xml (0 => 121086)


--- trunk/Tools/DumpRenderTree/chromium/android_main_fonts.xml	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/chromium/android_main_fonts.xml	2012-06-23 02:32:51 UTC (rev 121086)
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="utf-8"?>
+<familyset>
+
+    <family>
+        <nameset>
+            <name>sans</name>
+            <name>sans serif</name>
+            <name>sans-serif</name>
+            <name>Arial</name>
+            <name>Helvetica</name>
+        </nameset>
+        <fileset>
+            <file>Arial.ttf</file>
+            <file>Arial_Bold.ttf</file>
+            <file>Arial_Italic.ttf</file>
+            <file>Arial_Bold_Italic.ttf</file>
+        </fileset>
+    </family>
+
+    <family>
+        <nameset>
+            <name>serif</name>
+            <name>Times</name>
+            <name>Times New Roman</name>
+            <name>Monaco</name>
+        </nameset>
+        <fileset>
+            <file>Times_New_Roman.ttf</file>
+            <file>Times_New_Roman_Bold.ttf</file>
+            <file>Times_New_Roman_Italic.ttf</file>
+            <file>Times_New_Roman_Bold_Italic.ttf</file>
+        </fileset>
+    </family>
+
+    <family>
+        <nameset>
+            <name>mono</name>
+            <name>monospace</name>
+            <name>Courier</name>
+            <name>Courier New</name>
+        </nameset>
+        <fileset>
+            <file>Courier_New.ttf</file>
+            <file>Courier_New_Bold.ttf</file>
+            <file>Courier_New_Italic.ttf</file>
+            <file>Courier_New_Bold_Italic.ttf</file>
+        </fileset>
+    </family>
+
+    <family>
+        <nameset>
+            <name>cursive</name>
+            <name>Comic Sans MS</name>
+        </nameset>
+        <fileset>
+            <file>Comic_Sans_MS.ttf</file>
+            <file>Comic_Sans_MS_Bold.ttf</file>
+        </fileset>
+    </family>
+
+    <family>
+        <nameset>
+            <name>fantasy</name>
+            <name>Impact</name>
+        </nameset>
+        <fileset>
+            <file>Impact.ttf</file>
+        </fileset>
+    </family>
+
+    <family>
+        <nameset>
+            <name>Georgia</name>
+        </nameset>
+        <fileset>
+            <file>Georgia.ttf</file>
+            <file>Georgia_Bold.ttf</file>
+            <file>Georgia_Italic.ttf</file>
+            <file>Georgia_Bold_Italic.ttf</file>
+        </fileset>
+    </family>
+
+    <family>
+        <nameset>
+            <name>Trebuchet MS</name>
+        </nameset>
+        <fileset>
+            <file>Trebuchet_MS.ttf</file>
+            <file>Trebuchet_MS_Bold.ttf</file>
+            <file>Trebuchet_MS_Italic.ttf</file>
+            <file>Trebuchet_MS_Bold_Italic.ttf</file>
+        </fileset>
+    </family>
+
+    <family>
+        <nameset>
+            <name>Verdana</name>
+        </nameset>
+        <fileset>
+            <file>Verdana.ttf</file>
+            <file>Verdana_Bold.ttf</file>
+            <file>Verdana_Italic.ttf</file>
+            <file>Verdana_Bold_Italic.ttf</file>
+        </fileset>
+    </family>
+
+    <family>
+        <nameset>
+            <name>Ahem</name>
+        </nameset>
+        <fileset>
+            <file>AHEM____.TTF</file>
+        </fileset>
+    </family>
+
+</familyset>
\ No newline at end of file

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py (121085 => 121086)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py	2012-06-23 02:02:28 UTC (rev 121085)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py	2012-06-23 02:32:51 UTC (rev 121086)
@@ -79,7 +79,7 @@
 # Timeout in seconds to wait for start/stop of DumpRenderTree.
 DRT_START_STOP_TIMEOUT_SECS = 10
 
-# List of fonts that layout tests expect, copied from DumpRenderTree/gtk/TestShellGtk.cpp.
+# List of fonts that layout tests expect, copied from DumpRenderTree/gtk/TestShellX11.cpp.
 HOST_FONT_FILES = [
     [MS_TRUETYPE_FONTS_DIR, 'Arial.ttf'],
     [MS_TRUETYPE_FONTS_DIR, 'Arial_Bold.ttf'],
@@ -108,9 +108,12 @@
     [MS_TRUETYPE_FONTS_DIR, 'Verdana_Bold.ttf'],
     [MS_TRUETYPE_FONTS_DIR, 'Verdana_Bold_Italic.ttf'],
     [MS_TRUETYPE_FONTS_DIR, 'Verdana_Italic.ttf'],
+    # The Microsoft font EULA
+    ['/usr/share/doc/ttf-mscorefonts-installer/', 'READ_ME!.gz'],
+    ['/usr/share/fonts/truetype/ttf-dejavu/', 'DejaVuSans.ttf'],
 ]
 # Should increase this version after changing HOST_FONT_FILES.
-FONT_FILES_VERSION = 1
+FONT_FILES_VERSION = 2
 
 DEVICE_FONTS_DIR = DEVICE_DRT_DIR + 'fonts/'
 
@@ -333,6 +336,10 @@
                                  DEVICE_DRT_DIR + 'DumpRenderTree.pak')
             self._push_to_device(self._build_path(self.get_option('configuration'), 'DumpRenderTree_resources'),
                                  DEVICE_DRT_DIR + 'DumpRenderTree_resources')
+            self._push_to_device(self._build_path(self.get_option('configuration'), 'android_main_fonts.xml'),
+                                 DEVICE_DRT_DIR + 'android_main_fonts.xml')
+            self._push_to_device(self._build_path(self.get_option('configuration'), 'android_fallback_fonts.xml'),
+                                 DEVICE_DRT_DIR + 'android_fallback_fonts.xml')
             # Version control of test resources is dependent on executables,
             # because we will always rebuild executables when resources are
             # updated.
@@ -346,6 +353,7 @@
             self._push_to_device(path_to_ahem_font, DEVICE_FONTS_DIR + 'AHEM____.TTF')
             for (host_dir, font_file) in HOST_FONT_FILES:
                 self._push_to_device(host_dir + font_file, DEVICE_FONTS_DIR + font_file)
+            self._link_device_file('/system/fonts/DroidSansFallback.ttf', DEVICE_FONTS_DIR + 'DroidSansFallback.ttf')
             self._update_version(DEVICE_FONTS_DIR, FONT_FILES_VERSION)
 
     def _push_test_resources(self):
@@ -385,9 +393,10 @@
         _log.debug('Run adb result:\n' + result)
         return result
 
-    def _copy_device_file(self, from_file, to_file, ignore_error=False):
-        # 'cp' is unavailable on Android, so use 'dd' instead.
-        return self._run_adb_command(['shell', 'dd', 'if=' + from_file, 'of=' + to_file], ignore_error)
+    def _link_device_file(self, from_file, to_file, ignore_error=False):
+        # rm to_file first to make sure that ln succeeds.
+        self._run_adb_command(['shell', 'rm', to_file], ignore_error)
+        return self._run_adb_command(['shell', 'ln', '-s', from_file, to_file], ignore_error)
 
     def _push_to_device(self, host_path, device_path, ignore_error=False):
         return self._run_adb_command(['push', host_path, device_path], ignore_error)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to