Changeset 62 for trunk/org.modelica.mdt.test/src/org/modelica/mdt
- Timestamp:
- 10/07/05 13:45:56 (19 years ago)
- Location:
- trunk/org.modelica.mdt.test/src/org/modelica/mdt/test
- Files:
-
- 1 added
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/org.modelica.mdt.test/src/org/modelica/mdt/test/TestNewProjectWizard.java
r60 r62 42 42 package org.modelica.mdt.test; 43 43 44 import java.util.concurrent.Semaphore;45 46 44 import org.eclipse.core.resources.IProject; 47 45 import org.eclipse.core.resources.ResourcesPlugin; 48 46 import org.eclipse.core.runtime.CoreException; 49 import org.eclipse.jface.viewers.StructuredSelection; 50 import org.eclipse.jface.wizard.WizardDialog; 47 import org.eclipse.swt.widgets.Button; 51 48 import org.eclipse.swt.widgets.Text; 52 import org.eclipse.ui.IWorkbench;53 49 import org.eclipse.ui.IWorkbenchWizard; 54 50 import org.eclipse.ui.PlatformUI; 55 import org.eclipse.ui.wizards.IWizardDescriptor;56 51 import org.modelica.mdt.NewProjectWizard; 57 52 53 import abbot.finder.matchers.swt.TextMatcher; 54 import abbot.finder.swt.BasicFinder; 55 import abbot.finder.swt.MultipleWidgetsFoundException; 56 import abbot.finder.swt.TestHierarchy; 57 import abbot.finder.swt.WidgetNotFoundException; 58 import abbot.tester.swt.ButtonTester; 58 59 import abbot.tester.swt.TextTester; 59 60 … … 70 71 * init and display wizard 71 72 */ 72 IWorkbench workbench = PlatformUI.getWorkbench(); 73 IWizardDescriptor wizDesc = 74 workbench.getNewWizardRegistry().findWizard("org.modelica.mdt.NewProjectWizard"); 75 assertNotNull("new project wizard not found", wizDesc); 76 77 IWorkbenchWizard wizard = null; 78 try 79 { 80 wizard = wizDesc.createWizard(); 81 } 82 catch (CoreException e) 83 { 84 fail("Could not create new project wizard, CoreException thrown\n" 85 + e.getMessage()); 86 } 87 assertNotNull(wizard); 88 89 wizard.init(workbench, StructuredSelection.EMPTY); 90 final WizardDialog dialog = 91 new WizardDialog(workbench.getActiveWorkbenchWindow().getShell(), wizard); 92 dialog.create(); 93 94 openDialog(dialog); 95 73 IWorkbenchWizard wizard = Utility.openWizard("org.modelica.mdt.NewProjectWizard"); 96 74 assertFalse(wizard.canFinish()); 97 75 … … 103 81 assertTrue(wizard.canFinish()); 104 82 105 /* create project */ 106 boolean finishRes = wizard.performFinish(); 107 assertTrue("New wizard dialog failed to finish", finishRes); 83 /* 84 * create project 85 */ 86 BasicFinder finder = /* find finish button */ 87 new BasicFinder(new TestHierarchy(PlatformUI.getWorkbench().getDisplay())); 88 89 Button finish = null; 90 try 91 { 92 finish = (Button) finder.find(new TextMatcher("&Finish")); 93 } 94 catch (WidgetNotFoundException e) 95 { 96 fail("Finish button not found."); 97 } 98 catch (MultipleWidgetsFoundException e) 99 { 100 fail("Multiple finish buttons found."); 101 } 102 103 /* create project by clicking finish button */ 104 while (!finish.getEnabled()) 105 { 106 /* wait for the name changed to propogate to enable the finish button */ 107 } 108 ButtonTester.getButtonTester().actionClick(finish); 109 108 110 109 111 /* check that project was created */ 110 112 IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME); 111 113 112 assertTrue("new wizard fail to create project", project.exists());114 assertTrue("new wizard failed to create project", project.exists()); 113 115 assertTrue("new wizard didnt open the created project", project.isOpen()); 114 116 … … 126 128 fail("CoreException thrown while probing for modelica nature " + e.getMessage()); 127 129 } 128 129 130 /* clean up */ 131 dialog.close(); 130 132 131 } 133 132 134 /**135 * opens (runs dialog.open() method ) a dialog in UI thread and waits until it136 * is open before returning137 *138 * @param dialog the dialog to open, it is assumed that dialog is fully initialized139 *140 */141 private void openDialog(final WizardDialog dialog)142 {143 final Semaphore sem = new Semaphore(0);144 145 dialog.getShell().getDisplay().syncExec(new Runnable()146 {147 public void run()148 {149 dialog.setBlockOnOpen(false);150 dialog.open();151 sem.release();152 }153 });154 155 try156 {157 sem.acquire();158 }159 catch (InterruptedException e)160 {161 fail("interruped while waiting for dialog to open");162 }163 }164 165 133 }
Note: See TracChangeset
for help on using the changeset viewer.