Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-02-04 14:42:30 +0000
committerBenjamin Muskalla2012-03-23 15:35:29 +0000
commit31a9c126a5ad439cba2bdf3ddb04bac725fda1c9 (patch)
treec2af906f13b371a162f04730710e2a51589c94ca /org.eclipse.egit.mylyn.ui.test
parente0c4133d00ac9ef7b2056ff91ac2bdfd076336c7 (diff)
downloadegit-31a9c126a5ad439cba2bdf3ddb04bac725fda1c9.tar.gz
egit-31a9c126a5ad439cba2bdf3ddb04bac725fda1c9.tar.xz
egit-31a9c126a5ad439cba2bdf3ddb04bac725fda1c9.zip
Fix regions decorated by commit hyperlink detector
* The offset of the hyperlinked region is now calculated correctly. * Gerrit change ids are not detected as commit ids. * Performance is improved through using a regular expression rather than tokenizing the text. Bug: 355868 Change-Id: I35e36dc057a4ce1279836cf1aa65cbea6f83dbdb
Diffstat (limited to 'org.eclipse.egit.mylyn.ui.test')
-rw-r--r--org.eclipse.egit.mylyn.ui.test/src/org/eclipse/egit/internal/mylyn/CommitHyperlinkDetectorTest.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/org.eclipse.egit.mylyn.ui.test/src/org/eclipse/egit/internal/mylyn/CommitHyperlinkDetectorTest.java b/org.eclipse.egit.mylyn.ui.test/src/org/eclipse/egit/internal/mylyn/CommitHyperlinkDetectorTest.java
index b8b97c155e..1f16511747 100644
--- a/org.eclipse.egit.mylyn.ui.test/src/org/eclipse/egit/internal/mylyn/CommitHyperlinkDetectorTest.java
+++ b/org.eclipse.egit.mylyn.ui.test/src/org/eclipse/egit/internal/mylyn/CommitHyperlinkDetectorTest.java
@@ -118,6 +118,30 @@ public class CommitHyperlinkDetectorTest {
assertNull(hyperlinks);
}
+ @Test
+ public void testMultiLine() {
+ setText("Test multi-line text\n" + EXAMPLE_ID);
+ IHyperlink[] hyperlinks = detectHyperlinks(0,textViewer.getDocument().getLength());
+ assertEquals(1, hyperlinks.length);
+ assertEquals(EXAMPLE_ID, hyperlinks[0].getHyperlinkText());
+ assertEquals(new Region(21, EXAMPLE_ID.length()), hyperlinks[0].getHyperlinkRegion());
+ }
+
+ @Test
+ public void testGerritId() {
+ setText("I" + EXAMPLE_ID);
+ IHyperlink[] hyperlinks = detectHyperlinks(0,textViewer.getDocument().getLength());
+ assertNull(hyperlinks);
+ }
+
+ @Test
+ public void testGerritIdWithinText() {
+ setText("abc I" + EXAMPLE_ID);
+ IHyperlink[] hyperlinks = detectHyperlinks(5,textViewer.getDocument().getLength());
+ assertNull(hyperlinks);
+ }
+
+
private IHyperlink[] detectHyperlinks() {
return detectHyperlinks(0, textViewer.getDocument().getLength());
}

Back to the top