use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.
the class AntEditorTests method testHoverForPath.
public void testHoverForPath() throws PartInitException, BadLocationException {
// $NON-NLS-1$
IFile file = getIFile("refid.xml");
// $NON-NLS-1$
AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true);
XMLTextHover hover = new XMLTextHover(editor);
int offset = getOffsetWithinLine(editor, 9, 20);
IRegion region = hover.getHoverRegion(editor.getViewer(), offset);
String hoverText = hover.getHoverInfo(editor.getViewer(), region);
// $NON-NLS-1$
assertNotNull("Expecting a hovertext object", hoverText);
// $NON-NLS-1$
String correctResultRegEx = "<html><body text=\"#.*\" bgcolor=\"#.*\"><h5>Path Elements:</h5><ul><li>.*</html>";
// $NON-NLS-1$
assertTrue("Expected the following hover text to match regex: " + correctResultRegEx, hoverText.matches(correctResultRegEx));
}
use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.
the class AntEditorTests method testPatternSetHover.
public void testPatternSetHover() throws PartInitException, BadLocationException {
// $NON-NLS-1$
IFile file = getIFile("refid.xml");
// $NON-NLS-1$
AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true);
XMLTextHover hover = new XMLTextHover(editor);
int offset = getOffsetWithinLine(editor, 45, 25);
IRegion region = hover.getHoverRegion(editor.getViewer(), offset);
String hoverText = hover.getHoverInfo(editor.getViewer(), region);
// $NON-NLS-1$
assertNotNull("Expecting a hovertext object", hoverText);
// $NON-NLS-1$
String correctResult = "<h5>Includes:</h5><li>*.xml</li><p><p><h5>Excludes:</h5><li>**/*Test*</li></body></html>";
// $NON-NLS-1$ //$NON-NLS-2$
assertTrue("Expected the following hover text to end with: " + correctResult + "was: " + hoverText, hoverText.endsWith(correctResult));
}
use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.
the class AntEditorTests method testHoverRegionWithSpaces.
public void testHoverRegionWithSpaces() throws PartInitException, BadLocationException {
// $NON-NLS-1$
IFile file = getIFile("refid.xml");
// $NON-NLS-1$
AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true);
XMLTextHover hover = new XMLTextHover(editor);
// in the middle of the "compile" target of the depends attribute
int offset = getOffsetWithinLine(editor, 22, 39);
IRegion region = hover.getHoverRegion(editor.getViewer(), offset);
assertNotNull(region);
IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
String text = doc.get(region.getOffset(), region.getLength());
assertTrue(// $NON-NLS-1$ //$NON-NLS-2$
"Region incorrect. Expected length of 7 and text of \"compile\", length was " + region.getLength() + " and text was " + text, // $NON-NLS-1$
region.getLength() == 7 && "compile".equals(text));
}
Aggregations