Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.ui.genericeditor.tests;singleton:=true
Bundle-Version: 1.3.500.qualifier
Bundle-Version: 1.3.600.qualifier
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.ui.genericeditor.tests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
*/
public class HoverTest extends AbstratGenericEditorTest {

private static final int MAXIMUM_HOVER_RETRY_COUNT = 5;

@Rule
public TestName testName= new TestName();

Expand Down Expand Up @@ -227,38 +229,43 @@ private Object getHoverData(AbstractInformationControlManager manager) {
}

private AbstractInformationControlManager triggerCompletionAndRetrieveInformationControlManager() {
final int caretLocation= 2;
this.editor.selectAndReveal(caretLocation, 0);
final StyledText editorTextWidget= (StyledText) this.editor.getAdapter(Control.class);
new DisplayHelper() {
@Override
protected boolean condition() {
return editorTextWidget.isFocusControl() && editorTextWidget.getSelection().x == caretLocation;
}
}.waitForCondition(editorTextWidget.getDisplay(), 3000);
// sending event to trigger hover computation
editorTextWidget.getShell().forceActive();
editorTextWidget.getShell().setActive();
editorTextWidget.getShell().setFocus();
editorTextWidget.getShell().getDisplay().wake();
Event hoverEvent= new Event();
hoverEvent.widget= editorTextWidget;
hoverEvent.type= SWT.MouseHover;
hoverEvent.x= editorTextWidget.getClientArea().x + 5;
hoverEvent.y= editorTextWidget.getClientArea().y + 5;
hoverEvent.display= editorTextWidget.getDisplay();
hoverEvent.doit= true;
editorTextWidget.getDisplay().setCursorLocation(editorTextWidget.toDisplay(hoverEvent.x, hoverEvent.y));
editorTextWidget.notifyListeners(SWT.MouseHover, hoverEvent);
boolean foundHoverData = false;
int attemptNumber = 0;

ITextViewer viewer= (ITextViewer) new Accessor(editor, AbstractTextEditor.class).invoke("getSourceViewer", new Object[0]);
AbstractInformationControlManager textHoverManager= (AbstractInformationControlManager) new Accessor(viewer, TextViewer.class).get("fTextHoverManager");
// retrieving hover content
new DisplayHelper() {
@Override
protected boolean condition() {
return getHoverData(textHoverManager) != null;
}
}.waitForCondition(hoverEvent.display, 6000);

while (!foundHoverData && attemptNumber++ < MAXIMUM_HOVER_RETRY_COUNT) {
final int caretLocation= 2;
editor.setFocus();
this.editor.selectAndReveal(caretLocation, 0);
final StyledText editorTextWidget= (StyledText) this.editor.getAdapter(Control.class);
new DisplayHelper() {
@Override
protected boolean condition() {
return editorTextWidget.isFocusControl() && editorTextWidget.getSelection().x == caretLocation;
}
}.waitForCondition(editorTextWidget.getDisplay(), 3000);
assertTrue("editor does not have focus", editorTextWidget.isFocusControl());
// sending event to trigger hover computation
Event hoverEvent= new Event();
hoverEvent.widget= editorTextWidget;
hoverEvent.type= SWT.MouseHover;
hoverEvent.x= editorTextWidget.getClientArea().x + 5;
hoverEvent.y= editorTextWidget.getClientArea().y + 5;
hoverEvent.display= editorTextWidget.getDisplay();
hoverEvent.doit= true;
editorTextWidget.getDisplay().setCursorLocation(editorTextWidget.toDisplay(hoverEvent.x, hoverEvent.y));
editorTextWidget.notifyListeners(SWT.MouseHover, hoverEvent);
// retrieving hover content
foundHoverData = new DisplayHelper() {
@Override
protected boolean condition() {
return getHoverData(textHoverManager) != null;
}
}.waitForCondition(hoverEvent.display, 6000);
}
assertTrue("hover data not found", foundHoverData);
return textHoverManager;
}
}
Loading