/hg/icedtea6: Added new regression test for check if all non-Lat...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Tue Nov 2 03:39:56 PDT 2010
changeset 2210c22d3fff in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=2210c22d3fff
author: ptisnovs
date: Tue Nov 02 10:44:52 2010 +0100
Added new regression test for check if all non-Latin fonts are
installed and properly configured.
diffstat:
3 files changed, 207 insertions(+), 2 deletions(-)
ChangeLog | 9 +
Makefile.am | 5
patches/icedtea-jtreg-international-fonts.patch | 195 +++++++++++++++++++++++
diffs (230 lines):
diff -r 0bfb4898c039 -r 2210c22d3fff ChangeLog
--- a/ChangeLog Wed Oct 20 14:45:55 2010 +0100
+++ b/ChangeLog Tue Nov 02 10:44:52 2010 +0100
@@ -1,3 +1,12 @@ 2010-10-19 Andrew John Hughes <ahughes
+2010-11-02 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * Makefile.am:
+ * patches/icedtea-jtreg-international-fonts.patch:
+ Added new regression test
+ patches/icedtea-jtreg-international-fonts.patch
+ for checking if all non-Latin fonts are installed
+ and properly configured.
+
2010-10-19 Andrew John Hughes <ahughes at redhat.com>
* INSTALL: Clarify HotSpot build documentation.
diff -r 0bfb4898c039 -r 2210c22d3fff Makefile.am
--- a/Makefile.am Wed Oct 20 14:45:55 2010 +0100
+++ b/Makefile.am Tue Nov 02 10:44:52 2010 +0100
@@ -291,8 +291,9 @@ ICEDTEA_PATCHES = \
patches/numa_on_early_glibc.patch \
patches/icedtea-shark-build.patch \
patches/openjdk/6985992-test_6933784.patch \
- patches/openjdk/6853592-badwindow-warning-fix.patch \
- patches/6703377-freetypescaler.patch
+ patches/openjdk/6853592-badwindow-warning-fix.patch \
+ patches/6703377-freetypescaler.patch \
+ patches/icedtea-jtreg-international-fonts.patch
if !WITH_ALT_HSBUILD
ICEDTEA_PATCHES += \
diff -r 0bfb4898c039 -r 2210c22d3fff patches/icedtea-jtreg-international-fonts.patch
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/icedtea-jtreg-international-fonts.patch Tue Nov 02 10:44:52 2010 +0100
@@ -0,0 +1,195 @@
+--- /dev/null 2010-06-29 14:56:30.329576932 +0200
++++ openjdk/jdk/test/java/awt/font/InternationalFonts/InternationalFontsRendering.java 2010-11-01 11:27:46.000000000 +0100
+@@ -0,0 +1,192 @@
++import java.awt.Color;
++import java.awt.Font;
++import java.awt.Graphics2D;
++import java.awt.RenderingHints;
++import java.awt.image.BufferedImage;
++import java.io.File;
++import java.io.IOException;
++import java.util.Arrays;
++import java.util.List;
++import java.util.ArrayList;
++
++import javax.imageio.ImageIO;
++
++/**
++ * @test
++ * @run main InternationalFontsRendering
++ * @author Pavel Tisnovsky
++ *
++ * @summary This test check if all required fonts are properly installed and configured.
++ *
++ * This regression test checks if all required fonts are properly installed and
++ * that .src.properties font configuration is correct. The test is based on
++ * rendering certain characters from selected code pages into BufferedImage.
++ *
++ * When the font does not exists or font configuration is broken, only empty
++ * rectangle is rendered instead of the selected character shape. This rectangle
++ * is filtered and then the destination image is tested whether it is empty
++ * (=white).
++ *
++ * If test images with rendered characters needs to be created use following flag:
++ * -create-images
++ *
++ * regression for bug: https://bugzilla.redhat.com/show_bug.cgi?id=643674
++ * (Bug 643674 Misconfigured Path for Asian Font)
++ *
++ */
++public class InternationalFontsRendering
++{
++ private static int WIDTH = 200;
++ private static int HEIGHT = 200;
++
++ private static final int FONT_SIZE = 160;
++
++ private static final int MINIMUM_HORIZONTAL_LINE_LENGTH = 70;
++ private static final int MINIMUM_VERTICAL_LINE_LENGTH = 80;
++ private static final int BLACK_WHITE_THRESHOLD = 128;
++ private static final int BLACK_PIXEL_COUNT_THRESHOLD = WIDTH * HEIGHT / 1000;
++
++ private static final String[][] testedStrings = {
++ {"Latin-1", "abcdefABCDEF"},
++ {"Latin-2", "ÄÅ¡ÄÅžýáÃéúůľÅ"},
++ {"Cyrilic", "ÐÐÐÑ²Ð¤Ð¥Ñ°Ñ Ð¦"},
++ {"Greek", "βξγδÏεÏζΣÏÏηÏθÏ
Ω"},
++ {"Asia-Test1", "ä½ä¸æ符å·"},
++ {"Asia-Test2", "ç¹é«ä¸æ符è"},
++ {"Asia-Test3", "æ¥æ¬ã®è±¡å¾´"},
++ {"Asia-Test4", "íêµì´ê¸°í¸"},
++ };
++
++ /**
++ * Creates test image a renders one big character to it.
++ * @param testedString
++ * @return
++ */
++ private BufferedImage createTestImage(String str) {
++ BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_BYTE_GRAY);
++ Graphics2D gc = image.createGraphics();
++ gc.setBackground(Color.WHITE);
++ gc.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
++ gc.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
++ gc.clearRect(0, 0, WIDTH, HEIGHT);
++ gc.setFont(new Font(Font.DIALOG, Font.PLAIN, FONT_SIZE));
++ gc.setColor(Color.BLACK);
++ gc.drawString(str, 0, HEIGHT - 40);
++ gc.dispose();
++ return image;
++ }
++
++ /**
++ * Creates destination image and then copies data from source image to it
++ * @param src
++ * @return
++ */
++ private BufferedImage createDestinationImage(BufferedImage src) {
++ BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_BYTE_GRAY);
++ src.copyData(image.getRaster());
++ return image;
++ }
++
++ /**
++ * Removes long horizontal lines from image
++ */
++ private void removeHorizontalLines(BufferedImage image) {
++ for (int y = 0; y < image.getHeight(); y++) {
++ int startX = -1, endX = -1;
++ for (int x = 0; x < image.getWidth(); x++) {
++ int color = image.getRaster().getSample(x, y, 0);
++ if (startX < 0 && color <= BLACK_WHITE_THRESHOLD) {
++ startX = x;
++ //System.out.println("> " + y + "\t" + x);
++ }
++ if (startX > 0 && endX < 0 && color > BLACK_WHITE_THRESHOLD) {
++ endX = x;
++ //System.out.println("< " + y + "\t" + x);
++ }
++ }
++ // remove long horizontal line, but only if this line found detected in image
++ if (startX > 0 && endX > 0 && (endX - startX) > MINIMUM_HORIZONTAL_LINE_LENGTH) {
++ for (int x = startX; x < endX; x++) {
++ image.getRaster().setSample(x, y, 0, 255);
++ }
++ }
++ }
++ }
++
++ /**
++ * Removes long vertical lines from image
++ */
++ private void removeVerticalLines(BufferedImage image) {
++ for (int x = 0; x < image.getWidth(); x++) {
++ int startY = -1, endY = -1;
++ for (int y = 0; y < image.getHeight(); y++) {
++ int color = image.getRaster().getSample(x, y, 0);
++ if (startY < 0 && color <= BLACK_WHITE_THRESHOLD) {
++ startY = y;
++ }
++ if (startY > 0 && endY < 0 && color > BLACK_WHITE_THRESHOLD) {
++ endY = y;
++ //System.out.println("< " + y + "\t" + x);
++ }
++ }
++ // remove long vertical line, but only if this line found detected in image
++ if (startY > 0 && endY > 0 && (endY - startY) > MINIMUM_VERTICAL_LINE_LENGTH) {
++ for (int y = startY; y < endY; y++) {
++ image.getRaster().setSample(x, y, 0, 255);
++ }
++ }
++ }
++ }
++
++ /**
++ * Test if image is almost empty (one large white area)
++ * @param image
++ * @return
++ */
++ private boolean isImageAlmostEmpty(BufferedImage image) {
++ int blackPixelCount = 0;
++ for (int y = 0; y < image.getHeight(); y++) {
++ for (int x = 0; x < image.getWidth(); x++) {
++ if (image.getRaster().getSample(x, y, 0) < BLACK_WHITE_THRESHOLD) {
++ blackPixelCount++;
++ }
++ }
++ }
++ return blackPixelCount < BLACK_PIXEL_COUNT_THRESHOLD;
++ }
++
++ public void runTest(boolean createImages) throws IOException
++ {
++ List<Integer> badCharacters = new ArrayList<Integer>();
++ for (String[] testedString : testedStrings) {
++ System.out.println("\nTesting " + testedString[0]);
++ for (int i = 0; i < testedString[1].length(); i++) {
++ String str = testedString[1].substring(i, 1+i);
++ int code = str.charAt(0);
++ System.out.print(code + "\t");
++ BufferedImage src = createTestImage(str);
++ BufferedImage dst = createDestinationImage(src);
++ removeHorizontalLines(dst);
++ removeVerticalLines(dst);
++
++ if (createImages /* || true*/) {
++ ImageIO.write(src, "png", new File(code + "_src.png"));
++ ImageIO.write(dst, "png", new File(code + "_dst.png"));
++ }
++
++ if (isImageAlmostEmpty(dst)) {
++ System.err.println("Bad rendering of character with code: " + code);
++ badCharacters.add(Integer.valueOf(code));
++ }
++ }
++ }
++ if (!badCharacters.isEmpty()) {
++ throw new RuntimeException("Error in rendering of character(s) with code(s): " + badCharacters.toString());
++ }
++ }
++
++ public static void main(String[] args) throws IOException {
++ new InternationalFontsRendering().runTest(Arrays.asList(args).contains("-create-images"));
++ }
++}
++
More information about the distro-pkg-dev
mailing list