use of org.eclipse.jface.text.hyperlink.IHyperlink in project linuxtools by eclipse.
the class MailHyperlinkDetectorTest method testDetectHyperlinks.
@Test
public void testDetectHyperlinks() throws PartInitException {
String testText = "Version: 0.0\n" + "Release: 0\n" + "%changelog\n" + "* Fri Feb 27 2009 Test <someone@smth.com> 3.3.2.4-6\n-\n" + "* Fri Feb 27 2009 Test someone@smth.com 3.3.2.4-6\n-\n";
newFile(testText);
IEditorPart openEditor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), testFile, "org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor");
editor = (SpecfileEditor) openEditor;
editor.doRevertToSaved();
MailHyperlinkDetector elementDetector = new MailHyperlinkDetector();
elementDetector.setEditor(editor);
// test mail
IRegion region = new Region(38, 0);
IHyperlink[] returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
assertEquals(1, returned.length);
assertTrue(returned[0] instanceof MailHyperlink);
region = new Region(124, 0);
returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
assertEquals(1, returned.length);
assertTrue(returned[0] instanceof MailHyperlink);
}
use of org.eclipse.jface.text.hyperlink.IHyperlink in project linuxtools by eclipse.
the class SourcesFileHyperlinkDetectorTest method testDetectNoPatchInProject.
@Test
public void testDetectNoPatchInProject() throws PartInitException {
IEditorPart openEditor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), testFile, "org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor");
editor = (SpecfileEditor) openEditor;
editor.doRevertToSaved();
SourcesFileHyperlinkDetector elementDetector = new SourcesFileHyperlinkDetector();
elementDetector.setEditor(editor);
// test patch element
IRegion region = new Region(27, 0);
IHyperlink[] returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
// 1 = Create test.patch because test.patch doesn't exist in current project
assertEquals(1, returned.length);
}
use of org.eclipse.jface.text.hyperlink.IHyperlink in project linuxtools by eclipse.
the class SourcesFileHyperlinkDetectorTest method testDetectHyperlinksValidURL.
@Test
public void testDetectHyperlinksValidURL() throws PartInitException {
IEditorPart openEditor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), testFile, "org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor");
editor = (SpecfileEditor) openEditor;
editor.doRevertToSaved();
SourcesFileHyperlinkDetector elementDetector = new SourcesFileHyperlinkDetector();
elementDetector.setEditor(editor);
// test source2 element
IRegion region = new Region(82, 0);
IHyperlink[] returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
// 1 = Download from URL (Open in browser should not show up because URLHyperlinkWithMacroDetector detects that)
assertEquals(1, returned.length);
}
use of org.eclipse.jface.text.hyperlink.IHyperlink in project linuxtools by eclipse.
the class SourcesFileHyperlinkDetectorTest method testDetectHyperlinks.
@Test
public void testDetectHyperlinks() throws PartInitException {
IEditorPart openEditor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), testFile, "org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor");
editor = (SpecfileEditor) openEditor;
editor.doRevertToSaved();
SourcesFileHyperlinkDetector elementDetector = new SourcesFileHyperlinkDetector();
elementDetector.setEditor(editor);
// test source0 element
IRegion region = new Region(10, 0);
IHyperlink[] returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
// because test.zip does not exist, and is not a valid url
// it should not have hyperlinks
assertNull(returned);
}
use of org.eclipse.jface.text.hyperlink.IHyperlink in project linuxtools by eclipse.
the class SpecfileElementHyperlinkDetectorTest method testDetectHyperlinksNoRegionAndTextViewer.
@Test
public void testDetectHyperlinksNoRegionAndTextViewer() {
SpecfileElementHyperlinkDetector elementDetector = new SpecfileElementHyperlinkDetector();
elementDetector.setSpecfile(specfile);
IHyperlink[] returned = elementDetector.detectHyperlinks(null, null, false);
assertNull(returned);
}
Aggregations