Return-Path: Delivered-To: apmail-poi-commits-archive@locus.apache.org Received: (qmail 24406 invoked from network); 21 Jan 2009 02:16:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Jan 2009 02:16:23 -0000 Received: (qmail 63524 invoked by uid 500); 21 Jan 2009 02:16:23 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 63483 invoked by uid 500); 21 Jan 2009 02:16:22 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 63474 invoked by uid 99); 21 Jan 2009 02:16:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jan 2009 18:16:22 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Jan 2009 02:16:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A1790238896B; Tue, 20 Jan 2009 18:16:01 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r736193 - /poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java Date: Wed, 21 Jan 2009 02:16:01 -0000 To: commits@poi.apache.org From: josh@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090121021601.A1790238896B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: josh Date: Tue Jan 20 18:16:01 2009 New Revision: 736193 URL: http://svn.apache.org/viewvc?rev=736193&view=rev Log: Removed System.out.println and compiler warnings from test code Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java?rev=736193&r1=736192&r2=736193&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java Tue Jan 20 18:16:01 2009 @@ -27,43 +27,38 @@ * * @author Glen Stampoultzis (glens at apache.org) */ -public class TestEscherGraphics2d extends TestCase -{ - private HSSFShapeGroup escherGroup; - private EscherGraphics2d graphics; - - protected void setUp() throws Exception - { - super.setUp(); - - HSSFWorkbook workbook = new HSSFWorkbook(); - HSSFSheet sheet = workbook.createSheet("test"); - escherGroup = sheet.createDrawingPatriarch().createGroup(new HSSFClientAnchor(0,0,1023,255,(short)0,0,(short) 0,0)); - escherGroup = new HSSFShapeGroup(null, new HSSFChildAnchor()); - EscherGraphics g = new EscherGraphics(this.escherGroup, workbook, Color.black, 1.0f); - graphics = new EscherGraphics2d(g); - - } - - public void testDrawString() throws Exception - { - graphics.drawString("This is a test", 10, 10); - HSSFTextbox t = (HSSFTextbox) escherGroup.getChildren().get(0); - assertEquals("This is a test", t.getString().getString().toString()); +public final class TestEscherGraphics2d extends TestCase { + private HSSFShapeGroup escherGroup; + private EscherGraphics2d graphics; + + protected void setUp() { + + HSSFWorkbook workbook = new HSSFWorkbook(); + HSSFSheet sheet = workbook.createSheet("test"); + escherGroup = sheet.createDrawingPatriarch().createGroup(new HSSFClientAnchor(0,0,1023,255,(short)0,0,(short) 0,0)); + escherGroup = new HSSFShapeGroup(null, new HSSFChildAnchor()); + EscherGraphics g = new EscherGraphics(this.escherGroup, workbook, Color.black, 1.0f); + graphics = new EscherGraphics2d(g); + } + + public void testDrawString() { + graphics.drawString("This is a test", 10, 10); + HSSFTextbox t = (HSSFTextbox) escherGroup.getChildren().get(0); + assertEquals("This is a test", t.getString().getString().toString()); // Check that with a valid font, it's still ok Font font = new Font("Forte", Font.PLAIN, 12); graphics.setFont(font); - graphics.drawString("This is another test", 10, 10); + graphics.drawString("This is another test", 10, 10); // And test with ones that need the style appending font = new Font("dialog", Font.PLAIN, 12); graphics.setFont(font); - graphics.drawString("This is another test", 10, 10); + graphics.drawString("This is another test", 10, 10); font = new Font("dialog", Font.BOLD, 12); graphics.setFont(font); - graphics.drawString("This is another test", 10, 10); + graphics.drawString("This is another test", 10, 10); // But with an invalid font, we get an exception font = new Font("IamAmadeUPfont", Font.PLAIN, 22); @@ -72,60 +67,59 @@ graphics.drawString("This is another test", 10, 10); fail(); } catch(IllegalArgumentException e) { + // expected } - } + } - public void testFillRect() throws Exception - { - graphics.fillRect( 10, 10, 20, 20 ); - HSSFSimpleShape s = (HSSFSimpleShape) escherGroup.getChildren().get(0); - assertEquals(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE, s.getShapeType()); - assertEquals(10, s.getAnchor().getDx1()); - assertEquals(10, s.getAnchor().getDy1()); - assertEquals(30, s.getAnchor().getDy2()); - assertEquals(30, s.getAnchor().getDx2()); - } - - public void testGetFontMetrics() throws Exception - { - FontMetrics fontMetrics = graphics.getFontMetrics(graphics.getFont()); - if (graphics.getFont().toString().indexOf("dialog") != -1 || graphics.getFont().toString().indexOf("Dialog") != -1) // if dialog is returned we can't run the test properly. - return; - assertEquals(7, fontMetrics.charWidth('X')); - assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", fontMetrics.getFont().toString()); - } - - public void testSetFont() throws Exception - { - Font f = new Font("Helvetica", 0, 12); - graphics.setFont(f); - assertEquals(f, graphics.getFont()); - } - - public void testSetColor() throws Exception - { - graphics.setColor(Color.red); - assertEquals(Color.red, graphics.getColor()); - } - - public void testGetFont() throws Exception - { - Font f = graphics.getFont(); - if (graphics.getFont().toString().indexOf("dialog") != -1 || graphics.getFont().toString().indexOf("Dialog") != -1) // if dialog is returned we can't run the test properly. - return; - - assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.toString()); - } - - public void testDraw() throws Exception - { - graphics.draw(new Line2D.Double(10,10,20,20)); - HSSFSimpleShape s = (HSSFSimpleShape) escherGroup.getChildren().get(0); - assertTrue(s.getShapeType() == HSSFSimpleShape.OBJECT_TYPE_LINE); - assertEquals(10, s.getAnchor().getDx1()); - assertEquals(10, s.getAnchor().getDy1()); - assertEquals(20, s.getAnchor().getDx2()); - assertEquals(20, s.getAnchor().getDy2()); - System.out.println("s = " + s); - } + public void testFillRect() { + graphics.fillRect( 10, 10, 20, 20 ); + HSSFSimpleShape s = (HSSFSimpleShape) escherGroup.getChildren().get(0); + assertEquals(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE, s.getShapeType()); + assertEquals(10, s.getAnchor().getDx1()); + assertEquals(10, s.getAnchor().getDy1()); + assertEquals(30, s.getAnchor().getDy2()); + assertEquals(30, s.getAnchor().getDx2()); + } + + public void testGetFontMetrics() { + FontMetrics fontMetrics = graphics.getFontMetrics(graphics.getFont()); + if (isDialogPresent()) // if dialog is returned we can't run the test properly. + return; + assertEquals(7, fontMetrics.charWidth('X')); + assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", fontMetrics.getFont().toString()); + } + + public void testSetFont() { + Font f = new Font("Helvetica", 0, 12); + graphics.setFont(f); + assertEquals(f, graphics.getFont()); + } + + public void testSetColor() { + graphics.setColor(Color.red); + assertEquals(Color.red, graphics.getColor()); + } + + public void testGetFont() { + Font f = graphics.getFont(); + if (isDialogPresent()) // if dialog is returned we can't run the test properly. + return; + + assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.toString()); + } + + private boolean isDialogPresent() { + String fontDebugStr = graphics.getFont().toString(); + return fontDebugStr.indexOf("dialog") != -1 || fontDebugStr.indexOf("Dialog") != -1; + } + + public void testDraw() { + graphics.draw(new Line2D.Double(10,10,20,20)); + HSSFSimpleShape s = (HSSFSimpleShape) escherGroup.getChildren().get(0); + assertTrue(s.getShapeType() == HSSFSimpleShape.OBJECT_TYPE_LINE); + assertEquals(10, s.getAnchor().getDx1()); + assertEquals(10, s.getAnchor().getDy1()); + assertEquals(20, s.getAnchor().getDx2()); + assertEquals(20, s.getAnchor().getDy2()); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org