20
20
21
21
import java .util .List ;
22
22
23
- import org .eclipse .reddeer .common .wait .AbstractWait ;
24
23
import org .eclipse .reddeer .common .wait .TimePeriod ;
24
+ import org .eclipse .reddeer .common .wait .WaitWhile ;
25
25
import org .eclipse .reddeer .eclipse .jdt .ui .wizards .JavaProjectWizard ;
26
26
import org .eclipse .reddeer .eclipse .ui .navigator .resources .ProjectExplorer ;
27
27
import org .eclipse .reddeer .eclipse .wst .jsdt .ui .wizards .JavaProjectWizardFirstPage ;
28
28
import org .eclipse .reddeer .jface .text .contentassist .ContentAssistant ;
29
29
import org .eclipse .reddeer .junit .runner .RedDeerSuite ;
30
+ import org .eclipse .reddeer .swt .condition .ShellIsAvailable ;
30
31
import org .eclipse .reddeer .swt .impl .ctab .DefaultCTabItem ;
31
32
import org .eclipse .reddeer .workbench .impl .editor .DefaultEditor ;
32
33
@@ -73,15 +74,14 @@ public static void prepareEnvironment() {
73
74
createNewJavaProject (PROJECT_NAME );
74
75
new ProjectExplorer ().selectProjects (PROJECT_NAME );
75
76
createNewEmptyXMLFile (CAMEL_CONTEXT );
76
- DefaultEditor editor = new DefaultEditor (CAMEL_CONTEXT );
77
- editor .activate ();
77
+ new DefaultEditor (CAMEL_CONTEXT ).activate ();;
78
78
new DefaultCTabItem (EDITOR_SOURCE_TAB ).activate ();
79
79
EditorManipulator .copyFileContentToXMLEditor (RESOURCES_CONTEXT_PATH );
80
80
}
81
81
82
82
@ After
83
83
public void cleanEditor () {
84
- new DefaultEditor ( CAMEL_CONTEXT ) .activate ();
84
+ editor .activate ();
85
85
EditorManipulator .copyFileContentToXMLEditor (RESOURCES_CONTEXT_PATH );
86
86
}
87
87
@@ -116,7 +116,7 @@ public void testEndpointOptions() {
116
116
cursorPosition = editor .getText ().indexOf ("<from" );
117
117
editor .setCursorPosition (cursorPosition += 42 );
118
118
tryEndpointOptionsCompletion ();
119
-
119
+
120
120
cursorPosition = editor .getText ().indexOf ("<to" );
121
121
editor .setCursorPosition (cursorPosition += 42 );
122
122
tryEndpointOptionsCompletion ();
@@ -150,9 +150,9 @@ public void testDuplicateOptionsFiltering() {
150
150
editor = new SourceEditor ();
151
151
152
152
cursorPosition = editor .getText ().indexOf ("<from" );
153
- editor .setCursorPosition (cursorPosition += 42 );
153
+ editor .setCursorPosition (cursorPosition += 42 );
154
154
tryOptionsFiltering ();
155
-
155
+
156
156
cursorPosition = editor .getText ().indexOf ("<to" );
157
157
editor .setCursorPosition (cursorPosition += 42 );
158
158
tryOptionsFiltering ();
@@ -183,7 +183,6 @@ private static void createNewJavaProject(String name) {
183
183
}
184
184
185
185
private void assertComponentSchemes (List <String > proposals ) {
186
- AbstractWait .sleep (TimePeriod .MEDIUM );
187
186
collector .checkThat ("Content assistant is empty" , proposals .isEmpty (), equalTo (false ));
188
187
collector .checkThat ("Content assistant is not filtered" , proposals .get (0 ).startsWith ("f" ), equalTo (true ));
189
188
}
@@ -197,10 +196,9 @@ private void tryEndpointOptionsCompletion() {
197
196
assistant = editor .openContentAssistant ();
198
197
collector .checkThat (assistant .getProposals ().isEmpty (), equalTo (false ));
199
198
assistant .chooseProposal ("InOnly" );
200
- AbstractWait .sleep (TimePeriod .MEDIUM );
201
- if (editor .isDirty ()) {
202
- editor .save ();
203
- }
199
+
200
+ new WaitWhile (new ShellIsAvailable (assistant ), TimePeriod .MEDIUM );
201
+ editor .save ();
204
202
}
205
203
206
204
private void tryAdditionalOptionsCompletion () {
@@ -209,12 +207,11 @@ private void tryAdditionalOptionsCompletion() {
209
207
assistant = editor .openContentAssistant ();
210
208
collector .checkThat (assistant .getProposals ().isEmpty (), equalTo (false ));
211
209
assistant .chooseProposal ("allowNullBody" );
212
- AbstractWait .sleep (TimePeriod .MEDIUM );
213
- if (editor .isDirty ()) {
214
- editor .save ();
215
- }
210
+
211
+ new WaitWhile (new ShellIsAvailable (assistant ), TimePeriod .MEDIUM );
212
+ editor .save ();
216
213
}
217
-
214
+
218
215
private void tryOptionsFiltering () {
219
216
editor .insertText ("?e" );
220
217
editor .setCursorPosition (cursorPosition += 2 );
@@ -225,14 +222,14 @@ private void tryOptionsFiltering() {
225
222
collector .checkThat (assistant .getProposals ().isEmpty (), equalTo (false ));
226
223
assistant .chooseProposal ("InOnly" );
227
224
editor .insertText ("&e" );
228
- editor .setCursorPosition (cursorPosition += 27 );
225
+ editor .setCursorPosition (cursorPosition += 27 );
229
226
assistant = editor .openContentAssistant ();
230
227
collector .checkThat (assistant .getProposals ().isEmpty (), equalTo (false ));
231
228
collector .checkThat (assistant .getProposals ().contains ("exchangePattern" ), equalTo (false ));
232
229
assistant .close ();
233
- if ( editor . isDirty ()) {
234
- editor . save ( );
235
- }
230
+
231
+ new WaitWhile ( new ShellIsAvailable ( assistant ), TimePeriod . MEDIUM );
232
+ editor . save ();
236
233
}
237
234
238
235
}
0 commit comments