/*******************************************************************************
 * 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.tests.viewer.regression;

import org.apache.cactus.WebRequest;
import org.eclipse.birt.report.servlet.BirtEngineServlet;
import org.eclipse.birt.report.tests.viewer.BaseViewerTestCase;

import com.meterware.httpunit.HTMLElement;
import com.meterware.httpunit.WebResponse;

/**
 * <b>Bug Description:</b>
 * <p>
 * The Double line in border can't use
 * <p>
 * <b>steps to reproduce:</b>
 * <ol>
 * <li>New a report and drop a label
 * <li>Select the label border in Property
 * <li>Select double line in Style and All Borders in Preset
 * <li>Preview
 * </ol>
 * <b>Actual result:</b>
 * <p>
 * Only the odd line show expected result: The double line show
 * <p>
 * <b>Test Description:</b> Make sure double line is defined in the style, and
 * element "class" refer to the style
 */
public class Regression_113930 extends BaseViewerTestCase
{
	private final static String REPORT = "report/Regression_113930.rptdesign"; //$NON-NLS-1$

	/**
	 * @param webRequest
	 * @throws Exception
	 */
	public void begin_regression_113930( WebRequest webRequest )
			throws Exception
	{
		webRequest.setURL( null, null, SERVLET_PATH_FRAMESET, null, null );
		webRequest.addParameter( PARAM_REPORT, REPORT );
		webRequest.addParameter( PARAM_LOCALE, "en_US" ); //$NON-NLS-1$
	}

	/**
	 * test_regression_113930
	 */
	public void test_regression_113930( )
	{
		BirtEngineServlet servlet = new BirtEngineServlet( );
		try
		{
			servlet.init( config );
			servlet.doGet( request, response );
		}
		catch ( Exception e )
		{
			e.printStackTrace( );
			fail( e.toString( ) );
		}
	}

	/**
	 * @param webResponse
	 * @throws Exception
	 */
	public void end_regression_113930( WebResponse webResponse )
			throws Exception
	{
		HTMLElement element = webResponse.getElementWithID( "bookmark" ); //$NON-NLS-1$
		String style = element.getAttribute( "class" ); //$NON-NLS-1$
		assertNotNull( style );
		assertEquals( "style_1", style ); //$NON-NLS-1$
		String content = webResponse.getText( );
		String linestyle = content
				.substring(
						content.indexOf( "border-right:" ) + 21, content.indexOf( "border-right:" ) + 27 ); //$NON-NLS-1$ //$NON-NLS-2$
		assertEquals( "double", linestyle ); //$NON-NLS-1$
	}
}
