testdev/ite/test/com.nokia.testfw.launch.test/src/com/nokia/testfw/launch/STFEmulationLaunchTest.java
changeset 1 96906a986c3b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testdev/ite/test/com.nokia.testfw.launch.test/src/com/nokia/testfw/launch/STFEmulationLaunchTest.java	Tue Mar 30 14:39:29 2010 +0800
@@ -0,0 +1,104 @@
+package com.nokia.testfw.launch;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPresentationManager;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.nokia.testfw.test.utils.ProjectUtils;
+import com.nokia.testfw.test.utils.TestUtils;
+
+@SuppressWarnings("restriction")
+public class STFEmulationLaunchTest extends TestCase {
+
+	IProject targetProject;
+	ILaunchConfigurationWorkingCopy iLaunchConfigurationWorkingCopy;
+
+	@Before
+	public void setUp() throws Exception {
+		targetProject = ProjectUtils.getTargetProject("TestModule");
+		if (targetProject == null) {
+			String projectPath = (new File("resource/TestModule"))
+					.getCanonicalPath();
+			String bldInfPath = "group/bld.inf";
+			targetProject = ProjectUtils.createTargetProject("TestModule",
+					projectPath, bldInfPath);
+		}
+		ProjectUtils.selectProject(targetProject);
+		ILaunchManager lLaunchManager = DebugPlugin.getDefault()
+				.getLaunchManager();
+		ILaunchConfigurationType type = lLaunchManager
+				.getLaunchConfigurationType("com.nokia.testfw.launch.STFEmulationLaunch");
+		iLaunchConfigurationWorkingCopy = type.newInstance(null,
+				"STFEmulationLaunchTest");
+	}
+
+	@Test
+	public void testSUTEmulationLaunch() {
+		Shell shell = Display.getDefault().getShells()[0];
+		String groupIdentifier = "org.eclipse.debug.ui.launchGroup.run";
+
+		org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension ext = DebugUIPlugin
+				.getDefault().getLaunchConfigurationManager().getLaunchGroup(
+						groupIdentifier);
+		TestUtils.delay(1000);
+		if (ext != null) {
+			try {
+				ILaunchConfigurationTabGroup tabGroup = LaunchConfigurationPresentationManager
+						.getDefault().getTabGroup(
+								iLaunchConfigurationWorkingCopy,
+								ILaunchManager.RUN_MODE);
+				LaunchConfigurationsDialog dialog = new LaunchConfigurationsDialog(
+						shell, ext);
+				dialog.setInitialSelection(new StructuredSelection(
+						iLaunchConfigurationWorkingCopy.getType()));
+				dialog.setInitialStatus(null);
+				dialog.setOpenMode(3);
+				dialog.setBlockOnOpen(false);
+				dialog.open();
+
+				tabGroup.createTabs(dialog, dialog.getMode());
+				ILaunchConfigurationTab tabs[] = tabGroup.getTabs();
+				for (int i = 0; i < tabs.length; i++)
+					tabs[i].setLaunchConfigurationDialog(dialog);
+
+				tabGroup.setDefaults(iLaunchConfigurationWorkingCopy);
+				iLaunchConfigurationWorkingCopy.doSave();
+				tabGroup.dispose();
+				TestUtils.delay(1000);
+				try {
+					dialog.getTabGroup().performApply(
+							iLaunchConfigurationWorkingCopy);
+					String script = iLaunchConfigurationWorkingCopy
+							.getAttribute(LaunchConfigurationConstants.SCRIPT_DEVICE_PATH,
+									(String) null);
+					assertNotNull(script);
+					assertEquals(script, "c:\\TestFramework\\TestModuleTests.cfg");
+				} catch (CoreException e) {
+					e.printStackTrace();
+				}
+				dialog.close();
+				TestUtils.delay(1000);
+			} catch (CoreException e) {
+				e.printStackTrace();
+			}
+
+		}
+	}
+}