Return-Path: Delivered-To: apmail-xmlgraphics-fop-commits-archive@www.apache.org Received: (qmail 74956 invoked from network); 1 Nov 2007 16:13:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Nov 2007 16:13:06 -0000 Received: (qmail 30130 invoked by uid 500); 1 Nov 2007 15:58:00 -0000 Delivered-To: apmail-xmlgraphics-fop-commits-archive@xmlgraphics.apache.org Received: (qmail 30111 invoked by uid 500); 1 Nov 2007 15:58:00 -0000 Mailing-List: contact fop-commits-help@xmlgraphics.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: fop-dev@xmlgraphics.apache.org Delivered-To: mailing list fop-commits@xmlgraphics.apache.org Received: (qmail 30098 invoked by uid 99); 1 Nov 2007 15:58:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Nov 2007 08:58:00 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Nov 2007 15:58:11 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 991121A983A; Thu, 1 Nov 2007 08:57:51 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r591063 - in /xmlgraphics/fop/trunk/test: fotree/unittests/table/ java/org/apache/fop/fo/flow/ Date: Thu, 01 Nov 2007 15:57:51 -0000 To: fop-commits@xmlgraphics.apache.org From: vhennebert@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071101155751.991121A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: vhennebert Date: Thu Nov 1 08:57:50 2007 New Revision: 591063 URL: http://svn.apache.org/viewvc?rev=591063&view=rev Log: Testcases for fo:table-column Added: xmlgraphics/fop/trunk/test/fotree/unittests/table/table-column_column-number.fo (with props) xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/AbstractTableTestCase.java (with props) xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/TableColumnColumnNumberTestCase.java (with props) Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/TooManyColumnsTestCase.java Added: xmlgraphics/fop/trunk/test/fotree/unittests/table/table-column_column-number.fo URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/fotree/unittests/table/table-column_column-number.fo?rev=591063&view=auto ============================================================================== --- xmlgraphics/fop/trunk/test/fotree/unittests/table/table-column_column-number.fo (added) +++ xmlgraphics/fop/trunk/test/fotree/unittests/table/table-column_column-number.fo Thu Nov 1 08:57:50 2007 @@ -0,0 +1,131 @@ + + + + + + + + + + + + Several configurations of tables for testing the setup of + columns. + A simple table to begin. + + + + Header 1.1 + Header 1.2 + + + Footer 1.1 + Footer 1.2 + + + Cell 1.1 + Cell 1.2 + Cell 2.1 + Cell 2.2 + + + + 2 columns, resp. 200pt and 100pt + wide. + + + + + Header 1.1 + Header 1.2 + + + Footer 1.1 + Footer 1.2 + + + Cell 1.1 + Cell 1.2 + Cell 2.1 + Cell 2.2 + + + + 3 unordered columns, resp. 100, 150 and + 200pt wide. + + + + + + Header 1.1 + Header 1.2 + Header 1.3 + + + Footer 1.1 + Footer 1.2 + Footer 1.3 + + + Cell 1.1 + Cell 1.2 + Cell 1.3 + Cell 2.1 + Cell 2.2 + Cell 2.3 + + + + 4 unordered columns, 2nd column implicit, + resp. 100, 125, 150 and 175 pt wide. + + + + + + Header 1.1 + Header 1.2 + Header 1.3 + Header 1.4 + + + Footer 1.1 + Footer 1.2 + Footer 1.3 + Footer 1.4 + + + Cell 1.1 + Cell 1.2 + Cell 1.3 + Cell 1.4 + Cell 2.1 + Cell 2.2 + Cell 2.3 + Cell 2.4 + + + + + + Propchange: xmlgraphics/fop/trunk/test/fotree/unittests/table/table-column_column-number.fo ------------------------------------------------------------------------------ svn:eol-style = native Propchange: xmlgraphics/fop/trunk/test/fotree/unittests/table/table-column_column-number.fo ------------------------------------------------------------------------------ svn:keywords = Id Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/AbstractTableTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/AbstractTableTestCase.java?rev=591063&view=auto ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/AbstractTableTestCase.java (added) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/AbstractTableTestCase.java Thu Nov 1 08:57:50 2007 @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +/* $Id$ */ + +package org.apache.fop.fo.flow; + +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.fo.FOEventHandler; +import org.apache.fop.fotreetest.FOTreeUnitTester; + +/** + * Superclass for testcases related to tables, factoring the common stuff. + */ +abstract class AbstractTableTestCase extends FOTreeUnitTester { + + private FOTreeUnitTester.FOEventHandlerFactory tableHandlerFactory; + + private TableHandler tableHandler; + + public AbstractTableTestCase() throws Exception { + super(); + tableHandlerFactory = new FOEventHandlerFactory() { + public FOEventHandler createFOEventHandler(FOUserAgent foUserAgent) { + tableHandler = new TableHandler(foUserAgent); + return tableHandler; + } + }; + } + + protected void setUp(String filename) throws Exception { + setUp(filename, tableHandlerFactory); + } + + protected TableHandler getTableHandler() { + return tableHandler; + } +} Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/AbstractTableTestCase.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/AbstractTableTestCase.java ------------------------------------------------------------------------------ svn:keywords = Id Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/TableColumnColumnNumberTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/TableColumnColumnNumberTestCase.java?rev=591063&view=auto ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/TableColumnColumnNumberTestCase.java (added) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/TableColumnColumnNumberTestCase.java Thu Nov 1 08:57:50 2007 @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +/* $Id$ */ + +package org.apache.fop.fo.flow; + +import java.util.Iterator; + +import org.apache.fop.datatypes.PercentBaseContext; +import org.apache.fop.fo.FObj; + + +public class TableColumnColumnNumberTestCase extends AbstractTableTestCase { + + /** + * A percentBaseContext that mimics the behaviour of TableLM for computing the widths + * of columns. All what needs to be known is the width of a table unit (as in + * proportional-column-width()). + */ + private class TablePercentBaseContext implements PercentBaseContext { + + private int unitaryWidth; + + void setUnitaryWidth(int unitaryWidth) { + this.unitaryWidth = unitaryWidth; + } + + public int getBaseLength(int lengthBase, FObj fobj) { + return unitaryWidth; + } + } + + private TablePercentBaseContext percentBaseContext = new TablePercentBaseContext(); + + public TableColumnColumnNumberTestCase() throws Exception { + super(); + } + + private void checkColumn(Table t, int number, boolean isDefault, int spans, int repeated, int width) { + TableColumn c = t.getColumn(number - 1); + // TODO a repeated column has a correct number only for its first occurrence +// assertEquals(number, c.getColumnNumber()); + assertEquals(isDefault, c.isDefaultColumn()); + assertEquals(spans, c.getNumberColumnsSpanned()); + assertEquals(repeated, c.getNumberColumnsRepeated()); + assertEquals(width, c.getColumnWidth().getValue(percentBaseContext)); + } + + public void testColumnNumber() throws Exception { + setUp("table/table-column_column-number.fo"); + Iterator tableIter = getTableHandler().getTables().iterator(); + Table t = (Table) tableIter.next(); + assertEquals(2, t.getNumberOfColumns()); + checkColumn(t, 1, false, 1, 2, 100000); + checkColumn(t, 2, false, 1, 2, 100000); + + t = (Table) tableIter.next(); + assertEquals(2, t.getNumberOfColumns()); + checkColumn(t, 1, false, 1, 1, 200000); + checkColumn(t, 2, false, 1, 1, 100000); + + t = (Table) tableIter.next(); + assertEquals(3, t.getNumberOfColumns()); + checkColumn(t, 1, false, 1, 1, 100000); + checkColumn(t, 2, false, 1, 1, 150000); + checkColumn(t, 3, false, 1, 1, 200000); + + t = (Table) tableIter.next(); + percentBaseContext.setUnitaryWidth(125000); + assertEquals(4, t.getNumberOfColumns()); + checkColumn(t, 1, false, 1, 1, 100000); + checkColumn(t, 2, true, 1, 1, 125000); + checkColumn(t, 3, false, 1, 1, 150000); + checkColumn(t, 4, false, 1, 1, 175000); + } +} Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/TableColumnColumnNumberTestCase.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/TableColumnColumnNumberTestCase.java ------------------------------------------------------------------------------ svn:keywords = Id Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/TooManyColumnsTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/TooManyColumnsTestCase.java?rev=591063&r1=591062&r2=591063&view=diff ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/TooManyColumnsTestCase.java (original) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fo/flow/TooManyColumnsTestCase.java Thu Nov 1 08:57:50 2007 @@ -19,27 +19,17 @@ package org.apache.fop.fo.flow; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.fo.FOEventHandler; import org.apache.fop.fo.ValidationException; -import org.apache.fop.fotreetest.FOTreeUnitTester; -public class TooManyColumnsTestCase extends FOTreeUnitTester { - - private FOTreeUnitTester.FOEventHandlerFactory tableHandlerFactory; +public class TooManyColumnsTestCase extends AbstractTableTestCase { public TooManyColumnsTestCase() throws Exception { super(); - tableHandlerFactory = new FOTreeUnitTester.FOEventHandlerFactory() { - public FOEventHandler createFOEventHandler(FOUserAgent ua) { - return new TableHandler(ua); - } - }; } private void launchTest(String filename) throws Exception { try { - setUp(filename, tableHandlerFactory); + setUp(filename); fail(); } catch (ValidationException e) { // TODO check location --------------------------------------------------------------------- To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org