use of org.eclipse.linuxtools.internal.rpm.ui.editor.hyperlink.SpecfileElementHyperlinkDetector 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);
}
use of org.eclipse.linuxtools.internal.rpm.ui.editor.hyperlink.SpecfileElementHyperlinkDetector in project linuxtools by eclipse.
the class SpecfileElementHyperlinkDetectorTest method testDetectHyperlinks.
@Test
public void testDetectHyperlinks() throws PartInitException {
String testText = "%define smth other\nSource0: test.zip\nPatch0: first.patch\n" + "%build\n %{SOURCE0}\n%patch0\n%{smth}\n";
newFile(testText);
SpecfileElementHyperlinkDetector elementDetector = new SpecfileElementHyperlinkDetector();
elementDetector.setSpecfile(specfile);
IEditorPart openEditor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), testFile, "org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor");
editor = (SpecfileEditor) openEditor;
editor.doRevertToSaved();
// test source element
IRegion region = new Region(74, 0);
IHyperlink[] returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
SpecfileElementHyperlink element = (SpecfileElementHyperlink) returned[0];
assertTrue(element.getSource() instanceof SpecfileSource);
SpecfileSource source = (SpecfileSource) element.getSource();
assertEquals(source.getSourceType(), SpecfileSource.SourceType.SOURCE);
assertEquals(source.getFileName(), "test.zip");
// test patch element
region = new Region(83, 0);
returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
element = (SpecfileElementHyperlink) returned[0];
assertTrue(element.getSource() instanceof SpecfileSource);
source = (SpecfileSource) element.getSource();
assertEquals(source.getSourceType(), SpecfileSource.SourceType.PATCH);
assertEquals(source.getFileName(), "first.patch");
// test define
region = new Region(89, 0);
returned = elementDetector.detectHyperlinks(editor.getSpecfileSourceViewer(), region, false);
element = (SpecfileElementHyperlink) returned[0];
assertTrue(element.getSource() instanceof SpecfileDefine);
SpecfileDefine define = (SpecfileDefine) element.getSource();
assertEquals(define.getName(), "smth");
assertEquals(define.getStringValue(), "other");
}
Aggregations