1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /* $Id$ */ 19 20 package org.apache.fop.layoutmgr.table; 21 22 import org.junit.Test; 23 24 import static org.mockito.Mockito.mock; 25 import static org.mockito.Mockito.verify; 26 import static org.mockito.Mockito.when; 27 28 import org.apache.fop.fo.FONode.FONodeIterator; 29 import org.apache.fop.fo.flow.table.Table; 30 import org.apache.fop.layoutmgr.LayoutContext; 31 import org.apache.fop.layoutmgr.PositionIterator; 32 33 public class TableContentLayoutManagerTestCase { 34 35 @Test testAddAreas()36 public void testAddAreas() { 37 LayoutContext lc = LayoutContext.newInstance(); 38 // mock 39 ColumnSetup cs = mock(ColumnSetup.class); 40 when(cs.getColumnCount()).thenReturn(3); 41 // mock 42 FONodeIterator foni = mock(FONodeIterator.class); 43 when(foni.hasNext()).thenReturn(false); 44 // mock 45 Table t = mock(Table.class); 46 when(t.getChildNodes()).thenReturn(foni); 47 when(t.getMarkers()).thenReturn(null); 48 // mock 49 TableLayoutManager tlm = mock(TableLayoutManager.class); 50 when(tlm.getTable()).thenReturn(t); 51 when(tlm.getColumns()).thenReturn(cs); 52 // mock 53 PositionIterator pi = mock(PositionIterator.class); 54 when(pi.hasNext()).thenReturn(false); 55 // real TCLM, not a mock 56 TableContentLayoutManager tclm = new TableContentLayoutManager(tlm); 57 // check that addAreas() calls the clearTableFragments() on the table and the 58 // repeatAddAreasForSavedTableHeaderTableCellLayoutManagers on the TLM 59 tclm.addAreas(pi, lc); 60 verify(tlm).clearTableFragmentMarkers(); 61 verify(tlm).repeatAddAreasForSavedTableHeaderTableCellLayoutManagers(); 62 } 63 64 } 65