/hg/icedtea6: Added patch containing three new JTreg tests Compo...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Tue Apr 30 04:18:56 PDT 2013


changeset 3b76dff83564 in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=3b76dff83564
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue Apr 30 13:18:33 2013 +0200

	Added patch containing three new JTreg tests ComponentOrientationTest.java,
	ComponentPlacementTest.java and ComponentSizeTest.java.


diffstat:

 ChangeLog                               |   10 +
 Makefile.am                             |    3 +-
 patches/componentOrientationTests.patch |  246 ++++++++++++++++++++++++++++++++
 3 files changed, 258 insertions(+), 1 deletions(-)

diffs (280 lines):

diff -r 11353b3c2109 -r 3b76dff83564 ChangeLog
--- a/ChangeLog	Mon Apr 29 13:27:32 2013 +0200
+++ b/ChangeLog	Tue Apr 30 13:18:33 2013 +0200
@@ -1,3 +1,13 @@
+2013-04-30  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* Makefile.am:
+	(ICEDTEA_PATCHES): Added new patch.
+	* patches/componentOrientationTests.patch:
+	Patch containing three new JTreg tests ComponentOrientationTest.java,
+	ComponentPlacementTest.java and ComponentSizeTest.java. These tests
+	check if ComponentOrientation subsystem behaviour is correct even
+	when right-to-left orientation is used.
+
 2013-04-29  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* Makefile.am:
diff -r 11353b3c2109 -r 3b76dff83564 Makefile.am
--- a/Makefile.am	Mon Apr 29 13:27:32 2013 +0200
+++ b/Makefile.am	Tue Apr 30 13:18:33 2013 +0200
@@ -546,7 +546,8 @@
 	patches/object-factory-cl-internal.patch \
 	patches/openjdk/8009530-icu_kern_table_support_broken.patch \
 	patches/textLayoutGetCharacterCount.patch \
-	patches/textLayoutLimits.patch
+	patches/textLayoutLimits.patch \
+	patches/componentOrientationTests.patch
 
 if WITH_ALT_HSBUILD
 ICEDTEA_PATCHES += \
