Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2016-02-15 22:23:55 +0000
committerMatthias Sohn2016-02-17 22:18:16 +0000
commitf00fdab6734878a1891158a6205cc87dfe9e3002 (patch)
treeb0fc1b14c1b69fb11a33e719d399f540f26af6c4 /org.eclipse.egit.ui.test
parentb0e69095518fcc419891ca4235fdf9a350e38736 (diff)
downloadegit-f00fdab6734878a1891158a6205cc87dfe9e3002.tar.gz
egit-f00fdab6734878a1891158a6205cc87dfe9e3002.tar.xz
egit-f00fdab6734878a1891158a6205cc87dfe9e3002.zip
Fill FetchFromGerrit wizard for more clipboard contents
Try to extract a change number from more kinds of clipboard text: URLs, if they look like a Gerrit URL, as well as * simple integers, possibly surrounded by slashes * up to three integers separated by slashes * any of the above followed by /something,like for instance a Gerrit diff screen URL Should handle full and partial Gerrit URL selections, as well as "naked" change numbers. If a change number is detected, content assist is triggered automatically. New tests for change number detection are included. Bug: 486253 Change-Id: I35ea30947343ccaf09b2a6cf4104ad5f35cdda4b Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui.test')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangeTest.java140
1 files changed, 140 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangeTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangeTest.java
new file mode 100644
index 0000000000..79bfde72e4
--- /dev/null
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangeTest.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Thomas Wolf <thomas.wolf@paranor.ch>
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.fetch;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+
+/**
+ * Tests for determining a Gerrit change number from a string.
+ */
+public class FetchGerritChangeTest {
+
+ @Test
+ public void testChangeStringNull() {
+ assertNull(FetchGerritChangePage.determineChangeFromString(null));
+ }
+
+ @Test
+ public void testChangeStringEmpty() {
+ assertNull(FetchGerritChangePage.determineChangeFromString(""));
+ }
+
+ @Test
+ public void testChangeStringNoDigits() {
+ assertNull(FetchGerritChangePage
+ .determineChangeFromString("Just some string"));
+ }
+
+ @Test
+ public void testChangeStringZero() {
+ assertNull(FetchGerritChangePage.determineChangeFromString("0"));
+ }
+
+ @Test
+ public void testChangeStringNegative() {
+ assertNull(FetchGerritChangePage.determineChangeFromString("-17"));
+ }
+
+ @Test
+ public void testChangeStringOverflow() {
+ assertNull(FetchGerritChangePage
+ .determineChangeFromString("4444444444444444/4"));
+ assertNull(FetchGerritChangePage
+ .determineChangeFromString("4/4444444444444444/"));
+ }
+
+ @Test
+ public void testChangeStringUriNonsense() {
+ assertNull(FetchGerritChangePage
+ .determineChangeFromString("http://www.example.org/foo/bar"));
+ assertNull(FetchGerritChangePage.determineChangeFromString(
+ "https://git example.org/r/#/c/65510/"));
+ }
+
+ @Test
+ public void testChangeStringMultiline() {
+ assertNull(FetchGerritChangePage
+ .determineChangeFromString("/10/\n65510/6"));
+ }
+
+ @Test
+ public void testChangeStringUri() {
+ assertEquals("65510", FetchGerritChangePage.determineChangeFromString(
+ "https://git.example.org/r/#/c/65510"));
+ assertEquals("65510", FetchGerritChangePage.determineChangeFromString(
+ "https://git.example.org/r/#/c/65510/"));
+ assertEquals("65510", FetchGerritChangePage.determineChangeFromString(
+ "https://git.example.org/r/#/c/65510/6"));
+ assertEquals("65510", FetchGerritChangePage.determineChangeFromString(
+ "https://git.example.org/r/#/c/65510/6/"));
+ assertEquals("65510", FetchGerritChangePage.determineChangeFromString(
+ "https://git.example.org/r/#/c/65510/6/some.path/some/File.txt"));
+ assertEquals("65510", FetchGerritChangePage.determineChangeFromString(
+ "https://git.example.org/r/#/c/65510/4..5"));
+ assertEquals("65510", FetchGerritChangePage.determineChangeFromString(
+ "https://git.example.org/r/#/c/65510/4..5/"));
+ assertEquals("65510", FetchGerritChangePage.determineChangeFromString(
+ "https://git.example.org/r/#/c/65510/4..5/some.path/some/File.txt"));
+ assertEquals("65510", FetchGerritChangePage.determineChangeFromString(
+ "https://git.example.org:8080/r/#/c/65510"));
+ }
+
+ @Test
+ public void testChangeStringSingleNumber() {
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("65510"));
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("/65510"));
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("65510/"));
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("/65510/"));
+ }
+
+ @Test
+ public void testChangeStringTwoNumbers() {
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("65510/6"));
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("/65510/6"));
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("65510/6/"));
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("/65510/6/"));
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("10/65510"));
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("10/65510/"));
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("/10/65510"));
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("/10/65510/"));
+ assertEquals("10",
+ FetchGerritChangePage.determineChangeFromString("/10/10"));
+ }
+
+ @Test
+ public void testChangeStringThreeNumbers() {
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("10/65510/6"));
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("/10/65510/6"));
+ assertEquals("65510",
+ FetchGerritChangePage.determineChangeFromString("10/65510/6/"));
+ assertEquals("65510", FetchGerritChangePage
+ .determineChangeFromString("/10/65510/6/"));
+ assertEquals("10",
+ FetchGerritChangePage.determineChangeFromString("/10/10/6"));
+ assertEquals("10",
+ FetchGerritChangePage.determineChangeFromString("/65510/10/6"));
+ }
+
+}

Back to the top