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

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import org.eclipse.birt.report.tests.engine.EngineCase;

/**
 * <b>Bug description</b>
 * <p>
 * click the "+" in the BIRT viewer to expand the detail error message has no
 * effect.
 * <p>
 * <b>Test description</b>
 * <p>
 * This test makes sure that engine inlines the jsfunction to the onClick
 * attribute to ensure the expand effect.
 * <p>
 * 
 * 
 */
public class Regression_122111 extends EngineCase
{

	private final static String INPUT = "regression_122111.rptdesign"; //$NON-NLS-1$
	private final static String OUTPUT = "regression_122111.html"; //$NON-NLS-1$

	/**
	 * @throws Exception
	 */

	public void test_Regression_122111( ) throws Exception
	{
		runAndRender_HTML( INPUT, OUTPUT );
		checkOnClick( );
	}

	private void checkOnClick( ) throws IOException
	{
		String path = getClassFolder( ) + "/" + OUTPUT_FOLDER + "/";
		BufferedReader reader = new BufferedReader( new FileReader( new File(
				path + OUTPUT ) ) );
		String line = null;
		int begin = 0, flag = 0;
		while ( ( line = reader.readLine( ) ) != null )
		{
			if ( line.indexOf( "onclick" ) > 0 )
			{
				line = line.trim( );
				begin = line.indexOf( "onclick" );
				assertTrue( line.indexOf( "document.getElementById" ) > begin );
				assertTrue( line.indexOf( ".innerHTML = '- '" ) > begin );
				flag = 1;
				break;
			}
		}
		assertEquals( 1, flag );

	}
}
