Skip to content

Commit ae8f24a

Browse files
committed
Attempt to fix Autotool test errors in build by using Display thread.
2011-05-19 Jeff Johnston <[email protected]> * src/org/eclipse/linuxtools/cdt/autotools/tests/editors/AutomakeColourizationTests.java (setUp): Perform any editor or active page manipulation within Display thread. * src/org/eclipse/linuxtools/cdt/autotools/tests/editors/AutomakeTextHoverTest.java (setUp): Ditto. * src/org/eclipse/linuxtools/cdt/autotools/tests/editors/AutomakeEditorTests.java (testAutomakeEditorAssociation): Ditto.
1 parent b61aa40 commit ae8f24a

File tree

4 files changed

+91
-51
lines changed

4 files changed

+91
-51
lines changed

autotools/org.eclipse.linuxtools.cdt.autotools.tests/ChangeLog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2011-05-19 Jeff Johnston <[email protected]>
2+
3+
* src/org/eclipse/linuxtools/cdt/autotools/tests/editors/AutomakeColourizationTests.java (setUp): Perform
4+
any editor or active page manipulation within Display thread.
5+
* src/org/eclipse/linuxtools/cdt/autotools/tests/editors/AutomakeTextHoverTest.java (setUp): Ditto.
6+
* src/org/eclipse/linuxtools/cdt/autotools/tests/editors/AutomakeEditorTests.java (testAutomakeEditorAssociation): Ditto.
7+
18
2010-11-18 Jeff Johnston <[email protected]>
29

310
* src/org/eclipse/linuxtools/cdt/autotools/tests/ProjectTools.java (createProject): Try creating a project

autotools/org.eclipse.linuxtools.cdt.autotools.tests/src/org/eclipse/linuxtools/cdt/autotools/tests/editors/AutomakeColourizationTests.java

+27-16
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.eclipse.linuxtools.internal.cdt.autotools.ui.editors.automake.AutomakefileSourceConfiguration;
2929
import org.eclipse.linuxtools.internal.cdt.autotools.ui.preferences.ColorManager;
3030
import org.eclipse.swt.graphics.Color;
31+
import org.eclipse.swt.widgets.Display;
3132
import org.eclipse.ui.IEditorPart;
3233
import org.eclipse.ui.IWorkbench;
3334

@@ -64,22 +65,32 @@ protected void setUp() throws Exception {
6465

6566
project.open(new NullProgressMonitor());
6667

67-
makefileAmFile = tools.createFile(project, "Makefile.am", makefileAmContents);
68-
workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();
69-
70-
IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
71-
.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
72-
true);
73-
74-
AutomakeEditor automakeEditor = (AutomakeEditor) openEditor;
75-
AutomakeDocumentProvider docProvider = automakeEditor.getAutomakefileDocumentProvider();
76-
IDocument automakeDocument = docProvider.getDocument(openEditor.getEditorInput());
77-
AutomakefileSourceConfiguration automakeSourceViewerConfig = automakeEditor.getAutomakeSourceViewerConfiguration();
78-
79-
ITypedRegion region = automakeDocument.getPartition(0);
80-
81-
codeScanner = automakeSourceViewerConfig.getAutomakeCodeScanner();
82-
codeScanner.setRange(automakeDocument, region.getOffset(), region.getLength());
68+
Display.getDefault().syncExec(new Runnable() {
69+
70+
public void run() {
71+
try {
72+
makefileAmFile = tools.createFile(project, "Makefile.am", makefileAmContents);
73+
workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();
74+
75+
IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
76+
.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
77+
true);
78+
79+
AutomakeEditor automakeEditor = (AutomakeEditor) openEditor;
80+
AutomakeDocumentProvider docProvider = automakeEditor.getAutomakefileDocumentProvider();
81+
IDocument automakeDocument = docProvider.getDocument(openEditor.getEditorInput());
82+
AutomakefileSourceConfiguration automakeSourceViewerConfig = automakeEditor.getAutomakeSourceViewerConfiguration();
83+
84+
ITypedRegion region = automakeDocument.getPartition(0);
85+
codeScanner = automakeSourceViewerConfig.getAutomakeCodeScanner();
86+
codeScanner.setRange(automakeDocument, region.getOffset(), region.getLength());
87+
} catch (Exception e) {
88+
fail();
89+
}
90+
}
91+
92+
});
93+
8394
}
8495

