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

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

import org.eclipse.birt.report.model.api.SessionHandle;
import org.eclipse.birt.report.tests.engine.EngineCase;

/**
 * <b>Bug description</b>
 * <p>
 * Relative path is not supported in background image.
 * 
 * <p>
 * <b>Test description:</b>
 * <p>
 * This test makes sure that background image can use relative path to visit
 * image file in resource folder.
 * 
 */
public class Regression_139372 extends EngineCase
{

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

	/**
	 * @throws Exception
	 */
	public void test_Regression_139372( ) throws Exception
	{
		SessionHandle.setBirtResourcePath( getClassFolder( ) + "/"
				+ INPUT_FOLDER + "/" + "pics/" );
		runAndRender_HTML( INPUT, OUTPUT );
		checkBgImage( );
	}

	private void checkBgImage( ) throws IOException
	{
		BufferedReader reader = new BufferedReader( new FileReader(
				getClassFolder( ) + "/" + OUTPUT_FOLDER + "/" + OUTPUT ) );
		String line = null;
		while ( ( line = reader.readLine( ) ) != null )
		{
			if ( line.indexOf( "background-image: url" ) != -1 )
			{
				assertTrue( line.indexOf( "background-image: url('image" ) != -1 );
				break;
			}
		}

	}

}
