/*******************************************************************************
 * Copyright (c) 2012 - 2015 Signal Iduna Corporation and others.
 * 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:
 * Signal Iduna Corporation - initial API and implementation
 * akquinet AG
 *******************************************************************************/
package org.testeditor.ui.reporting;

import static org.junit.Assert.assertNotNull;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.testeditor.core.exceptions.SystemException;
import org.testeditor.core.model.testresult.TestResult;
import org.testeditor.core.model.teststructure.TestCase;
import org.testeditor.core.model.teststructure.TestStructure;
import org.testeditor.core.services.interfaces.TestStructureService;
import org.testeditor.ui.adapter.TestStructureServiceAdapter;
import org.testeditor.ui.utilities.TestEditorTranslationService;

/**
 * 
 * Integrationtests for the TestExecutionProgressDialog.
 * 
 */
public class TestExecutionProgressDialogTest {

	private Shell shell;

	/**
	 * Test the Execution of a Teststructure.
	 * 
	 * @throws Exception
	 *             for test
	 */
	@Test
	@Ignore
	public void testExecuteTest() throws Exception {
		IEclipseContext context = EclipseContextFactory.create();
		context.set(Shell.class, shell);
		context.set(TestStructureService.class, getTestStructureServiceMock());
		context.set(IEventBroker.class, null);
		context.set(TestEditorTranslationService.class, new TestEditorTranslationService() {
			@Override
			public String translate(String key, Object... params) {
				return "";
			}
		});
		TestExecutionProgressDialog testExecutionDialog = ContextInjectionFactory.make(
				TestExecutionProgressDialog.class, context);
		TestStructure test = new TestCase();
		TestResult testResult = testExecutionDialog.executeTest(test);
		assertNotNull("Notnull for testresult", testResult);
	}

	/**
	 * Creates the UI Ressources for the test.
	 */
	@Before
	public void setUp() {
		shell = new Shell(Display.getDefault());
	}

	/**
	 * Disposes UI Resources after test.
	 */
	@After
	public void tearDown() {
		shell.dispose();
	}

	/**
	 * Creates a TestStructureService Mock Object. CHECKSTYLE:OFF
	 * 
	 * @return Mock for the Test
	 */
	private TestStructureService getTestStructureServiceMock() {
		TestStructureServiceAdapter testStructureServiceAdapter = new TestStructureServiceAdapter() {
			@Override
			public TestResult executeTestStructure(TestStructure testStructure, IProgressMonitor monitor)
					throws SystemException {

				return new TestResult();
			}
		};
		testStructureServiceAdapter.setEmptyVariable(true);
		return testStructureServiceAdapter;
	}

}

@@ -602,16 +602,109 @@
 rting;%0A%0A
+import static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotEquals;%0A
 import s
@@ -1018,24 +1018,224 @@
 ventBroker;%0A
+import org.eclipse.swt.SWT;%0Aimport org.eclipse.swt.events.SelectionListener;%0Aimport org.eclipse.swt.graphics.Point;%0Aimport org.eclipse.swt.layout.GridLayout;%0Aimport org.eclipse.swt.widgets.Composite;%0A
 import org.e
@@ -1966,16 +1966,74 @@
 l shell;
+%0A%09private TestExecutionProgressDialog testExecutionDialog;
 %0A%0A%09/**%0A%09
@@ -2197,16 +2197,930 @@
 ption %7B%0A
+%09%09TestStructure test = new TestCase();%0A%09%09TestResult testResult = testExecutionDialog.executeTest(test);%0A%09%09assertNotNull(%22Notnull for testresult%22, testResult);%0A%09%7D%0A%0A%09/**%0A%09 * Test the detail switcher selection listener.%0A%09 * %0A%09 */%0A%09@Test%0A%09public void testSwitchDetailSelectionListener() %7B%0A%09%09testExecutionDialog.createDialogArea(shell);%0A%09%09Composite composite = new Composite(shell, SWT.NORMAL);%0A%09%09composite.setLayout(new GridLayout());%0A%09%09testExecutionDialog.createButtonsForButtonBar(composite);%0A%09%09Point originalSize = shell.getSize();%0A%09%09SelectionListener listener = testExecutionDialog.getSwitchDetailSelectionListener();%0A%09%09listener.widgetSelected(null);%0A%09%09assertNotEquals(originalSize, shell.getSize());%0A%09%09listener.widgetSelected(null);%0A%09%09assertEquals(originalSize, shell.getSize());%0A%09%7D%0A%0A%09/**%0A%09 * Creates the UI Ressources for the test.%0A%09 */%0A%09@Before%0A%09public void setUp() %7B%0A%09%09shell = new Shell(Display.getDefault());%0A
 %09%09IEclip
@@ -3224,34 +3224,25 @@
 set(
-TestStructure
+%22ActualTC
 Service
-.class
+%22
 , ge
@@ -3503,36 +3503,8 @@
 ;%0A%09%09
-TestExecutionProgressDialog 
 test
@@ -3550,21 +3550,16 @@
 ry.make(
-%0A%09%09%09%09
 TestExec
@@ -3599,300 +3599,8 @@
 t);%0A
-%09%09TestStructure test = new TestCase();%0A%09%09TestResult testResult = testExecutionDialog.executeTest(test);%0A%09%09assertNotNull(%22Notnull for testresult%22, testResult);%0A%09%7D%0A%0A%09/**%0A%09 * Creates the UI Ressources for the test.%0A%09 */%0A%09@Before%0A%09public void setUp() %7B%0A%09%09shell = new Shell(Display.getDefault());%0A
 %09%7D%0A%0A

Test the switch logic for the size