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

import org.eclipse.birt.report.engine.api.IReportDocument;
import org.eclipse.birt.report.engine.api.ITOCTree;
import org.eclipse.birt.report.engine.api.TOCNode;
import org.eclipse.birt.report.tests.engine.EngineCase;

import com.ibm.icu.util.ULocale;

/**
 * <b>Bug description</b>
 * <p>
 * Datetime TOC display format is inconsistent between preview page and TOC pane
 * in Web Viewer Group TOC doesn't show up when preview
 * <p>
 * <b>Test description:</b>
 * <p>
 * This test makes sure that display format of two places are the same. This
 * test also makes sure that Group TOC will return value.
 */
public class Regression_122895and122306 extends EngineCase
{

	private final static String INPUT = "regression_122895and122306.rptdesign"; //$NON-NLS-1$
	private final static String OUTPUT = "regression_122895and122306.rptdocument"; //$NON-NLS-1$
	private String path = getClassFolder( )
			+ System.getProperty( "file.separator" );
	private String out_path = path + "output"
			+ System.getProperty( "file.separator" );

	/**
	 * @throws Exception
	 */

	public void test_Regression_122895and122306( ) throws Exception
	{
		run( INPUT, OUTPUT );
		IReportDocument reportDoc = engine.openReportDocument( out_path
				+ OUTPUT );

		ITOCTree tree = reportDoc.getTOCTree( null, ULocale.ENGLISH );
		TOCNode root = tree.findTOC( "/" );
		String tocValue, tocLabel;
		tocLabel = ( (TOCNode) root.getChildren( ).get( 0 ) )
				.getDisplayString( );
		tocValue = "Jan 6, 2003 12:00 AM";
		assertEquals(
				"Toc with datetime type display different format from preview page",
				tocValue, tocLabel );
	}
}
