
package org.eclipse.birt.report.tests.engine.regression;

import java.util.HashMap;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.HTMLRenderContext;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.tests.engine.EngineCase;

/**
 * <b>Bug description</b>
 * <p>
 * Iid is still associated with chart image after nest chart inside table item.
 * <p>
 * <b>Test description</b>
 * <p>
 * This test makes sure that iid will be associated with outer table instead of
 * inner chart image.
 * 
 */
public class Regression_142382 extends EngineCase
{

	private final static String INPUT = "regression_142382.rptdesign"; //$NON-NLS-1$
	private final static String OUTPUT = "regression_142382.html"; //$NON-NLS-1$
	private final static String GOLDEN = "regression_142382.html"; //$NON-NLS-1$
	private String inputPath = getClassFolder( )
			+ System.getProperty( "file.separator" ) + INPUT_FOLDER
			+ System.getProperty( "file.separator" );
	private String outputPath = getClassFolder( )
			+ System.getProperty( "file.separator" ) + OUTPUT_FOLDER
			+ System.getProperty( "file.separator" );

	/**
	 * @throws Exception
	 */
	public void test_Regression_142382( ) throws Exception
	{
		IReportRunnable reportRunnable = engine.openReportDesign( inputPath
				+ INPUT );
		IRunAndRenderTask task = engine.createRunAndRenderTask( reportRunnable );
		HTMLRenderContext renderContext = new HTMLRenderContext( );
		renderContext.setImageDirectory( "image" );
		HashMap appContext = new HashMap( );
		appContext.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,
				renderContext );
		HTMLRenderOption options = new HTMLRenderOption( );
		options.setOutputFileName( outputPath + OUTPUT );
		options.setOutputFormat( "html" );
		task.setAppContext( appContext );
		task.setRenderOption( options );
		task.run( );
		assertTrue( "Exception when runandrender report!", task.getErrors( )
				.size( ) <= 0 );
		task.close( );
		compareHTML( GOLDEN, OUTPUT );

	}

}
