Skip to content

Commit

Permalink
Refactoring the AbstractLinkedEditingIntegrationTest test cases.
Browse files Browse the repository at this point in the history
- Deprecate the waitForDisplay() method in the
AbstractLinkedEditingIntegrationTest class in favor of the
waitForEventProcessing() method in the AbstractWorkbenchTest class.
- Modify the test cases inherited from the
AbstractLinkedEditingIntegrationTest base class to use the preferred
method instead of the deprecated one.

Signed-off-by: miklossy <[email protected]>
  • Loading branch information
miklossy committed Jul 10, 2024
1 parent 60240c9 commit f17d252
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2017 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2011, 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -32,6 +32,10 @@ public void process(XtextResource state) throws Exception {
});
}

/**
* @deprecated, use the inherited {@link AbstractWorkbenchTest#waitForEventProcessing} method instead.
*/
@Deprecated
protected void waitForDisplay() {
while(Display.getDefault().readAndDispatch()) {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2017 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2011, 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -77,7 +77,7 @@ protected void smudge(ITextEditor... editors) throws BadLocationException {
if(editor instanceof XtextEditor) {
waitForReconciler((XtextEditor) editor);
}
waitForDisplay();
waitForEventProcessing();
assertTrue(editor.isDirty());
}
}
Expand Down Expand Up @@ -240,7 +240,7 @@ protected void smudge(ITextEditor... editors) throws BadLocationException {

protected void renameFooToFooBar(final XtextEditor contextEditor) throws Exception {
contextEditor.getEditorSite().getPage().activate(contextEditor);
waitForDisplay();
waitForEventProcessing();
IXtextDocument document = contextEditor.getDocument();
final int offset = document.get().indexOf("foo");
contextEditor.selectAndReveal(offset, 3);
Expand All @@ -262,9 +262,9 @@ protected void renameFooToFooBar(final XtextEditor contextEditor) throws Excepti
// controller.startRefactoring(RefactoringType.LINKED_EDITING);
// waitForDisplay();
pressKeys(contextEditor, "fooBar\n");
waitForDisplay();
waitForEventProcessing();
waitForReconciler(fooEditor);
waitForReconciler(barEditor);
waitForDisplay();
waitForEventProcessing();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2017 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2011, 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -87,7 +87,7 @@ public void setUp() throws Exception {
final XtextEditor editor = openEditor(file);
final TextSelection selection = new TextSelection(model.indexOf(TEST_CLASS), TEST_CLASS.length());
editor.getSelectionProvider().setSelection(selection);
waitForDisplay();
waitForEventProcessing();
IRenameElementContext context = editor.getDocument().readOnly(new IUnitOfWork<IRenameElementContext, XtextResource>() {
@Override
public IRenameElementContext exec(XtextResource state) throws Exception {
Expand All @@ -98,10 +98,10 @@ public IRenameElementContext exec(XtextResource state) throws Exception {
}
});
renameRefactoringController.startRefactoring(context);
waitForDisplay();
waitForEventProcessing();
pressKeys(editor, "NewTestClass\n");
waitForReconciler(editor);
waitForDisplay();
waitForEventProcessing();
waitForBuild();
ecoreResource.load(null);
assertEquals("NewTestClass", ((EPackage)ecoreResource.getContents().get(0)).getEClassifiers().get(0).getName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2020 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2011, 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -160,7 +160,7 @@ public void testRefactorXtextGrammarWithoutGeneratedClassifier() throws Exceptio
final XtextEditor editor = openEditor(grammarFile);
doRefactoring(editor);
waitForReconciler(editor);
waitForDisplay();
waitForEventProcessing();
waitForBuild();
checkConsistenceOfGrammar(editor);
}
Expand Down Expand Up @@ -217,7 +217,7 @@ public void testRefactorXtextGrammarWithGeneratedClassifierAndModelWithRefToClas
refToGreetingResource.unload();
ecoreModelResource.unload();
waitForBuild();
waitForDisplay();
waitForEventProcessing();
XtextEditor editor = openEditor(grammarFile);
doRefactoring(editor);
waitForBuild();
Expand Down Expand Up @@ -273,13 +273,13 @@ private Resource createEcoreModel(ResourceSet rs, URI uri, EObject rootElement)
private XtextEditor doRefactoring(XtextEditor editor) throws Exception {
final TextSelection selection = new TextSelection(grammar.indexOf(CLASSIFIERNAME), CLASSIFIERNAME.length());
editor.getSelectionProvider().setSelection(selection);
waitForDisplay();
waitForEventProcessing();
IRenameElementContext context = new IRenameElementContext.Impl(greetingParserRuleUri,
XtextPackage.Literals.PARSER_RULE, editor, selection, grammarUri);
renameRefactoringController.startRefactoring(context);
waitForDisplay();
waitForEventProcessing();
pressKeys(editor, REFACTOREDCLASSIFIERNAME + "\n");
waitForDisplay();
waitForEventProcessing();
return editor;
}

Expand Down

0 comments on commit f17d252

Please sign in to comment.