Skip to content

Commit 4ae2bee

Browse files
committed
More Autotool test fixes to use 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. (testGetHoverForMacro2): Ditto. (testGetHoverForMacro1): Ditto. (testGetHoverInfoForTargetDependencies): Ditto. (testGetHoverInfoForTargetDependency): Ditto. (testGetHoverInfoTargetName2): Ditto. (testGetHoverInfoTargetName1): Ditto. * src/org/eclipse/linuxtools/cdt/autotools/tests/editors/AutomakeEditorTests.java (testAutomakeEditorAssociation): Ditto.
1 parent ae8f24a commit 4ae2bee

File tree

2 files changed

+155
-119
lines changed

2 files changed

+155
-119
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
* src/org/eclipse/linuxtools/cdt/autotools/tests/editors/AutomakeColourizationTests.java (setUp): Perform
44
any editor or active page manipulation within Display thread.
55
* src/org/eclipse/linuxtools/cdt/autotools/tests/editors/AutomakeTextHoverTest.java (setUp): Ditto.
6+
(testGetHoverForMacro2): Ditto.
7+
(testGetHoverForMacro1): Ditto.
8+
(testGetHoverInfoForTargetDependencies): Ditto.
9+
(testGetHoverInfoForTargetDependency): Ditto.
10+
(testGetHoverInfoTargetName2): Ditto.
11+
(testGetHoverInfoTargetName1): Ditto.
612
* src/org/eclipse/linuxtools/cdt/autotools/tests/editors/AutomakeEditorTests.java (testAutomakeEditorAssociation): Ditto.
713

814
2010-11-18 Jeff Johnston <[email protected]>

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