8596
IToken getNextToken() {

autotools/org.eclipse.linuxtools.cdt.autotools.tests/src/org/eclipse/linuxtools/cdt/autotools/tests/editors/AutomakeEditorTests.java

+20-9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.eclipse.linuxtools.cdt.autotools.tests.AutotoolsTestsPlugin;
1919
import org.eclipse.linuxtools.cdt.autotools.tests.ProjectTools;
2020
import org.eclipse.linuxtools.internal.cdt.autotools.ui.editors.automake.AutomakeEditor;
21+
import org.eclipse.swt.widgets.Display;
2122
import org.eclipse.ui.IEditorPart;
2223
import org.eclipse.ui.IWorkbench;
2324

@@ -43,16 +44,26 @@ public void testAutomakeEditorAssociation() throws Exception {
4344

4445
project.open(new NullProgressMonitor());
4546

46-
IFile makefileAmFile = tools.createFile(project, "Makefile.am", "");
47-
assertTrue(makefileAmFile.exists());
48-
49-
IWorkbench workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();
47+
Display.getDefault().syncExec(new Runnable() {
48+
49+
public void run() {
50+
try {
51+
IFile makefileAmFile = tools.createFile(project, "Makefile.am", "");
52+
assertTrue(makefileAmFile.exists());
53+
54+
IWorkbench workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();
55+
56+
IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
57+
.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
58+
true);
59+
assertTrue(openEditor instanceof AutomakeEditor);
60+
} catch (Exception e) {
61+
fail();
62+
}
63+
}
64+
65+
});
5066

51-
IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
52-
.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
53-
true);
54-
assertTrue(openEditor instanceof AutomakeEditor);
55-
5667
project.delete(true, false, ProjectTools.getMonitor());
5768
}
5869
}

autotools/org.eclipse.linuxtools.cdt.autotools.tests/src/org/eclipse/linuxtools/cdt/autotools/tests/editors/AutomakeTextHoverTest.java

+37-26
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.eclipse.linuxtools.internal.cdt.autotools.ui.editors.automake.AutomakeEditor;
2525
import org.eclipse.linuxtools.internal.cdt.autotools.ui.editors.automake.AutomakeTextHover;
2626
import org.eclipse.linuxtools.internal.cdt.autotools.ui.editors.automake.AutomakefileSourceConfiguration;
27+
import org.eclipse.swt.widgets.Display;
2728
import org.eclipse.ui.IEditorPart;
2829
import org.eclipse.ui.IWorkbench;
2930

@@ -65,33 +66,43 @@ public class AutomakeTextHoverTest extends TestCase {
6566
"\t" + "echo $?" + "\n" +
6667
"";
6768
private IWorkbench workbench;
68-
69+
6970
protected void setUp() throws Exception {
70-
super.setUp();
71-
tools = new ProjectTools();
72-
if (!ProjectTools.setup())
73-
fail("could not perform basic project workspace setup");
74-
75-
project = ProjectTools.createProject("testProjectATHT");
76-
77-
if(project == null) {
78-
fail("Unable to create test project");
79-
}
80-
81-
project.open(new NullProgressMonitor());
82-
83-
makefileAmFile = tools.createFile(project, "Makefile.am", makefileAmContents);
84-
workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();
85-
86-
IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
87-
.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
88-
true);
89-
90-
automakeEditor = (AutomakeEditor) openEditor;
91-
AutomakeDocumentProvider docProvider = automakeEditor.getAutomakefileDocumentProvider();
92-
automakeDocument = docProvider.getDocument(openEditor.getEditorInput());
93-
AutomakefileSourceConfiguration automakeSourceViewerConfig = automakeEditor.getAutomakeSourceViewerConfiguration();
94-
textHover = (AutomakeTextHover) automakeSourceViewerConfig.getTextHover(null, "");
71+
super.setUp();
72+
tools = new ProjectTools();
73+
if (!ProjectTools.setup())
74+
fail("could not perform basic project workspace setup");
75+
76+
project = ProjectTools.createProject("testProjectATHT");
77+
78+
if(project == null) {
79+
fail("Unable to create test project");
80+
}
81+
82+
project.open(new NullProgressMonitor());
83+
84+
Display.getDefault().syncExec(new Runnable() {
85+
86+
public void run() {
87+
try {
88+
makefileAmFile = tools.createFile(project, "Makefile.am", makefileAmContents);
89+
workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();
90+
91+
IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
92+
.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
93+
true);
94+
95+
automakeEditor = (AutomakeEditor) openEditor;
96+
AutomakeDocumentProvider docProvider = automakeEditor.getAutomakefileDocumentProvider();
97+
automakeDocument = docProvider.getDocument(openEditor.getEditorInput());
98+
AutomakefileSourceConfiguration automakeSourceViewerConfig = automakeEditor.getAutomakeSourceViewerConfiguration();
99+
textHover = (AutomakeTextHover) automakeSourceViewerConfig.getTextHover(null, "");
100+
} catch (Exception e) {
101+
fail();
102+
}
103+
}
104+
105+
});
95106
}
96107

97108
protected void tearDown() throws Exception {

0 commit comments

Comments
 (0)