harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r448871 [1/2] - in /incubator/harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/ test/api/java/common/org/apache/harmony/awt/tests/ test/api/java/common/org/apache/harmony/awt/tests/java/ test/api/java/common/org/ap...
Date Fri, 22 Sep 2006 09:28:29 GMT
Author: hindessm
Date: Fri Sep 22 02:28:28 2006
New Revision: 448871

URL: http://svn.apache.org/viewvc?view=rev&rev=448871
Log:
Patches from "[#HARMONY-1530] [classlib][awt] Fonts-related tests are absent
in awt module".

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/FontRenderContextTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/GlyphJustificationInfoTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/GlyphMetricsTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/ImageGraphicAttributeTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/NumericShaperTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/ShapeGraphicAttributeTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/TransformAttributeTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/apache/
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/apache/harmony/
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/apache/harmony/awt/
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/apache/harmony/awt/tests/
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/apache/harmony/awt/tests/java/
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/apache/harmony/awt/tests/java/awt/
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/apache/harmony/awt/tests/java/awt/WinFontMetricsTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/apache/harmony/awt/tests/java/awt/WinFontTest.java   (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java?view=diff&rev=448871&r1=448870&r2=448871
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java Fri Sep 22 02:28:28 2006
@@ -166,7 +166,11 @@
 
             currAttr = attributes.get(TextAttribute.TRANSFORM);
             if ( currAttr != null){
-                this.transformed = !((TransformAttribute)currAttr).getTransform().isIdentity();
+                if (currAttr instanceof TransformAttribute) {
+                    this.transformed = !((TransformAttribute)currAttr).getTransform().isIdentity();
+                } else if (currAttr instanceof AffineTransform) {
+                    this.transformed = !((AffineTransform)currAttr).isIdentity();
+                }
             }
 
         } else {
@@ -535,7 +539,9 @@
                              TextAttribute.POSTURE,
                              TextAttribute.SIZE,
                              TextAttribute.TRANSFORM,
-                             TextAttribute.WEIGHT};
+                             TextAttribute.WEIGHT,
+                             TextAttribute.SUPERSCRIPT,
+                             TextAttribute.WIDTH};
         return attrs;
     }
 

Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/FontRenderContextTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/FontRenderContextTest.java?view=auto&rev=448871
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/FontRenderContextTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/FontRenderContextTest.java Fri Sep 22 02:28:28 2006
@@ -0,0 +1,95 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.awt.tests.java.awt.font;
+
+import java.awt.font.FontRenderContext;
+import java.awt.geom.AffineTransform;
+
+import junit.framework.TestCase;
+
+public class FontRenderContextTest extends TestCase {
+    
+    FontRenderContext frc;
+    AffineTransform at = AffineTransform.getRotateInstance(1);
+    boolean isAA = true;
+    boolean usesFractionalMetrics = false;
+    
+    public FontRenderContextTest(String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        frc = new FontRenderContext(at, isAA, usesFractionalMetrics);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'java.awt.font.FontRenderContext.FontRenderContext(AffineTransform, boolean, boolean)'
+     */
+    public final void testFontRenderContextAffineTransformBooleanBoolean() {
+        
+        assertNotNull(frc);
+        assertEquals("AffineTransform", at, frc.getTransform());
+        assertEquals("isAntialiased", isAA, frc.isAntiAliased());
+        assertEquals("usesFractionalMetrics", usesFractionalMetrics, frc.usesFractionalMetrics());
+        
+        frc = new FontRenderContext(null, isAA, usesFractionalMetrics);
+        assertEquals("AffineTransform", new AffineTransform(), frc.getTransform());
+    }
+
+    /*
+     * Test method for 'java.awt.font.FontRenderContext.equals(Object)'
+     */
+    public final void testEqualsObject() {
+        FontRenderContext frc1 = new FontRenderContext(at, isAA, usesFractionalMetrics);
+        assertTrue(frc.equals((Object)frc1));
+    }
+
+    /*
+     * Test method for 'java.awt.font.FontRenderContext.getTransform()'
+     */
+    public final void testGetTransform() {
+        assertEquals(at, frc.getTransform());
+    }
+
+    /*
+     * Test method for 'java.awt.font.FontRenderContext.equals(FontRenderContext)'
+     */
+    public final void testEqualsFontRenderContext() {
+        FontRenderContext frc1 = new FontRenderContext(at, isAA, usesFractionalMetrics);
+        assertTrue(frc.equals(frc1));
+    }
+
+    /*
+     * Test method for 'java.awt.font.FontRenderContext.usesFractionalMetrics()'
+     */
+    public final void testUsesFractionalMetrics() {
+        assertEquals(usesFractionalMetrics, frc.usesFractionalMetrics());
+    }
+
+    /*
+     * Test method for 'java.awt.font.FontRenderContext.isAntiAliased()'
+     */
+    public final void testIsAntiAliased() {
+        assertEquals(isAA, frc.isAntiAliased());
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/FontRenderContextTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/GlyphJustificationInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/GlyphJustificationInfoTest.java?view=auto&rev=448871
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/GlyphJustificationInfoTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/GlyphJustificationInfoTest.java Fri Sep 22 02:28:28 2006
@@ -0,0 +1,164 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.awt.tests.java.awt.font;
+
+import java.awt.font.GlyphJustificationInfo;
+
+import junit.framework.TestCase;
+
+public class GlyphJustificationInfoTest extends TestCase {
+    float weight = 120; 
+    boolean growAbsorb = true;
+    int growPriority = GlyphJustificationInfo.PRIORITY_KASHIDA; 
+    float growLeftLimit = 20;
+    float growRightLimit = 20;
+    boolean shrinkAbsorb = false;
+    int shrinkPriority = GlyphJustificationInfo.PRIORITY_WHITESPACE;
+    float shrinkLeftLimit = 20;
+    float shrinkRightLimit = 20;
+    
+
+    public GlyphJustificationInfoTest(String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphJustificationInfo.GlyphJustificationInfo(float, boolean, int, float, float, boolean, int, float, float)'
+     */
+    public final void testGlyphJustificationInfo() {
+        GlyphJustificationInfo gji = new GlyphJustificationInfo(weight, growAbsorb, 
+                growPriority, growLeftLimit, growRightLimit, shrinkAbsorb, 
+                shrinkPriority, shrinkLeftLimit, shrinkRightLimit);
+        
+        assertEquals("weight", weight, gji.weight);
+        assertEquals("growAbsorb", growAbsorb, gji.growAbsorb);
+        assertEquals("growPriority", growPriority, gji.growPriority);
+        assertEquals("growLeftLimit", growLeftLimit, gji.growLeftLimit);
+        assertEquals("growRightLimit", growRightLimit, gji.growRightLimit);
+        assertEquals("shrinkAbsorb", shrinkAbsorb, gji.shrinkAbsorb);
+        assertEquals("shrinkPriority", shrinkPriority, gji.shrinkPriority);
+        assertEquals("shrinkLeftLimit", shrinkLeftLimit, gji.shrinkLeftLimit);
+        assertEquals("shrinkRightLimit", shrinkRightLimit, gji.shrinkRightLimit);
+        
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphJustificationInfo.GlyphJustificationInfo(float, boolean, int, float, float, boolean, int, float, float)'
+     */
+    public final void testGlyphJustificationInfo_parametersCheck() {
+        GlyphJustificationInfo gji;
+        
+        // negative weight
+        try{
+            gji = new GlyphJustificationInfo(-1, growAbsorb, 
+                growPriority, growLeftLimit, growRightLimit, shrinkAbsorb, 
+                shrinkPriority, shrinkLeftLimit, shrinkRightLimit);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+        
+        // growPriority illegal level value
+        try{
+            gji = new GlyphJustificationInfo(weight, growAbsorb, 
+                5, growLeftLimit, growRightLimit, shrinkAbsorb, 
+                shrinkPriority, shrinkLeftLimit, shrinkRightLimit);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try{
+            gji = new GlyphJustificationInfo(weight, growAbsorb, 
+                    -1, growLeftLimit, growRightLimit, shrinkAbsorb, 
+                    shrinkPriority, shrinkLeftLimit, shrinkRightLimit);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        // negative growLeftLimit
+        try{
+            gji = new GlyphJustificationInfo(weight, growAbsorb, 
+                growPriority, -1, growRightLimit, shrinkAbsorb, 
+                shrinkPriority, shrinkLeftLimit, shrinkRightLimit);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+        
+        // negative growRightLimit
+        try{
+            gji = new GlyphJustificationInfo(weight, growAbsorb, 
+                growPriority, growLeftLimit, -1, shrinkAbsorb, 
+                shrinkPriority, shrinkLeftLimit, shrinkRightLimit);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        // shrinkPriority illegal level value
+        try{
+            gji = new GlyphJustificationInfo(weight, growAbsorb, 
+                growPriority, growLeftLimit, growRightLimit, shrinkAbsorb, 
+                5, shrinkLeftLimit, shrinkRightLimit);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try{
+            gji = new GlyphJustificationInfo(weight, growAbsorb, 
+                    growPriority, growLeftLimit, growRightLimit, shrinkAbsorb, 
+                    -1, shrinkLeftLimit, shrinkRightLimit);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        // negative shrinkLeftLimit
+        try{
+            gji = new GlyphJustificationInfo(weight, growAbsorb, 
+                growPriority, growLeftLimit, growRightLimit, shrinkAbsorb, 
+                shrinkPriority, -1, shrinkRightLimit);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+        
+        // negative shrinkRightLimit
+        try{
+            gji = new GlyphJustificationInfo(weight, growAbsorb, 
+                growPriority, growLeftLimit, growRightLimit, shrinkAbsorb, 
+                shrinkPriority, -1, shrinkRightLimit);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/GlyphJustificationInfoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/GlyphMetricsTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/GlyphMetricsTest.java?view=auto&rev=448871
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/GlyphMetricsTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/GlyphMetricsTest.java Fri Sep 22 02:28:28 2006
@@ -0,0 +1,198 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.awt.tests.java.awt.font;
+
+import java.awt.font.GlyphMetrics;
+import java.awt.geom.Rectangle2D;
+
+import junit.framework.TestCase;
+
+public class GlyphMetricsTest extends TestCase {
+    float advance = 10;
+    Rectangle2D.Float bounds = new Rectangle2D.Float(2, 2, 15, 15);
+    byte glyphType = GlyphMetrics.COMPONENT;
+    
+    public GlyphMetricsTest(String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.GlyphMetrics(boolean, float, float, Rectangle2D, byte)'
+     */
+    public final void testGlyphMetricsBooleanFloatFloatRectangle2DByte() {
+        boolean horizontal = false;
+        float advanceX = -5;
+        float advanceY = 5;
+        GlyphMetrics gm = new GlyphMetrics(horizontal, advanceX, advanceY, bounds, glyphType);
+        assertEquals(bounds, gm.getBounds2D());
+        assertEquals(advanceY, gm.getAdvance());
+        assertEquals(glyphType, gm.getType());
+        assertEquals(advanceX, gm.getAdvanceX());
+        assertEquals(advanceY, gm.getAdvanceY());
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.GlyphMetrics(float, Rectangle2D, byte)'
+     */
+    public final void testGlyphMetricsFloatRectangle2DByte() {
+        GlyphMetrics gm = new GlyphMetrics(advance, bounds, glyphType);
+        assertEquals(bounds, gm.getBounds2D());
+        assertEquals(advance, gm.getAdvance());
+        assertEquals(glyphType, gm.getType());
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.getBounds2D()'
+     */
+    public final void testGetBounds2D() {
+        GlyphMetrics gm = new GlyphMetrics(advance, bounds, GlyphMetrics.LIGATURE);
+        assertEquals(bounds, gm.getBounds2D());
+        
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.isWhitespace()'
+     */
+    public final void testIsWhitespace() {
+        GlyphMetrics gm = new GlyphMetrics(advance, bounds, GlyphMetrics.WHITESPACE);
+        assertTrue(gm.isWhitespace());
+        
+        gm = new GlyphMetrics(advance, bounds, GlyphMetrics.COMBINING);
+        assertFalse(gm.isWhitespace());
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.isStandard()'
+     */
+    public final void testIsStandard() {
+        GlyphMetrics gm = new GlyphMetrics(advance, bounds, GlyphMetrics.STANDARD);
+        assertTrue(gm.isStandard());
+        
+        gm = new GlyphMetrics(advance, bounds, GlyphMetrics.COMBINING);
+        assertFalse(gm.isStandard());
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.isLigature()'
+     */
+    public final void testIsLigature() {
+        GlyphMetrics gm = new GlyphMetrics(advance, bounds, GlyphMetrics.LIGATURE);
+        assertTrue(gm.isLigature());
+        
+        gm = new GlyphMetrics(advance, bounds, GlyphMetrics.COMBINING);
+        assertFalse(gm.isLigature());
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.isComponent()'
+     */
+    public final void testIsComponent() {
+        GlyphMetrics gm = new GlyphMetrics(advance, bounds, GlyphMetrics.COMPONENT);
+        assertTrue(gm.isComponent());
+        
+        gm = new GlyphMetrics(advance, bounds, GlyphMetrics.LIGATURE);
+        assertFalse(gm.isComponent());
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.isCombining()'
+     */
+    public final void testIsCombining() {
+        GlyphMetrics gm = new GlyphMetrics(advance, bounds, GlyphMetrics.COMBINING);
+        assertTrue(gm.isCombining());
+        
+        gm = new GlyphMetrics(advance, bounds, GlyphMetrics.LIGATURE);
+        assertFalse(gm.isCombining());
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.getType()'
+     */
+    public final void testGetType() {
+        GlyphMetrics gm = new GlyphMetrics(advance, bounds, glyphType);
+        assertEquals(glyphType, gm.getType());
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.getRSB()'
+     */
+    public final void testGetRSB() {
+        GlyphMetrics gm = new GlyphMetrics(advance, bounds, glyphType);
+        assertEquals(bounds.x, gm.getLSB());
+
+        boolean horizontal = false;
+        float advanceX = -5;
+        float advanceY = 5;
+        gm = new GlyphMetrics(horizontal, advanceX, advanceY, bounds, glyphType);
+        assertEquals(bounds.y, gm.getLSB());
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.getLSB()'
+     */
+    public final void testGetLSB() {
+        GlyphMetrics gm = new GlyphMetrics(advance, bounds, glyphType);
+        assertEquals(advance - bounds.x - (float)bounds.getWidth(), gm.getRSB());
+
+        boolean horizontal = false;
+        float advanceX = -5;
+        float advanceY = 5;
+        gm = new GlyphMetrics(horizontal, advanceX, advanceY, bounds, glyphType);
+        assertEquals(advanceY - bounds.y - (float)bounds.getHeight(), gm.getRSB());
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.getAdvanceY()'
+     */
+    public final void testGetAdvanceY() {
+        GlyphMetrics gm = new GlyphMetrics(advance, bounds, glyphType);
+        assertEquals((float)0, gm.getAdvanceY());
+        
+        gm = new GlyphMetrics(true, 0, advance, bounds, glyphType);
+        assertEquals(advance, gm.getAdvanceY());
+
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.getAdvanceX()'
+     */
+    public final void testGetAdvanceX() {
+        GlyphMetrics gm = new GlyphMetrics(advance, bounds, glyphType);
+        assertEquals(advance, gm.getAdvanceX());
+        
+        gm = new GlyphMetrics(true, advance, 0, bounds, glyphType);
+        assertEquals(advance, gm.getAdvanceX());
+
+    }
+
+    /*
+     * Test method for 'java.awt.font.GlyphMetrics.getAdvance()'
+     */
+    public final void testGetAdvance() {
+        GlyphMetrics gm = new GlyphMetrics(advance, bounds, glyphType);
+        assertEquals(advance, gm.getAdvance());
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/GlyphMetricsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/ImageGraphicAttributeTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/ImageGraphicAttributeTest.java?view=auto&rev=448871
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/ImageGraphicAttributeTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/ImageGraphicAttributeTest.java Fri Sep 22 02:28:28 2006
@@ -0,0 +1,229 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.awt.tests.java.awt.font;
+
+import java.awt.Image;
+import java.awt.font.GlyphJustificationInfo;
+import java.awt.font.GraphicAttribute;
+import java.awt.font.ImageGraphicAttribute;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+
+import junit.framework.TestCase;
+
+public class ImageGraphicAttributeTest extends TestCase {
+    ImageGraphicAttribute iga;
+    int width =10;
+    int height = 10;
+    Image img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+    int alignment =  GraphicAttribute.ROMAN_BASELINE;
+    
+    public ImageGraphicAttributeTest(String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'java.awt.font.ImageGraphicAttribute.getAdvance()'
+     */
+    public final void testGetAdvance() {
+        float xOrigin = 5;
+        float yOrigin = 5;
+        float xOrigin1 = 15;
+
+        iga = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin);
+        assertEquals(img.getWidth(null) - xOrigin, iga.getAdvance());
+
+        iga = new ImageGraphicAttribute(img, alignment, xOrigin1, yOrigin);
+        assertEquals((float)0, iga.getAdvance());
+    }
+
+    /*
+     * Test method for 'java.awt.font.ImageGraphicAttribute.getAscent()'
+     */
+    public final void testGetAscent() {
+        float yOrigin = 5;
+        float xOrigin = 5;
+        float yOrigin1 = -5;
+
+        iga = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin);
+        assertEquals(yOrigin, iga.getAscent());
+
+        iga = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin1);
+        assertEquals((float)0, iga.getAscent());
+    }
+
+    /*
+     * Test method for 'java.awt.font.ImageGraphicAttribute.getBounds()'
+     */
+    public final void testGetBounds() {
+        float yOrigin = 5;
+        float xOrigin = 5;
+        iga = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin);
+        assertEquals(new Rectangle2D.Float(-xOrigin, -yOrigin, img.getWidth(null), img.getHeight(null)), 
+                iga.getBounds());
+
+        iga = new ImageGraphicAttribute(img, alignment);
+        assertEquals(new Rectangle2D.Float(0, 0, img.getWidth(null), img.getHeight(null)), 
+                iga.getBounds());
+
+    }
+
+    /*
+     * Test method for 'java.awt.font.ImageGraphicAttribute.getDescent()'
+     */
+    public final void testGetDescent() {
+        float yOrigin = 5;
+        float xOrigin = 5;
+        float yOrigin1 = 15;
+
+        iga = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin);
+        assertEquals(img.getHeight(null) - yOrigin, iga.getDescent());
+
+        iga = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin1);
+        assertEquals((float)0, iga.getDescent());
+        
+    }
+
+    /*
+     * Test method for 'java.awt.font.ImageGraphicAttribute.ImageGraphicAttribute(Image, int, float, float)'
+     */
+    public final void testImageGraphicAttributeImageInt() {
+        ImageGraphicAttribute igAttribute = new ImageGraphicAttribute(img, alignment);
+        assertNotNull(igAttribute);
+        assertEquals(alignment, igAttribute.getAlignment());
+        assertEquals((float)width, igAttribute.getAdvance());
+        assertEquals((float)0, igAttribute.getAscent());
+        assertEquals((float)height, igAttribute.getDescent());
+        assertEquals(new Rectangle2D.Float(0, 0, img.getWidth(null), img.getHeight(null)), 
+                igAttribute.getBounds());
+
+        // illegal alignment value
+        try {
+            iga = new ImageGraphicAttribute(img, -3);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try {
+            iga = new ImageGraphicAttribute(img, 3);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    /*
+     * Test method for 'java.awt.font.ImageGraphicAttribute.ImageGraphicAttribute(Image, int)'
+     */
+    public final void testImageGraphicAttributeImageIntFloatFloat() {
+        float xOrigin = 5;
+        float yOrigin = 5;
+        ImageGraphicAttribute igAttribute = new ImageGraphicAttribute(img, alignment, xOrigin, yOrigin);
+        assertNotNull(igAttribute);
+        assertEquals(alignment, igAttribute.getAlignment());
+        assertEquals((float)width - xOrigin, igAttribute.getAdvance());
+        assertEquals(yOrigin, igAttribute.getAscent());
+        assertEquals((float)height - yOrigin, igAttribute.getDescent());
+        assertEquals(new Rectangle2D.Float(-xOrigin, -yOrigin, img.getWidth(null), img.getHeight(null)), 
+                igAttribute.getBounds());
+
+        // illegal alignment value
+        try {
+            iga = new ImageGraphicAttribute(img, -3, xOrigin, yOrigin);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try {
+            iga = new ImageGraphicAttribute(img, 3, xOrigin, yOrigin);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    /*
+     * Test method for 'java.awt.font.ImageGraphicAttribute.equals(ImageGraphicAttribute)'
+     */
+    public final void testEqualsImageGraphicAttribute() {
+        iga = new ImageGraphicAttribute(img, alignment);
+        ImageGraphicAttribute iga1 = new ImageGraphicAttribute(img, alignment);
+        assertEquals(iga, iga1);
+    }
+
+    /*
+     * Test method for 'java.awt.font.ImageGraphicAttribute.equals(Object)'
+     */
+    public final void testEqualsObject() {
+        iga = new ImageGraphicAttribute(img, alignment);
+        ImageGraphicAttribute iga1 = new ImageGraphicAttribute(img, alignment);
+        assertEquals(iga, (Object)iga1);
+    }
+
+    /*
+     * Test method for 'java.awt.font.GraphicAttribute.getAlignment()'
+     */
+    public final void testGetAlignment() {
+        iga = new ImageGraphicAttribute(img, alignment);
+        assertEquals(alignment, iga.getAlignment());
+    }
+
+    /*
+     * Test method for 'java.awt.font.GraphicAttribute.getJustificationInfo()'
+     */
+    public final void testGetJustificationInfo() {
+        iga = new ImageGraphicAttribute(img, alignment);
+        float advance = iga.getAdvance();
+        GlyphJustificationInfo gji = new GlyphJustificationInfo(
+                advance,
+                false,
+                GlyphJustificationInfo.PRIORITY_INTERCHAR,
+                advance / 3,
+                advance / 3,
+                false,
+                GlyphJustificationInfo.PRIORITY_WHITESPACE,
+                0,
+                0);
+        equalsGlyphJustificationInfo(gji, iga.getJustificationInfo());
+
+    }
+    
+    private boolean equalsGlyphJustificationInfo(GlyphJustificationInfo info1, GlyphJustificationInfo info2){
+        assertEquals("weight", info1.weight, info2.weight);
+        assertEquals("growAbsorb", info1.growAbsorb, info2.growAbsorb);
+        assertEquals("growPriority", info1.growPriority, info2.growPriority);
+        assertEquals("growLeftLimit", info1.growLeftLimit, info2.growLeftLimit);
+        assertEquals("growRightLimit", info1.growRightLimit, info2.growRightLimit);
+        assertEquals("shrinkAbsorb", info1.shrinkAbsorb, info2.shrinkAbsorb);
+        assertEquals("shrinkPriority", info1.shrinkPriority, info2.shrinkPriority);
+        assertEquals("shrinkLeftLimit", info1.shrinkLeftLimit, info2.shrinkLeftLimit);
+        assertEquals("shrinkRightLimit", info1.shrinkRightLimit, info2.shrinkRightLimit);
+        
+        return true;
+    }
+    
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/ImageGraphicAttributeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/NumericShaperTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/NumericShaperTest.java?view=auto&rev=448871
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/NumericShaperTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/NumericShaperTest.java Fri Sep 22 02:28:28 2006
@@ -0,0 +1,357 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.awt.tests.java.awt.font;
+
+import java.awt.font.NumericShaper;
+
+import junit.framework.TestCase;
+
+public class NumericShaperTest extends TestCase {
+
+    private final String testStringNoContext1 = "123456789ab0123456789cde";
+    private final String goldenBengaliStringNoContext1 = "\u09E7\u09E8\u09E9\u09EA\u09EB\u09EC\u09ED\u09EE\u09EFab\u09E6\u09E7\u09E8\u09E9\u09EA\u09EB\u09EC\u09ED\u09EE\u09EFcde";
+
+    // text starts with the nonDigit char and ends with digit char
+    private final String testStringNoContext2 = "abc0123456789de0123456789";
+    private final String goldenBengaliStringNoContext2 = "abc\u09E6\u09E7\u09E8\u09E9\u09EA\u09EB\u09EC\u09ED\u09EE\u09EFde\u09E6\u09E7\u09E8\u09E9\u09EA\u09EB\u09EC\u09ED\u09EE\u09EF";
+
+    // text starts with the BENGALI context digit char and ends with nonDigit char
+    private final String testStringContext1 = "\u0983123456789ab0123456789cde";
+    private final String goldenBengaliDevanagariStringContext1 = "\u0983\u09E7\u09E8\u09E9\u09EA\u09EB\u09EC\u09ED\u09EE\u09EFab0123456789cde";
+
+    // text starts with the nonDigit char and ends with digit char
+    // the first set of digits in text folows by "\u0909" char from the DEVANAGARI script
+    // the second set of digits in text folows by "\u0983" char from the BENGALI script
+    private final String testStringContext2 = "abc\u09090123456789de\u09830123456789";
+    private final String goldenBengaliDevanagariStringContext2 = "abc\u0909\u0966\u0967\u0968\u0969\u096A\u096B\u096C\u096D\u096E\u096Fde\u0983\u09E6\u09E7\u09E8\u09E9\u09EA\u09EB\u09EC\u09ED\u09EE\u09EF";
+
+    private final String testStringContext3 = "0123456789de\u12010123456789";
+    private final String goldenTamilDevanagariStringContext3 = "\u0966\u0967\u0968\u0969\u096A\u096B\u096C\u096D\u096E\u096Fde\u12010123456789";
+
+    public NumericShaperTest(String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'java.awt.font.NumericShaper.equals(Object)'
+     */
+    public final void testEqualsObject() {
+        NumericShaper ns;
+        NumericShaper ns1;
+
+        // Simple shapers are equal
+        ns = NumericShaper.getShaper(NumericShaper.BENGALI);
+        assertTrue("NonContextual object isn't equal to itself", ns.equals(ns));
+
+        ns1 = NumericShaper.getShaper(NumericShaper.BENGALI);
+        assertTrue("NonContextual object isn't equal to the equal object", ns.equals(ns1));
+        
+        ns1 = NumericShaper.getShaper(NumericShaper.ARABIC);
+        assertFalse("Object equals to the different NumericShaper nonContextual object", ns.equals(ns1));
+
+        // Context shapers with default context are equal
+        ns = NumericShaper.getContextualShaper(NumericShaper.BENGALI);
+        assertTrue("Contextual(default) object isn't equal to itself", ns.equals(ns));
+
+        ns1 = NumericShaper.getContextualShaper(NumericShaper.BENGALI);
+        assertTrue("Contextual(default) object isn't equal to the equal object", ns.equals(ns1));
+        
+        ns1 = NumericShaper.getContextualShaper(NumericShaper.ARABIC);
+        assertFalse("Object equals to the different NumericShaper contextual(default) object", ns.equals(ns1));
+
+        // Context shapers with context are equal
+        ns = NumericShaper.getContextualShaper(NumericShaper.ARABIC | NumericShaper.ETHIOPIC, NumericShaper.BENGALI);
+        assertTrue("Contextual object isn't equal to itself", ns.equals(ns));
+
+        ns1 = NumericShaper.getContextualShaper(NumericShaper.ARABIC | NumericShaper.ETHIOPIC, NumericShaper.BENGALI);
+        assertTrue("Contextual object isn't equal to the equal object", ns.equals(ns1));
+        
+        ns1 = NumericShaper.getContextualShaper(NumericShaper.ARABIC | NumericShaper.ETHIOPIC, NumericShaper.EUROPEAN);
+        assertFalse("Object equals to the different NumericShaper contextual object", ns.equals(ns1));
+    }
+
+    /*
+     * Test method for 'java.awt.font.NumericShaper.getContextualShaper(int, int)'
+     */
+    public final void testGetContextualShaperIntInt() {
+        NumericShaper ns;
+        ns = NumericShaper.getContextualShaper(NumericShaper.ARABIC | NumericShaper.TAMIL, NumericShaper.EASTERN_ARABIC);
+        assertNotNull(ns);
+        
+        assertEquals("Ranges are different", NumericShaper.ARABIC | NumericShaper.TAMIL, ns.getRanges());
+        assertTrue("Contextual shaper isContextual() method must return true value", ns.isContextual());
+
+        try{
+            // wrong ranges value
+            ns = NumericShaper.getShaper(13);
+            fail("IlligalArgumentException wasn't thrown with invalid shaper value");
+        } catch (IllegalArgumentException e){
+            
+        }
+    }
+
+    /*
+     * Test method for 'java.awt.font.NumericShaper.getContextualShaper(int)'
+     */
+    public final void testGetContextualShaperInt() {
+        NumericShaper ns;
+        ns = NumericShaper.getContextualShaper(NumericShaper.ARABIC | NumericShaper.TAMIL);
+        assertNotNull(ns);
+        
+        assertEquals("Ranges are not the same", NumericShaper.ARABIC | NumericShaper.TAMIL, ns.getRanges());
+        assertTrue("Default contextual shaper isContextual() method must return true value", ns.isContextual());
+        
+        try{
+            // wrong ranges value
+            ns = NumericShaper.getShaper(13);
+            fail("IlligalArgumentException wasn't thrown with invalid shaper value");
+        } catch (IllegalArgumentException e){
+            
+        }
+
+    }
+
+    /*
+     * Test method for 'java.awt.font.NumericShaper.getRanges()'
+     */
+    public final void testGetRanges() {
+        NumericShaper ns;
+        int ranges;
+        ns = NumericShaper.getShaper(NumericShaper.ARABIC);
+        ranges = ns.getRanges();
+        assertEquals("Simple shaper ranges have differences", NumericShaper.ARABIC, ranges);
+        
+        ns = NumericShaper.getContextualShaper(NumericShaper.ARABIC | NumericShaper.TAMIL, NumericShaper.EASTERN_ARABIC);
+
+        ranges = ns.getRanges();
+        assertEquals("Contextual shaper ranges have differences", NumericShaper.ARABIC | NumericShaper.TAMIL, ranges);
+    }
+
+    /*
+     * Test method for 'java.awt.font.NumericShaper.getShaper(int)'
+     */
+    public final void testGetShaper() {
+        NumericShaper ns;
+        ns = NumericShaper.getShaper(NumericShaper.EASTERN_ARABIC);
+        assertNotNull(ns);
+        
+        assertEquals("Ranges are different", NumericShaper.EASTERN_ARABIC, ns.getRanges());
+        assertFalse("Simple shaper can not be contextual", ns.isContextual());
+        
+        try{
+            ns = NumericShaper.getShaper(NumericShaper.EASTERN_ARABIC | NumericShaper.BENGALI);
+            fail("IlligalArgumentException wasn't thrown with invalid shaper value");
+        } catch (IllegalArgumentException e){
+            
+        }
+    }
+
+    /*
+     * Test method for 'java.awt.font.NumericShaper.isContextual()'
+     */
+    public final void testIsContextual() {
+        NumericShaper ns;
+
+        // Simple shapers 
+        ns = NumericShaper.getShaper(NumericShaper.EASTERN_ARABIC); 
+        assertFalse("Simple shapers may not be contextual", ns.isContextual());
+        
+        // Context shapers with default context
+        ns = NumericShaper.getContextualShaper(NumericShaper.ARABIC | NumericShaper.TAMIL);
+        assertTrue("Default context shapers must be contextual", ns.isContextual());
+            
+        // Context shapers with context 
+        ns = NumericShaper.getContextualShaper(NumericShaper.ARABIC | NumericShaper.TAMIL, NumericShaper.EASTERN_ARABIC);
+        assertTrue("Context shapers must be contextual", ns.isContextual());
+    }
+
+    /*
+     * Test method for 'java.awt.font.NumericShaper.shape(char[], int, int, int)'
+     */
+    public final void testShapeCharArrayIntIntInt() {
+        NumericShaper ns;
+        
+        int context = NumericShaper.DEVANAGARI;
+        
+        // non-contextual shaper - context ignored
+        ns = NumericShaper.getShaper(NumericShaper.BENGALI);
+        
+        // test text that starts with the digit char and ends with nonDigit char 
+        char[] chars = testStringNoContext1.toCharArray(); 
+
+        ns.shape(chars, 0, chars.length, context);
+        
+        for (int i=0; i < chars.length; i++){
+            assertEquals("shaped char at pos[" + i + "] not equals to the golden one", (int)goldenBengaliStringNoContext1.charAt(i), chars[i]);
+        }
+
+        // shaper without default context
+        ns = NumericShaper.getContextualShaper(NumericShaper.TAMIL | NumericShaper.DEVANAGARI);
+        
+        // test text starts with the TAMIL context digit char and ends with nonDigit char
+        chars = testStringContext3.toCharArray(); 
+
+        ns.shape(chars, 0, chars.length, context);
+        
+        for (int i=0; i < chars.length; i++){
+            assertEquals("shaped char at pos[" + i + "] not equals to the golden one", (int)goldenTamilDevanagariStringContext3.charAt(i), chars[i]);
+        }
+
+
+        // offset >= length
+        try{
+            ns.shape(chars, chars.length + 1, 1, context);
+            fail("IndexOutOfBoundsException expected but wasn't thrown!");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+        
+        // offset < 0
+        try{
+            ns.shape(chars, -1, 1, context);
+            fail("IndexOutOfBoundsException expected but wasn't thrown!");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+
+        // offset+length out of range
+        try{
+            ns.shape(chars, chars.length -1, 2);
+            fail("IndexOutOfBoundsException expected but wasn't thrown!");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+
+    }
+
+    /*
+     * Test method for 'java.awt.font.NumericShaper.shape(char[], int, int)'
+     */
+    public final void testShapeCharArrayIntInt() {
+        NumericShaper ns;
+        
+        /*************************/
+        /* Non-Contextual shaper */  
+        /*************************/
+
+        ns = NumericShaper.getShaper(NumericShaper.BENGALI);
+        
+        // test text that starts with the digit char and ends with nonDigit char 
+        char[] chars = testStringNoContext1.toCharArray(); 
+
+        ns.shape(chars, 0, chars.length);
+        
+        for (int i=0; i < chars.length; i++){
+            assertEquals("shaped char at pos[" + i + "] not equals to the golden one", (int)goldenBengaliStringNoContext1.charAt(i), chars[i]);
+        }
+
+        // text starts with the nonDigit char and ends with digit char
+        chars = testStringNoContext2.toCharArray();
+        ns.shape(chars, 0, chars.length);
+        
+        for (int i=0; i < chars.length; i++){
+            assertEquals("shaped char at pos[" + i + "] not equals to the golden one", (int)goldenBengaliStringNoContext2.charAt(i), chars[i]);
+        }
+
+        /*********************/
+        /* Contextual shaper */  
+        /*********************/
+        
+        // shaper without default context
+        ns = NumericShaper.getContextualShaper(NumericShaper.BENGALI | NumericShaper.DEVANAGARI);
+        
+        // test text starts with the BENGALI context digit char and ends with nonDigit char
+        chars = testStringContext1.toCharArray(); 
+
+        ns.shape(chars, 0, chars.length);
+        
+        for (int i=0; i < chars.length; i++){
+            assertEquals("shaped char at pos[" + i + "] not equals to the golden one", (int)goldenBengaliDevanagariStringContext1.charAt(i), chars[i]);
+        }
+
+        // text starts with the nonDigit char and ends with digit char
+        // the first set of digits in text folows by "\u0909" char from the DEVANGARI script
+        // the second set of digits in text folows by "\u0983" char from the BENGALI script
+        chars = testStringContext2.toCharArray(); 
+
+        ns.shape(chars, 0, chars.length);
+        
+        for (int i=0; i < chars.length; i++){
+            assertEquals("shaped char at pos[" + i + "] not equals to the golden one", (int)goldenBengaliDevanagariStringContext2.charAt(i), chars[i]);
+        }
+
+        // shaper with acceptable default context
+        ns = NumericShaper.getContextualShaper(NumericShaper.TAMIL | NumericShaper.DEVANAGARI, NumericShaper.DEVANAGARI);
+        
+        // text starts with Digit char and ends with digit char
+        // These digits must be replaced with default context digits
+        chars = testStringContext3.toCharArray(); 
+        
+        ns.shape(chars, 0, chars.length);
+        
+        for (int i=0; i < chars.length; i++){
+            assertEquals("shaped char at pos[" + i + "] not equals to the golden one", (int)goldenTamilDevanagariStringContext3.charAt(i), chars[i]);
+        }
+        
+        // shaper with nonacceptable default context
+        ns = NumericShaper.getContextualShaper(NumericShaper.TAMIL | NumericShaper.DEVANAGARI, NumericShaper.KANNADA);
+        
+        // text starts with Digit char and ends with digit char
+        // All digits must stay without changes
+        chars = testStringContext3.toCharArray(); 
+        
+        ns.shape(chars, 0, chars.length);
+        
+        for (int i=0; i < chars.length; i++){
+            assertEquals("shaped char at pos[" + i + "] not equals to the golden one", (int)testStringContext3.charAt(i), chars[i]);
+        }
+        
+        // offset >= length
+        try{
+            ns.shape(chars, chars.length + 1, 1);
+            fail("IndexOutOfBoundsException expected but wasn't thrown!");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+        
+        // offset < 0
+        try{
+            ns.shape(chars, -1, 1);
+            fail("IndexOutOfBoundsException expected but wasn't thrown!");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+
+        // offset+length out of range
+        try{
+            ns.shape(chars, chars.length -1, 2);
+            fail("IndexOutOfBoundsException expected but wasn't thrown!");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+        
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/NumericShaperTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/ShapeGraphicAttributeTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/ShapeGraphicAttributeTest.java?view=auto&rev=448871
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/ShapeGraphicAttributeTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/ShapeGraphicAttributeTest.java Fri Sep 22 02:28:28 2006
@@ -0,0 +1,194 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.awt.tests.java.awt.font;
+
+import java.awt.Shape;
+import java.awt.font.GlyphJustificationInfo;
+import java.awt.font.GraphicAttribute;
+import java.awt.font.ShapeGraphicAttribute;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import junit.framework.TestCase;
+
+public class ShapeGraphicAttributeTest extends TestCase {
+    ShapeGraphicAttribute sga;
+    float width = 10;
+    float height = 10;
+    float xOrigin = 5;
+    float yOrigin = 5;
+    boolean stroke = ShapeGraphicAttribute.FILL;
+    
+    Shape shape = new Rectangle2D.Float(xOrigin, yOrigin, width, height);
+    int alignment =  GraphicAttribute.ROMAN_BASELINE;
+
+    public ShapeGraphicAttributeTest(String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'java.awt.font.ShapeGraphicAttribute.getAdvance()'
+     */
+    public final void testGetAdvance() {
+
+        sga = new ShapeGraphicAttribute(shape, alignment, stroke);
+        assertEquals((float)shape.getBounds2D().getWidth() + xOrigin, sga.getAdvance());
+        
+        Shape trShape = AffineTransform.getTranslateInstance(-20, 0).createTransformedShape(shape);
+        sga = new ShapeGraphicAttribute(trShape, alignment, stroke);
+        assertEquals((float)0, sga.getAdvance());
+    }
+
+    /*
+     * Test method for 'java.awt.font.ShapeGraphicAttribute.getAscent()'
+     */
+    public final void testGetAscent() {
+        sga = new ShapeGraphicAttribute(shape, alignment, stroke);
+        assertEquals((float)0, sga.getAscent());
+
+        Shape trShape = AffineTransform.getTranslateInstance(0, -30).createTransformedShape(shape);
+        sga = new ShapeGraphicAttribute(trShape, alignment, stroke);
+        assertEquals(-(float)trShape.getBounds2D().getMinY(), sga.getAscent());
+
+    }
+
+    /*
+     * Test method for 'java.awt.font.ShapeGraphicAttribute.getBounds()'
+     */
+    public final void testGetBounds() {
+        sga = new ShapeGraphicAttribute(shape, alignment, ShapeGraphicAttribute.FILL);
+        Rectangle2D.Float bounds = (Rectangle2D.Float)shape.getBounds2D();
+        assertEquals(bounds, sga.getBounds());
+
+    }
+
+    /*
+     * Test method for 'java.awt.font.ShapeGraphicAttribute.getDescent()'
+     */
+    public final void testGetDescent() {
+        sga = new ShapeGraphicAttribute(shape, alignment, stroke);
+        assertEquals((float)shape.getBounds2D().getMinY() + height, sga.getDescent());
+
+        Shape trShape = AffineTransform.getTranslateInstance(0, -30).createTransformedShape(shape);
+        sga = new ShapeGraphicAttribute(trShape, alignment, stroke);
+        assertEquals((float)0, sga.getDescent());
+    }
+
+    /*
+     * Test method for 'java.awt.font.ShapeGraphicAttribute.ShapeGraphicAttribute(Shape, int, boolean)'
+     */
+    public final void testShapeGraphicAttribute() {
+        ShapeGraphicAttribute shAttribute = new ShapeGraphicAttribute(shape, alignment, stroke);
+        assertNotNull(shAttribute);
+        assertEquals(alignment, shAttribute.getAlignment());
+        assertEquals((float)shape.getBounds2D().getMaxX(), shAttribute.getAdvance());
+        assertEquals((float)0, shAttribute.getAscent());
+        assertEquals((float)shape.getBounds2D().getMinY() + height, shAttribute.getDescent());
+
+        Rectangle2D.Float bounds = (Rectangle2D.Float)shape.getBounds2D();
+        if (stroke == ShapeGraphicAttribute.STROKE){
+            bounds.width++;
+            bounds.height++;
+        }
+        assertEquals(bounds, shAttribute.getBounds());
+
+        // illegal alignment value
+        try {
+            sga = new ShapeGraphicAttribute(shape, -3, stroke);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try {
+            sga = new ShapeGraphicAttribute(shape, 3, stroke);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    /*
+     * Test method for 'java.awt.font.ShapeGraphicAttribute.equals(ShapeGraphicAttribute)'
+     */
+    public final void testEqualsShapeGraphicAttribute() {
+        sga = new ShapeGraphicAttribute(shape, alignment, stroke);
+        ShapeGraphicAttribute sga1 = new ShapeGraphicAttribute(shape, alignment, stroke);
+        assertTrue(sga.equals(sga1));
+    }
+
+    /*
+     * Test method for 'java.awt.font.ShapeGraphicAttribute.equals(Object)'
+     */
+    public final void testEqualsObject() {
+        sga = new ShapeGraphicAttribute(shape, alignment, stroke);
+        ShapeGraphicAttribute sga1 = new ShapeGraphicAttribute(shape, alignment, stroke);
+        assertTrue(sga.equals((Object)sga1));
+    }
+
+    /*
+     * Test method for 'java.awt.font.GraphicAttribute.getAlignment()'
+     */
+    public final void testGetAlignment() {
+        sga = new ShapeGraphicAttribute(shape, alignment, stroke);
+        assertEquals(alignment, sga.getAlignment());
+    }
+
+    /*
+     * Test method for 'java.awt.font.GraphicAttribute.getJustificationInfo()'
+     */
+    public final void testGetJustificationInfo() {
+        sga = new ShapeGraphicAttribute(shape, alignment, stroke);
+        float advance = sga.getAdvance();
+        GlyphJustificationInfo gji = new GlyphJustificationInfo(
+                advance,
+                false,
+                GlyphJustificationInfo.PRIORITY_INTERCHAR,
+                advance / 3,
+                advance / 3,
+                false,
+                GlyphJustificationInfo.PRIORITY_WHITESPACE,
+                0,
+                0);
+        equalsGlyphJustificationInfo(gji, sga.getJustificationInfo());
+
+    }
+
+    private boolean equalsGlyphJustificationInfo(GlyphJustificationInfo info1, GlyphJustificationInfo info2){
+        assertEquals("weight", info1.weight, info2.weight);
+        assertEquals("growAbsorb", info1.growAbsorb, info2.growAbsorb);
+        assertEquals("growPriority", info1.growPriority, info2.growPriority);
+        assertEquals("growLeftLimit", info1.growLeftLimit, info2.growLeftLimit);
+        assertEquals("growRightLimit", info1.growRightLimit, info2.growRightLimit);
+        assertEquals("shrinkAbsorb", info1.shrinkAbsorb, info2.shrinkAbsorb);
+        assertEquals("shrinkPriority", info1.shrinkPriority, info2.shrinkPriority);
+        assertEquals("shrinkLeftLimit", info1.shrinkLeftLimit, info2.shrinkLeftLimit);
+        assertEquals("shrinkRightLimit", info1.shrinkRightLimit, info2.shrinkRightLimit);
+        
+        return true;
+    }
+    
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/ShapeGraphicAttributeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/TransformAttributeTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/TransformAttributeTest.java?view=auto&rev=448871
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/TransformAttributeTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/TransformAttributeTest.java Fri Sep 22 02:28:28 2006
@@ -0,0 +1,80 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.awt.tests.java.awt.font;
+
+import java.awt.font.TransformAttribute;
+import java.awt.geom.AffineTransform;
+
+import junit.framework.TestCase;
+
+public class TransformAttributeTest extends TestCase {
+
+    public TransformAttributeTest(String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'java.awt.font.TransformAttribute.TransformAttribute(AffineTransform)'
+     */
+    public final void testTransformAttribute() {
+        TransformAttribute ta;
+        AffineTransform at = AffineTransform.getRotateInstance(1);
+        ta = new TransformAttribute(at);
+        assertEquals(at, ta.getTransform());
+
+        // check if transform cloned
+        at.translate(10, 10);
+        assertFalse(at.equals(ta.getTransform()));
+        
+        try{
+            ta = new TransformAttribute(null);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    /*
+     * Test method for 'java.awt.font.TransformAttribute.getTransform()'
+     */
+    public final void testGetTransform() {
+        AffineTransform at = AffineTransform.getRotateInstance(1);
+        TransformAttribute ta = new TransformAttribute(at);
+        assertEquals(at, ta.getTransform());
+    }
+
+    /*
+     * Test method for 'java.awt.font.TransformAttribute.isIdentity()'
+     */
+    public final void testIsIdentity() {
+        TransformAttribute ta = new TransformAttribute(new AffineTransform());
+        assertTrue(ta.isIdentity());
+
+        AffineTransform at = AffineTransform.getRotateInstance(1);
+        ta = new TransformAttribute(at);
+        assertFalse(ta.isIdentity());
+}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/TransformAttributeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/apache/harmony/awt/tests/java/awt/WinFontMetricsTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/apache/harmony/awt/tests/java/awt/WinFontMetricsTest.java?view=auto&rev=448871
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/apache/harmony/awt/tests/java/awt/WinFontMetricsTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/apache/harmony/awt/tests/java/awt/WinFontMetricsTest.java Fri Sep 22 02:28:28 2006
@@ -0,0 +1,399 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.awt.tests.java.awt;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Toolkit;
+import java.awt.font.FontRenderContext;
+import java.awt.font.LineMetrics;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+
+import junit.framework.TestCase;
+
+/*
+ *  This test is valid only on Windows!
+ */
+
+public class WinFontMetricsTest extends TestCase {
+    Font physicalFont;
+    Font dialogFont;
+    FontRenderContext frc = new FontRenderContext(null, false, false);
+    Graphics g;
+    FontMetrics fm;
+    
+    public void setUp() throws Exception{
+        super.setUp();
+        physicalFont = new Font("Arial", Font.PLAIN, 12);
+        dialogFont = new Font("dialog", Font.PLAIN, 12);
+        
+        fm = Toolkit.getDefaultToolkit().getFontMetrics(physicalFont);
+        g = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB).getGraphics();
+        g.setFont(physicalFont);
+    }
+    
+    public WinFontMetricsTest(String name) {
+        super(name);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.FontMetrics(Font)'
+     */
+    public final void testFontMetrics() {
+        FontMetrics fMetrics = Toolkit.getDefaultToolkit().getFontMetrics(physicalFont);
+        assertNotNull(fMetrics);
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getFont()'
+     */
+    public final void testGetFont() {
+        assertEquals(physicalFont, fm.getFont());
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getHeight()'
+     */
+    public final void testGetHeight() {
+        int height = 15; 
+        assertEquals(height, fm.getHeight());
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getAscent()'
+     */
+    public final void testGetAscent() {
+        int ascent = 12; 
+        assertEquals(ascent, fm.getAscent());
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getDescent()'
+     */
+    public final void testGetDescent() {
+        int descent = 3; 
+        assertEquals(descent, fm.getDescent());
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getLeading()'
+     */
+    public final void testGetLeading() {
+        int leading = 0; 
+        assertEquals(leading, fm.getLeading());
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getLineMetrics(CharacterIterator, int, int, Graphics)'
+     */
+    public final void testGetLineMetricsCharacterIteratorIntIntGraphics() {
+        CharacterIterator ci = new StringCharacterIterator("Only Hello world! metrics");
+
+        LineMetrics lm = fm.getLineMetrics(ci, 5, 17, g);
+
+        lmEquals(physicalFont.getLineMetrics(ci, 5, 17, ((Graphics2D)g).getFontRenderContext()), lm);
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getLineMetrics(String, Graphics)'
+     */
+    public final void testGetLineMetricsStringGraphics() {
+        String str = "Hello world!";
+        LineMetrics lm = fm.getLineMetrics(str, g);
+
+        lmEquals(physicalFont.getLineMetrics(str, ((Graphics2D)g).getFontRenderContext()), lm);
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getLineMetrics(char[], int, int, Graphics)'
+     */
+    public final void testGetLineMetricsCharArrayIntIntGraphics() {
+        char[] chars = new char[]{'H','e','l','l','o',' ','w','o','r','l','d','!'};
+
+        LineMetrics lm = fm.getLineMetrics(chars, 0, chars.length, g);
+
+        lmEquals(physicalFont.getLineMetrics(chars, 0, chars.length, ((Graphics2D) g)
+                .getFontRenderContext()), lm);
+
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getLineMetrics(String, int, int, Graphics)'
+     */
+    public final void testGetLineMetricsStringIntIntGraphics() {
+        String str = "Only Hello world! metrics";
+
+        LineMetrics lm = fm.getLineMetrics(str, 5, 17, g);
+
+        lmEquals(physicalFont.getLineMetrics(str, 5, 17, ((Graphics2D) g)
+                .getFontRenderContext()), lm);
+
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getStringBounds(CharacterIterator, int, int, Graphics)'
+     */
+    public final void testGetStringBoundsCharacterIteratorIntIntGraphics() {
+        String str = "toremove-This is a very long string for getting bounds!-toremove";
+        int width = 237;
+        CharacterIterator ci = new StringCharacterIterator(str);
+
+        Rectangle2D rect = fm.getStringBounds(ci, 9, 55, g);
+        LineMetrics lm = fm.getLineMetrics(" ", g);
+        assertNotNull(rect);
+        assertEquals(rect, new Rectangle2D.Float(0, -lm.getAscent(), width, lm.getHeight()));
+        
+        try{
+            rect = fm.getStringBounds(ci, 10, 155, g);
+            fail("IndexOutOfBoundsException wasn't thrown, when end index is more than count of elements in CharacterIterator");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+        
+        try{
+            rect = fm.getStringBounds(ci, -1, 55, g);
+            fail("IndexOutOfBoundsException wasn't thrown, when initial offset < 0");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+
+        try{
+            rect = fm.getStringBounds(ci, 45, 40, g);
+            fail("IndexOutOfBoundsException wasn't thrown, when end index is lesser than start index");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+
+
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getStringBounds(String, int, int, Graphics)'
+     */
+    public final void testGetStringBoundsStringIntIntGraphics() {
+        String str = "toremove-This is a very long string for getting bounds!-toremove";
+        int width = 237;
+        Rectangle2D rect = fm.getStringBounds(str, 9, 55, g);
+        LineMetrics lm = fm.getLineMetrics(" ", g);
+        assertNotNull(rect);
+        assertEquals(rect, new Rectangle2D.Float(0, -lm.getAscent(), width, lm.getHeight()));
+
+        try{
+            rect = fm.getStringBounds(str, 10, 65, g);
+            fail("IndexOutOfBoundsException wasn't thrown, when end index is more than number of chars in string");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+        
+        try{
+            rect = fm.getStringBounds(str, -1, 55, g);
+            fail("IndexOutOfBoundsException wasn't thrown, when initial offset < 0");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+
+        try{
+            rect = fm.getStringBounds(str, 45, 10, g);
+            fail("IndexOutOfBoundsException wasn't thrown, when end index is less than start index");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getStringBounds(char[], int, int, Graphics)'
+     */
+    public final void testGetStringBoundsCharArrayIntIntGraphics() {
+        String str = "toremove-This is a very long string for getting bounds!-toremove";
+        char[] chars = str.toCharArray();
+        int width = 237;
+        Rectangle2D rect = fm.getStringBounds(chars, 9, 55, g);
+        LineMetrics lm = fm.getLineMetrics(" ", g);
+        assertNotNull(rect);
+        assertEquals(rect, new Rectangle2D.Float(0, -lm.getAscent(), width, lm.getHeight()));
+        
+        try{
+            rect = fm.getStringBounds(chars, 10, 155, g);
+            fail("IndexOutOfBoundsException wasn't thrown, when end index is more than count of elements in CharacterIterator");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+        
+        try{
+            rect = fm.getStringBounds(chars, -1, 55, g);
+            fail("IndexOutOfBoundsException wasn't thrown, when initial offset < 0");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+
+        try{
+            rect = fm.getStringBounds(chars, 45, 40, g);
+            fail("IndexOutOfBoundsException wasn't thrown, when end index is less than start index");
+        } catch (IndexOutOfBoundsException e){
+            // expected
+        }
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getStringBounds(String, Graphics)'
+     */
+    public final void testGetStringBoundsStringGraphics() {
+        String str = "This is a very long string for getting bounds!";
+        int width = 237;
+        Rectangle2D rect = fm.getStringBounds(str, g);
+        LineMetrics lm = fm.getLineMetrics(" ", g);
+        assertNotNull(rect);
+        assertEquals(new Rectangle2D.Float(0, -lm.getAscent(), width, lm.getHeight()), rect);
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.hasUniformLineMetrics()'
+     */
+    public final void testHasUniformLineMetrics() {
+        // !! fails on RI, seems it is a bug in RI, see the spec
+        assertTrue(fm.hasUniformLineMetrics());
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.bytesWidth(byte[], int, int)'
+     */
+    public final void testBytesWidth() {
+        byte[] chars = new byte[]{'M','P'};
+        int width = fm.bytesWidth(chars, 0, 2);
+        assertEquals(17, width);
+
+        assertEquals(9, fm.bytesWidth(chars, 0, 1));
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.charsWidth(char[], int, int)'
+     */
+    public final void testCharsWidth() {
+        char[] chars = new char[]{'M','P'};
+        int width = fm.charsWidth(chars, 0, 2);
+        assertEquals(17, width);
+
+        assertEquals(9, fm.charsWidth(chars, 0, 1));
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.charWidth(int)'
+     */
+    public final void testCharWidthInt() {
+        int widthOf_a = 7;
+        int chr = 'a';
+        assertEquals(widthOf_a, fm.charWidth(chr));
+        chr = '\u0003';
+        int defaultWidth = 9;
+        assertEquals(defaultWidth, fm.charWidth(chr));
+
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.charWidth(char)'
+     */
+    public final void testCharWidthChar() {
+        int widthOf_a = 7;
+        char chr = 'a';
+        assertEquals(widthOf_a, fm.charWidth(chr));
+        chr = '\u0003';
+        int defaultWidth = 9;
+        assertEquals(defaultWidth, fm.charWidth(chr));
+
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getMaxAscent()'
+     */
+    public final void testGetMaxAscent() {
+        int maxAscent = 12;
+        assertEquals(maxAscent, fm.getMaxAscent());
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getMaxDecent()'
+     */
+    public final void testGetMaxDecent() {
+        int maxDecent = 3;
+        assertEquals(maxDecent, fm.getMaxDecent());
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getMaxDescent()'
+     */
+    public final void testGetMaxDescent() {
+        int maxDescent = 3;
+        assertEquals(maxDescent, fm.getMaxDescent());
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.getWidths()'
+     */
+    public final void testGetWidths() {
+        int[] widths;
+        int[] values = new int[]{3,3,4,7,7,11,8,2,4,4,
+                        5,7,3,4,3,3,7,7,7,7};
+        widths = fm.getWidths();
+        
+        assertNotNull(widths);
+        assertEquals(widths.length, 256);
+        
+        for (int i = 0x20; i < 0x34; i++){
+            assertEquals("widths[" + i + "]=" + widths[i]+ "!=" +values[i-0x20], widths[i], values[i-0x20]);
+        }
+        
+    }
+
+    /*
+     * Test method for 'java.awt.FontMetrics.stringWidth(String)'
+     */
+    public final void testStringWidth() {
+        int width = 131;
+        String str = "Hello world string width!";
+        assertEquals(width, fm.stringWidth(str));
+
+    }
+    
+    private boolean lmEquals(LineMetrics lm1, LineMetrics lm2){
+        assertEquals("Ascent", lm1.getAscent(), lm2.getAscent());
+        assertEquals("Baseline Index", lm1.getBaselineIndex(), lm2.getBaselineIndex());
+        float[] offsets = lm2.getBaselineOffsets(); 
+        assertNotNull(offsets);
+        for (int i=0; i < offsets.length; i++){
+            assertEquals("Baseline offset[" + i + "]", lm1.getBaselineOffsets()[i], offsets[i]);
+        }
+        assertEquals("Descent", lm1.getDescent(), lm2.getDescent());
+        assertEquals("Height", lm1.getHeight(), lm2.getHeight());
+        assertEquals("Leading", lm1.getLeading(), lm2.getLeading());
+        assertEquals("NumChars", lm1.getNumChars(), lm2.getNumChars());
+        assertEquals("Strikethrough offset", lm1.getStrikethroughOffset(), lm2.getStrikethroughOffset());
+        assertEquals("Strikethrough thickness", lm1.getStrikethroughThickness(), lm2.getStrikethroughThickness());
+        assertEquals("Underline offset", lm1.getUnderlineOffset(), lm2.getUnderlineOffset());
+        assertEquals("Underline thickness", lm1.getUnderlineThickness(), lm2.getUnderlineThickness());
+
+        return true;
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/windows/org/apache/harmony/awt/tests/java/awt/WinFontMetricsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message