diff -r 11353b3c2109 -r 3b76dff83564 patches/componentOrientationTests.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/componentOrientationTests.patch	Tue Apr 30 13:18:33 2013 +0200
@@ -0,0 +1,246 @@
+diff -uN ComponentOrientation/ComponentOrientationTest.java /jck/icedtea6/openjdk/jdk/test/java/awt/ComponentOrientation/ComponentOrientationTest.java
+--- openjdk.old/jdk/test/java/awt/ComponentOrientation/ComponentOrientationTest.java	2013-04-29 15:24:56.000000000 +0200
++++ openjdk/jdk/test/java/awt/ComponentOrientation/ComponentOrientationTest.java	2013-04-29 15:24:56.000000000 +0200
+@@ -0,0 +1,77 @@
++/*
++ * Copyright 2013 Red Hat, Inc. All Rights Reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ */
++
++import java.awt.ComponentOrientation;
++import java.awt.FlowLayout;
++import java.awt.Rectangle;
++
++import javax.swing.JFrame;
++import javax.swing.JLabel;
++
++/**
++ * @test
++ * @run main ComponentOrientationTest
++ * @author Pavel Tisnovsky
++ *
++ * Basic test if component orientation subsystem works properly.
++ */
++public class ComponentOrientationTest {
++
++    public static void main(String[] args) {
++        int[] aligns = {FlowLayout.LEFT, FlowLayout.CENTER, FlowLayout.RIGHT};
++
++        for (int align : aligns) {
++            testComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT, align, true);
++            testComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT, align, false);
++        }
++    }
++
++    private static void testComponentOrientation(ComponentOrientation componentOrientation, int align, boolean firstLabelBeforeSecondOne) {
++        JFrame panel = new JFrame();
++        JLabel label1 = new JLabel("JAVA");
++        JLabel label2 = new JLabel("JAVA");
++
++        panel.setLayout(new FlowLayout(align));
++        panel.applyComponentOrientation(componentOrientation);
++
++        panel.add(label1);
++        panel.add(label2);
++        panel.pack();
++
++        Rectangle rect1 = firstLabelBeforeSecondOne ? label1.getBounds() : label2.getBounds();
++        Rectangle rect2 = firstLabelBeforeSecondOne ? label2.getBounds() : label1.getBounds();
++
++        // test the order of two components
++        if (rect1.x >= rect2.x) {
++            panel.dispose();
++            throw new RuntimeException("Components are positioned in a wrong order!");
++        }
++        if (rect1.x + rect1.width >= rect2.x) {
++            panel.dispose();
++            throw new RuntimeException("Components are positioned on the same place!");
++        }
++
++        // test vertical position of two components
++        if (rect1.y != rect2.y) {
++            panel.dispose();
++            throw new RuntimeException("Components are not positioned  on the same vertical position!");
++        }
++        panel.dispose();
++    }
++}
+diff -uN ComponentOrientation/ComponentPlacementTest.java /jck/icedtea6/openjdk/jdk/test/java/awt/ComponentOrientation/ComponentPlacementTest.java
+--- openjdk.old/jdk/test/java/awt/ComponentOrientation/ComponentPlacementTest.java	2013-04-29 15:24:56.000000000 +0200
++++ openjdk/jdk/test/java/awt/ComponentOrientation/ComponentPlacementTest.java	2013-04-29 15:24:56.000000000 +0200
+@@ -0,0 +1,79 @@
++/*
++ * Copyright 2013 Red Hat, Inc. All Rights Reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ */
++
++import java.awt.ComponentOrientation;
++import java.awt.FlowLayout;
++import java.awt.Rectangle;
++
++import javax.swing.JFrame;
++import javax.swing.JLabel;
++
++/**
++ * @test
++ * @run main ComponentPlacementTest
++ * @author Pavel Tisnovsky
++ *
++ * Basic test if component orientation and component placement subsystem works properly.
++ */
++public class ComponentPlacementTest
++{
++    public static void main(String[] args) {
++        int[] aligns = {FlowLayout.LEFT, FlowLayout.CENTER, FlowLayout.RIGHT};
++        for (int align : aligns) {
++            testComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT, align, true);
++            testComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT, align, false);
++        }
++    }
++
++    private static void testComponentOrientation(ComponentOrientation componentOrientation, int align, boolean firstLabelBeforeSecondOne) {
++        JFrame panel = new JFrame();
++        JLabel label1 = new JLabel("JAVA1");
++        JLabel label2 = new JLabel("JAVA2");
++
++        panel.setLayout(new FlowLayout(align));
++        panel.applyComponentOrientation(componentOrientation);
++
++        panel.add(label1);
++        panel.add(label2);
++        panel.pack();
++
++        Rectangle panelRect = panel.getBounds();
++        Rectangle rect1 = firstLabelBeforeSecondOne ? label1.getBounds() : label2.getBounds();
++        Rectangle rect2 = firstLabelBeforeSecondOne ? label2.getBounds() : label1.getBounds();
++        rect1.x += panelRect.x;
++        rect1.y += panelRect.y;
++        rect2.x += panelRect.x;
++        rect2.y += panelRect.y;
++
++        if (!panelRect.contains(rect1)) {
++            panel.dispose();
++            throw new RuntimeException("First component is not placed inside the frame!");
++        }
++        if (!panelRect.contains(rect2)) {
++            panel.dispose();
++            throw new RuntimeException("Second component is not placed inside the frame!");
++        }
++        if (!rect1.intersection(rect2).isEmpty()) {
++            panel.dispose();
++            throw new RuntimeException("Component intersection detected!");
++        }
++        panel.dispose();
++    }
++
++}
+diff -uN ComponentOrientation/ComponentSizeTest.java /jck/icedtea6/openjdk/jdk/test/java/awt/ComponentOrientation/ComponentSizeTest.java
+--- openjdk.old/jdk/test/java/awt/ComponentOrientation/ComponentSizeTest.java	2013-04-29 15:24:56.000000000 +0200
++++ openjdk/jdk/test/java/awt/ComponentOrientation/ComponentSizeTest.java	2013-04-29 15:24:56.000000000 +0200
+@@ -0,0 +1,78 @@
++/*
++ * Copyright 2013 Red Hat, Inc. All Rights Reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ */
++
++import java.awt.ComponentOrientation;
++import java.awt.FlowLayout;
++import java.awt.Rectangle;
++
++import javax.swing.JFrame;
++import javax.swing.JLabel;
++
++/**
++ * @test
++ * @run main ComponentSizeTest
++ * @author Pavel Tisnovsky
++ *
++ * Basic test if component orientation and component placement subsystem works properly.
++ */
++public class ComponentSizeTest
++{
++    public static void main(String[] args) {
++        int[] aligns = {FlowLayout.LEFT, FlowLayout.CENTER, FlowLayout.RIGHT};
++        for (int align : aligns) {
++            testComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT, align, true);
++            testComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT, align, false);
++        }
++    }
++
++    private static void testComponentOrientation(ComponentOrientation componentOrientation, int align, boolean firstLabelBeforeSecondOne) {
++        JFrame panel = new JFrame();
++        JLabel label1 = new JLabel("JAVA");
++        JLabel label2 = new JLabel("JAVA");
++
++        panel.setLayout(new FlowLayout(align));
++        panel.applyComponentOrientation(componentOrientation);
++
++        panel.add(label1);
++        panel.add(label2);
++        panel.pack();
++
++        Rectangle rect1 = firstLabelBeforeSecondOne ? label1.getBounds() : label2.getBounds();
++        Rectangle rect2 = firstLabelBeforeSecondOne ? label2.getBounds() : label1.getBounds();
++
++        if (rect1.isEmpty()) {
++            panel.dispose();
++            throw new RuntimeException("First component has zero area!");
++        }
++        if (rect2.isEmpty()) {
++            panel.dispose();
++            throw new RuntimeException("Second component has zero area!");
++        }
++        if (rect1.width != rect2.width) {
++            panel.dispose();
++            throw new RuntimeException("Components should have the same width!");
++        }
++        if (rect1.height != rect2.height) {
++            panel.dispose();
++            throw new RuntimeException("Components should have the same height!");
++        }
++        panel.dispose();
++    }
++
++}



More information about the distro-pkg-dev mailing list