@@ -37,34 +37,34 @@ public class AutomakeTextHoverTest extends TestCase {
37
37
private AutomakeTextHover textHover ;
38
38
private AutomakeEditor automakeEditor ;
39
39
private IDocument automakeDocument ;
40
-
40
+
41
41
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
+ "" ;
68
68
private IWorkbench workbench ;
69
69
70
70
protected void setUp () throws Exception {
@@ -104,118 +104,148 @@ public void run() {
104
104
105
105
});
106
106
}
107
-
107
+
108
108
protected void tearDown () throws Exception {
109
109
super .tearDown ();
110
110
project .delete (true , false , ProjectTools .getMonitor ());
111
111
}
112
-
112
+
113
113
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
+ });
129
134
}
130
-
135
+
131
136
public void testGetHoverInfoTargetName2 () {
132
137
// 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
+ });
147
157
}
148
-
158
+
149
159
public void testGetHoverInfoForTargetDependency () {
150
160
// 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
+ });
165
180
}
166
-
181
+
167
182
public void testGetHoverInfoForTargetDependencies () {
168
183
// 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
+ });
183
203
}
184
204
185
205
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
+ });
201
226
}
202
-
227
+
203
228
public void testGetHoverForMacro2 () {
204
229
// 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
+ });
219
249
}
220
250
221
251
}
0 commit comments