+149-119
Original file line numberDiff line numberDiff line change
@@ -37,34 +37,34 @@ public class AutomakeTextHoverTest extends TestCase {
3737
private AutomakeTextHover textHover;
3838
private AutomakeEditor automakeEditor;
3939
private IDocument automakeDocument;
40-
40+
4141
static String makefileAmContents =
42-
// There are 6 characters from line beginning to
43-
// the space after the echo
44-
// ie. '\techo ' == 6 characters
45-
"MACRO = case1" + "\n" +
46-
// 14
47-
"target1:" + "\n" +
48-
// 23 (before the tab)
49-
// 32 is after the M in MACRO
50-
"\t" + "echo $(MACRO)" + "\n" +
51-
// 38 (before the tab)
52-
"\t" + "echo $@" + "\n" +
53-
"\n" +
54-
// 48
55-
"target2: target1" + "\n" +
56-
// 65 (before the tab)
57-
"\t" + "echo ${MACRO}" + "\n" +
58-
// 80 (before the tab)
59-
"\t" + "echo $@" + "\n" +
60-
// 89 (before the tab)
61-
"\t" + "echo $<" + "\n" +
62-
"\n" +
63-
// 99
64-
"target3: target1 target2" + "\n" +
65-
// 124 (before the tab)
66-
"\t" + "echo $?" + "\n" +
67-
"";
42+
// There are 6 characters from line beginning to
43+
// the space after the echo
44+
// ie. '\techo ' == 6 characters
45+
"MACRO = case1" + "\n" +
46+
// 14
47+
"target1:" + "\n" +
48+
// 23 (before the tab)
49+
// 32 is after the M in MACRO
50+
"\t" + "echo $(MACRO)" + "\n" +
51+
// 38 (before the tab)
52+
"\t" + "echo $@" + "\n" +
53+
"\n" +
54+
// 48
55+
"target2: target1" + "\n" +
56+
// 65 (before the tab)
57+
"\t" + "echo ${MACRO}" + "\n" +
58+
// 80 (before the tab)
59+
"\t" + "echo $@" + "\n" +
60+
// 89 (before the tab)
61+
"\t" + "echo $<" + "\n" +
62+
"\n" +
63+
// 99
64+
"target3: target1 target2" + "\n" +
65+
// 124 (before the tab)
66+
"\t" + "echo $?" + "\n" +
67+
"";
6868
private IWorkbench workbench;
6969

7070
protected void setUp() throws Exception {
@@ -104,118 +104,148 @@ public void run() {
104104

105105
});
106106
}
107-
107+
108108
protected void tearDown() throws Exception {
109109
super.tearDown();
110110
project.delete(true, false, ProjectTools.getMonitor());
111111
}
112-
112+
113113
public void testGetHoverInfoTargetName1() {
114-
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 45);
115-
if (hoverRegion == null)
116-
fail("Null hoverRegion");
117-
// hover between the $ and the @ in target1
118-
assertEquals(44, hoverRegion.getOffset());
119-
assertEquals(2, hoverRegion.getLength());
120-
try {
121-
assertEquals("$@", automakeDocument.get(hoverRegion.getOffset(),
122-
hoverRegion.getLength()));
123-
} catch (BadLocationException e) {
124-
fail("BadLocationException");
125-
e.printStackTrace();
126-
}
127-
assertEquals("target1", textHover.getHoverInfo(
128-
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
114+
Display.getDefault().syncExec(new Runnable() {
115+
116+
public void run() {
117+
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 45);
118+
if (hoverRegion == null)
119+
fail("Null hoverRegion");
120+
// hover between the $ and the @ in target1
121+
assertEquals(44, hoverRegion.getOffset());
122+
assertEquals(2, hoverRegion.getLength());
123+
try {
124+
assertEquals("$@", automakeDocument.get(hoverRegion.getOffset(),
125+
hoverRegion.getLength()));
126+
} catch (BadLocationException e) {
127+
fail("BadLocationException");
128+
e.printStackTrace();
129+
}
130+
assertEquals("target1", textHover.getHoverInfo(
131+
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
132+
}
133+
});
129134
}
130-
135+
131136
public void testGetHoverInfoTargetName2() {
132137
// hover between the $ and the @ in target2
133-
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 87);
134-
if (hoverRegion == null)
135-
fail("Null hoverRegion");
136-
assertEquals(86, hoverRegion.getOffset());
137-
assertEquals(2, hoverRegion.getLength());
138-
try {
139-
assertEquals("$@", automakeDocument.get(hoverRegion.getOffset(),
140-
hoverRegion.getLength()));
141-
} catch (BadLocationException e) {
142-
fail("BadLocationException");
143-
e.printStackTrace();
144-
}
145-
assertEquals("target2", textHover.getHoverInfo(
146-
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
138+
Display.getDefault().syncExec(new Runnable() {
139+
140+
public void run() {
141+
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 87);
142+
if (hoverRegion == null)
143+
fail("Null hoverRegion");
144+
assertEquals(86, hoverRegion.getOffset());
145+
assertEquals(2, hoverRegion.getLength());
146+
try {
147+
assertEquals("$@", automakeDocument.get(hoverRegion.getOffset(),
148+
hoverRegion.getLength()));
149+
} catch (BadLocationException e) {
150+
fail("BadLocationException");
151+
e.printStackTrace();
152+
}
153+
assertEquals("target2", textHover.getHoverInfo(
154+
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
155+
}
156+
});
147157
}
148-
158+
149159
public void testGetHoverInfoForTargetDependency() {
150160
// hover between the $ and the < in target2
151-
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 96);
152-
if (hoverRegion == null)
153-
fail("Null hoverRegion");
154-
assertEquals(95, hoverRegion.getOffset());
155-
assertEquals(2, hoverRegion.getLength());
156-
try {
157-
assertEquals("$<", automakeDocument.get(hoverRegion.getOffset(),
158-
hoverRegion.getLength()));
159-
} catch (BadLocationException e) {
160-
fail("BadLocationException");
161-
e.printStackTrace();
162-
}
163-
assertEquals("target1", textHover.getHoverInfo(
164-
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
161+
Display.getDefault().syncExec(new Runnable() {
162+
163+
public void run() {
164+
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 96);
165+
if (hoverRegion == null)
166+
fail("Null hoverRegion");
167+
assertEquals(95, hoverRegion.getOffset());
168+
assertEquals(2, hoverRegion.getLength());
169+
try {
170+
assertEquals("$<", automakeDocument.get(hoverRegion.getOffset(),
171+
hoverRegion.getLength()));
172+
} catch (BadLocationException e) {
173+
fail("BadLocationException");
174+
e.printStackTrace();
175+
}
176+
assertEquals("target1", textHover.getHoverInfo(
177+
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
178+
}
179+
});
165180
}
166-
181+
167182
public void testGetHoverInfoForTargetDependencies() {
168183
// hover between the $ and the ? in target3
169-
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 131);
170-
if (hoverRegion == null)
171-
fail("Null hoverRegion");
172-
assertEquals(130, hoverRegion.getOffset());
173-
assertEquals(2, hoverRegion.getLength());
174-
try {
175-
assertEquals("$?", automakeDocument.get(hoverRegion.getOffset(),
176-
hoverRegion.getLength()));
177-
} catch (BadLocationException e) {
178-
fail("BadLocationException");
179-
e.printStackTrace();
180-
}
181-
assertEquals("target1 target2", textHover.getHoverInfo(
182-
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
184+
Display.getDefault().syncExec(new Runnable() {
185+
186+
public void run() {
187+
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 131);
188+
if (hoverRegion == null)
189+
fail("Null hoverRegion");
190+
assertEquals(130, hoverRegion.getOffset());
191+
assertEquals(2, hoverRegion.getLength());
192+
try {
193+
assertEquals("$?", automakeDocument.get(hoverRegion.getOffset(),
194+
hoverRegion.getLength()));
195+
} catch (BadLocationException e) {
196+
fail("BadLocationException");
197+
e.printStackTrace();
198+
}
199+
assertEquals("target1 target2", textHover.getHoverInfo(
200+
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
201+
}
202+
});
183203
}
184204

185205
public void testGetHoverForMacro1() {
186-
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 32);
187-
if (hoverRegion == null)
188-
fail("Null hoverRegion");
189-
// hover between the M and the A in the first $(MACRO) reference
190-
assertEquals(31, hoverRegion.getOffset());
191-
assertEquals(5, hoverRegion.getLength());
192-
try {
193-
assertEquals("MACRO", automakeDocument.get(hoverRegion.getOffset(),
194-
hoverRegion.getLength()));
195-
} catch (BadLocationException e) {
196-
fail("BadLocationException");
197-
e.printStackTrace();
198-
}
199-
assertEquals("case1", textHover.getHoverInfo(
200-
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
206+
Display.getDefault().syncExec(new Runnable() {
207+
208+
public void run() {
209+
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 32);
210+
if (hoverRegion == null)
211+
fail("Null hoverRegion");
212+
// hover between the M and the A in the first $(MACRO) reference
213+
assertEquals(31, hoverRegion.getOffset());
214+
assertEquals(5, hoverRegion.getLength());
215+
try {
216+
assertEquals("MACRO", automakeDocument.get(hoverRegion.getOffset(),
217+
hoverRegion.getLength()));
218+
} catch (BadLocationException e) {
219+
fail("BadLocationException");
220+
e.printStackTrace();
221+
}
222+
assertEquals("case1", textHover.getHoverInfo(
223+
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
224+
}
225+
});
201226
}
202-
227+
203228
public void testGetHoverForMacro2() {
204229
// hover between the M and the A in the ${MACRO} reference in target2
205-
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 74);
206-
if (hoverRegion == null)
207-
fail("Null hoverRegion");
208-
assertEquals(73, hoverRegion.getOffset());
209-
assertEquals(5, hoverRegion.getLength());
210-
try {
211-
assertEquals("MACRO", automakeDocument.get(hoverRegion.getOffset(),
212-
hoverRegion.getLength()));
213-
} catch (BadLocationException e) {
214-
fail("BadLocationException");
215-
e.printStackTrace();
216-
}
217-
assertEquals("case1", textHover.getHoverInfo(
218-
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
230+
Display.getDefault().syncExec(new Runnable() {
231+
232+
public void run() {
233+
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 74);
234+
if (hoverRegion == null)
235+
fail("Null hoverRegion");
236+
assertEquals(73, hoverRegion.getOffset());
237+
assertEquals(5, hoverRegion.getLength());
238+
try {
239+
assertEquals("MACRO", automakeDocument.get(hoverRegion.getOffset(),
240+
hoverRegion.getLength()));
241+
} catch (BadLocationException e) {
242+
fail("BadLocationException");
243+
e.printStackTrace();
244+
}
245+
assertEquals("case1", textHover.getHoverInfo(
246+
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
247+
}
248+
});
219249
}
220250

221251
}

0 commit comments

Comments
 (0)