17
17
import static org .eclipse .ui .genericeditor .tests .contributions .LongRunningBarContentAssistProcessor .LONG_RUNNING_BAR_CONTENT_ASSIST_PROPOSAL ;
18
18
import static org .hamcrest .CoreMatchers .endsWith ;
19
19
import static org .hamcrest .MatcherAssert .assertThat ;
20
- import static org .junit .Assert .assertEquals ;
21
- import static org .junit .Assert .assertFalse ;
22
- import static org .junit .Assert .assertNotNull ;
23
- import static org .junit .Assert .assertNull ;
24
- import static org .junit .Assert .assertTrue ;
25
- import static org .junit .Assert .fail ;
26
- import static org .junit .Assume .assumeFalse ;
20
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
21
+ import static org .junit .jupiter .api .Assertions .assertFalse ;
22
+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
23
+ import static org .junit .jupiter .api .Assertions .assertNull ;
24
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
25
+ import static org .junit .jupiter .api .Assertions .fail ;
27
26
28
27
import java .util .ArrayList ;
29
28
import java .util .Arrays ;
36
35
import java .util .function .BooleanSupplier ;
37
36
import java .util .stream .Collectors ;
38
37
39
- import org .junit .After ;
40
- import org .junit .Test ;
38
+ import org .junit .jupiter .api .AfterEach ;
39
+ import org .junit .jupiter .api .Test ;
40
+ import org .junit .jupiter .api .condition .DisabledOnOs ;
41
+ import org .junit .jupiter .api .condition .OS ;
41
42
import org .osgi .framework .Bundle ;
42
43
import org .osgi .framework .BundleContext ;
43
44
import org .osgi .framework .FrameworkUtil ;
60
61
import org .eclipse .core .runtime .IStatus ;
61
62
import org .eclipse .core .runtime .Platform ;
62
63
63
- import org .eclipse .jface .util .Util ;
64
-
65
64
import org .eclipse .jface .text .ITextSelection ;
66
65
import org .eclipse .jface .text .ITextViewer ;
67
66
import org .eclipse .jface .text .contentassist .ICompletionProposal ;
@@ -85,14 +84,16 @@ public class CompletionTest extends AbstratGenericEditorTest {
85
84
private Shell completionShell ;
86
85
87
86
@ Test
87
+ @ DisabledOnOs (value = OS .MAC , disabledReason = "test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" )
88
88
public void testCompletion () throws Exception {
89
- assumeFalse ("test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" , Util .isMac ());
90
89
editor .selectAndReveal (3 , 0 );
91
- this .completionShell = openConentAssist ();
90
+ this .completionShell = openConentAssist ();
92
91
final Table completionProposalList = findCompletionSelectionControl (completionShell );
93
92
checkCompletionContent (completionProposalList );
94
- // TODO find a way to actually trigger completion and verify result against Editor content
95
- // Assert.assertEquals("Completion didn't complete", "bars are good for a beer.", ((StyledText)editor.getAdapter(Control.class)).getText());
93
+ // TODO find a way to actually trigger completion and verify result against
94
+ // Editor content
95
+ // Assert.assertEquals("Completion didn't complete", "bars are good for a
96
+ // beer.", ((StyledText)editor.getAdapter(Control.class)).getText());
96
97
}
97
98
98
99
@ Test
@@ -103,13 +104,13 @@ public void testDefaultContentAssistBug570488() throws Exception {
103
104
createAndOpenFile ("Bug570488.txt" , "bar 'bar'" );
104
105
openConentAssist (false );
105
106
DisplayHelper .runEventLoop (Display .getCurrent (), 0 );
106
- assertFalse ("There are errors in the log" , listener .messages .stream ().anyMatch (s -> s .matches (IStatus .ERROR )));
107
+ assertFalse (listener .messages .stream ().anyMatch (s -> s .matches (IStatus .ERROR )), "There are errors in the log" );
107
108
log .removeLogListener (listener );
108
109
}
109
110
110
111
@ Test
112
+ @ DisabledOnOs (value = OS .MAC , disabledReason = "test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" )
111
113
public void testCompletionService () throws Exception {
112
- assumeFalse ("test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" , Util .isMac ());
113
114
Bundle bundle = FrameworkUtil .getBundle (CompletionTest .class );
114
115
assertNotNull (bundle );
115
116
BundleContext bundleContext = bundle .getBundleContext ();
@@ -122,13 +123,13 @@ public void testCompletionService() throws Exception {
122
123
this .completionShell = openConentAssist ();
123
124
final Table completionProposalList = findCompletionSelectionControl (completionShell );
124
125
checkCompletionContent (completionProposalList );
125
- assertTrue ("Service was not called!" , service . called );
126
+ assertTrue (service . called , "Service was not called!" );
126
127
registration .unregister ();
127
128
}
128
129
129
130
@ Test
131
+ @ DisabledOnOs (value = OS .MAC , disabledReason = "test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" )
130
132
public void testCompletionUsingViewerSelection () throws Exception {
131
- assumeFalse ("test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" , Util .isMac ());
132
133
editor .getDocumentProvider ().getDocument (editor .getEditorInput ()).set ("abc" );
133
134
editor .selectAndReveal (0 , 3 );
134
135
this .completionShell = openConentAssist ();
@@ -138,13 +139,10 @@ public void testCompletionUsingViewerSelection() throws Exception {
138
139
}
139
140
140
141
private static void waitForProposalRelatedCondition (String errorMessage , Table completionProposalList , BooleanSupplier condition , int timeoutInMsec ) {
141
- assertTrue (errorMessage , new DisplayHelper () {
142
- @ Override
143
- protected boolean condition () {
144
- assertFalse ("Completion proposal list was unexpectedly disposed" , completionProposalList .isDisposed ());
145
- return condition .getAsBoolean ();
146
- }
147
- }.waitForCondition (completionProposalList .getDisplay (), timeoutInMsec ));
142
+ assertTrue (DisplayHelper .waitForCondition (completionProposalList .getDisplay (), timeoutInMsec , () -> {
143
+ assertFalse (completionProposalList .isDisposed (), "Completion proposal list was unexpectedly disposed" );
144
+ return condition .getAsBoolean ();
145
+ }), errorMessage );
148
146
}
149
147
150
148
@ Test
@@ -153,7 +151,7 @@ public void testEnabledWhenCompletion() throws Exception {
153
151
EnabledPropertyTester .setEnabled (false );
154
152
createAndOpenFile ("enabledWhen.txt" , "bar 'bar'" );
155
153
editor .selectAndReveal (3 , 0 );
156
- assertNull ("A new shell was found" , openConentAssist ( false ) );
154
+ assertNull (openConentAssist ( false ), "A new shell was found" );
157
155
cleanFileAndEditor ();
158
156
159
157
// Confirm that when enabled, a completion shell is present
@@ -187,8 +185,8 @@ private void checkCompletionContent(final Table completionProposalList) {
187
185
// should be instantaneous, but happens to go asynchronous on CI so let's allow a wait
188
186
waitForProposalRelatedCondition ("Proposal list did not show two initial items" , completionProposalList ,
189
187
() -> completionProposalList .getItemCount () == 2 , 200 );
190
- assertTrue ("Missing computing info entry" , isComputingInfoEntry (completionProposalList .getItem (0 )));
191
- assertTrue ("Missing computing info entry in proposal list" , isComputingInfoEntry ( completionProposalList . getItem ( 0 )) );
188
+ assertTrue (isComputingInfoEntry (completionProposalList .getItem (0 )), "Missing computing info entry" );
189
+ assertTrue (isComputingInfoEntry ( completionProposalList . getItem ( 0 )), "Missing computing info entry in proposal list" );
192
190
final TableItem initialProposalItem = completionProposalList .getItem (1 );
193
191
final String initialProposalString = ((ICompletionProposal )initialProposalItem .getData ()).getDisplayString ();
194
192
assertThat ("Unexpected initial proposal item" ,
@@ -205,7 +203,7 @@ private void checkCompletionContent(final Table completionProposalList) {
205
203
assertThat ("Unexpected first proposal item" , BAR_CONTENT_ASSIST_PROPOSAL , endsWith (firstCompletionProposalText ));
206
204
assertThat ("Unexpected second proposal item" , LONG_RUNNING_BAR_CONTENT_ASSIST_PROPOSAL , endsWith (secondCompletionProposalText ));
207
205
String selectedProposalString = ((ICompletionProposal )completionProposalList .getSelection ()[0 ].getData ()).getDisplayString ();
208
- assertEquals ("Addition of completion proposal should keep selection" , initialProposalString , selectedProposalString );
206
+ assertEquals (initialProposalString , selectedProposalString , "Addition of completion proposal should keep selection" );
209
207
}
210
208
211
209
private static boolean isComputingInfoEntry (TableItem item ) {
@@ -218,33 +216,33 @@ public static Shell findNewShell(Set<Shell> beforeShells, Display display, boole
218
216
.filter (shell -> !beforeShells .contains (shell ))
219
217
.toArray (Shell []::new );
220
218
if (expectShell ) {
221
- assertEquals ("No new shell found" , 1 , afterShells . length );
219
+ assertEquals (1 , afterShells . length , "No new shell found" );
222
220
}
223
221
return afterShells .length > 0 ? afterShells [0 ] : null ;
224
222
}
225
223
226
224
@ Test
225
+ @ DisabledOnOs (value = OS .MAC , disabledReason = "test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" )
227
226
public void testCompletionFreeze_bug521484 () throws Exception {
228
- assumeFalse ("test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" , Util .isMac ());
229
227
editor .selectAndReveal (3 , 0 );
230
228
this .completionShell =openConentAssist ();
231
229
final Table completionProposalList = findCompletionSelectionControl (this .completionShell );
232
230
// should be instantaneous, but happens to go asynchronous on CI so let's allow a wait
233
231
waitForProposalRelatedCondition ("Proposal list did not show two items" , completionProposalList ,
234
232
() -> completionProposalList .getItemCount () == 2 , 200 );
235
- assertTrue ("Missing computing info entry" , isComputingInfoEntry (completionProposalList .getItem (0 )));
233
+ assertTrue (isComputingInfoEntry (completionProposalList .getItem (0 )), "Missing computing info entry" );
236
234
// Some processors are long running, moving cursor can cause freeze (bug 521484)
237
235
// asynchronous
238
236
long timestamp = System .currentTimeMillis ();
239
237
emulatePressLeftArrowKey ();
240
238
DisplayHelper .sleep (editor .getSite ().getShell ().getDisplay (), 200 ); //give time to process events
241
239
long processingDuration = System .currentTimeMillis () - timestamp ;
242
- assertTrue ("UI Thread frozen for " + processingDuration + "ms" , processingDuration < LongRunningBarContentAssistProcessor . DELAY );
240
+ assertTrue (processingDuration < LongRunningBarContentAssistProcessor . DELAY , "UI Thread frozen for " + processingDuration + "ms" );
243
241
}
244
242
245
243
@ Test
244
+ @ DisabledOnOs (value = OS .MAC , disabledReason = "test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" )
246
245
public void testMoveCaretBackUsesAllProcessors_bug522255 () throws Exception {
247
- assumeFalse ("test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" , Util .isMac ());
248
246
testCompletion ();
249
247
emulatePressLeftArrowKey ();
250
248
final Set <Shell > beforeShells = Arrays .stream (editor .getSite ().getShell ().getDisplay ().getShells ()).filter (Shell ::isVisible ).collect (Collectors .toSet ());
@@ -280,7 +278,7 @@ public static Table findCompletionSelectionControl(Widget control) {
280
278
return null ;
281
279
}
282
280
283
- @ After
281
+ @ AfterEach
284
282
public void closeShell () {
285
283
if (this .completionShell != null && !completionShell .isDisposed ()) {
286
284
completionShell .close ();
0 commit comments