/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.engine.ir;

import junit.framework.TestCase;

/**
 * Test RowType.
 * 
 */
public class RowTypeTest extends TestCase
{

	/**
	 * test addCell function.
	 * 
	 * cell has column attribute, but the row keep the cell as the design order,
	 * all check will be done by DE' parser.
	 */
	public void testAddCell( )
	{
		RowDesign row = new RowDesign( );
		//add cell 1
		row.addCell( createCell( 1 ) );
		//skip 2
		//set the column 3
		row.addCell( createCell( 3, 3 ) );
		//column 4
		row.addCell( createCell( 4 ) );
		//skip 5
		//column 6
		row.addCell( createCell( 6, 6 ) );

		assertCell( row.getCell( 0 ), 1 );
		assertCell( row.getCell( 1 ), 3 );
		assertCell( row.getCell( 2 ), 4 );
		assertCell( row.getCell( 3 ), 6 );
	}

	private CellDesign createCell( int colId, int cellId )
	{
		CellDesign cell = new CellDesign( );
		cell.setColumn( colId );
		cell.setColSpan( cellId );
		return cell;
	}

	private CellDesign createCell( int cellId )
	{
		return createCell( 0, cellId );
	}

	private void assertCell( CellDesign cell, int cellId )
	{
		assertTrue( cell.getColSpan( ) == cellId );
	}
	
	public void testGetSet()
	{
		RowDesign row = new RowDesign( );
		DimensionType height = new DimensionType(1.0, DimensionType.UNITS_CM);
		String bookmark = "";

		//set
		row.setHeight(height);
		row.setBookmark(bookmark);

		//set
		assertEquals(row.getHeight(), height);
		assertEquals(row.getBookmark(), bookmark);
	}
}
