|
13 | 13 | *******************************************************************************/
|
14 | 14 | package org.eclipse.ui.tests.dialogs;
|
15 | 15 |
|
16 |
| -import java.util.List; |
| 16 | +import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace; |
17 | 17 |
|
| 18 | +import java.util.List; |
| 19 | +import org.eclipse.core.internal.resources.Workspace; |
18 | 20 | import org.eclipse.core.resources.IWorkspace;
|
| 21 | +import org.eclipse.core.resources.IWorkspaceDescription; |
19 | 22 | import org.eclipse.core.resources.ResourcesPlugin;
|
| 23 | +import org.eclipse.core.runtime.CoreException; |
20 | 24 | import org.eclipse.core.runtime.IAdaptable;
|
21 | 25 | import org.eclipse.jface.wizard.IWizardPage;
|
22 | 26 | import org.eclipse.swt.widgets.Composite;
|
@@ -57,6 +61,29 @@ private IWorkingSetPage getDefaultEditPage() {
|
57 | 61 | return registry.getDefaultWorkingSetPage();
|
58 | 62 | }
|
59 | 63 |
|
| 64 | + /** |
| 65 | + * Blocks the calling thread until autobuild completes. |
| 66 | + */ |
| 67 | + private static void waitForBuild() { |
| 68 | + ((Workspace) getWorkspace()).getBuildManager().waitForAutoBuild(); |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * Enables or disables workspace autobuild. Waits for the build to be finished, |
| 73 | + * even if the autobuild value did not change and a previous build is still |
| 74 | + * running. |
| 75 | + */ |
| 76 | + private static void setAutoBuilding(boolean enabled) throws CoreException { |
| 77 | + IWorkspace workspace = getWorkspace(); |
| 78 | + if (workspace.isAutoBuilding() != enabled) { |
| 79 | + IWorkspaceDescription description = workspace.getDescription(); |
| 80 | + description.setAutoBuilding(enabled); |
| 81 | + workspace.setDescription(description); |
| 82 | + } |
| 83 | + waitForBuild(); |
| 84 | + } |
| 85 | + |
| 86 | + |
60 | 87 | @Test
|
61 | 88 | public void testEditPage() throws Throwable {
|
62 | 89 | IWizardPage page = getWizardDialog().getCurrentPage();
|
@@ -119,4 +146,17 @@ public void testEditPage() throws Throwable {
|
119 | 146 |
|
120 | 147 | DialogCheck.assertDialogTexts(getWizardDialog());
|
121 | 148 | }
|
| 149 | + |
| 150 | + @Override |
| 151 | + public void doSetUp() throws Exception { |
| 152 | + super.doSetUp(); |
| 153 | + setAutoBuilding(false); |
| 154 | + } |
| 155 | + |
| 156 | + @Override |
| 157 | + public void doTearDown() throws Exception { |
| 158 | + super.doTearDown(); |
| 159 | + ResourcesPlugin.getWorkspace().setDescription(Workspace.defaultWorkspaceDescription()); |
| 160 | + } |
| 161 | + |
122 | 162 | }
|
0 commit comments