Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2015-11-30 19:23:22 +0000
committerMarkus Keller2015-12-01 12:59:16 +0000
commit96da92a20589d62dad534245c5d9c4d45618ee95 (patch)
treedb7f27dc0839db136db463ad28a7e763a6a07a91 /org.eclipse.ui.workbench.texteditor.tests
parent0bbe21e0e553957dd09eda0b29e8c77a98f38048 (diff)
downloadeclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.gz
eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.xz
eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.zip
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor.tests')
-rw-r--r--org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/HippieCompletionTest.java52
-rw-r--r--org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/revisions/ChangeRegionTest.java26
-rw-r--r--org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/revisions/RangeUtil.java30
-rw-r--r--org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/rulers/DAGTest.java16
5 files changed, 63 insertions, 63 deletions
diff --git a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/HippieCompletionTest.java b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/HippieCompletionTest.java
index 3d3359472..56df24cb9 100644
--- a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/HippieCompletionTest.java
+++ b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/HippieCompletionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* 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
@@ -16,10 +16,6 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.runtime.AssertionFailedException;
import org.eclipse.text.tests.Accessor;
@@ -30,6 +26,10 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.internal.texteditor.HippieCompletionEngine;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
/**
* Tests for the Hippie completion action of the text editor.
@@ -139,7 +139,7 @@ public class HippieCompletionTest extends TestCase {
public void testSearchBackwards1() {
try {
- List list= fEngine.getCompletionsBackwards(documents[0],
+ List<String> list= fEngine.getCompletionsBackwards(documents[0],
"pri", documents[0].get().indexOf("println") + 10);
assertEquals(list.size(), 2);
assertEquals(list.get(0), "ntln");
@@ -168,7 +168,7 @@ public class HippieCompletionTest extends TestCase {
public void testSearchBackwards2() {
try {
- List list= fEngine.getCompletionsBackwards(documents[2],
+ List<String> list= fEngine.getCompletionsBackwards(documents[2],
"plugi", documents[2].getLength());
assertEquals(8, list.size());
list= fEngine.makeUnique(list);
@@ -186,7 +186,7 @@ public class HippieCompletionTest extends TestCase {
public void testSearchBackwards3() {
try {
- List list= fEngine.getCompletionsBackwards(documents[1],
+ List<String> list= fEngine.getCompletionsBackwards(documents[1],
"test", documents[1].getLength());
assertEquals("Number of backwards suggestions does not match", 2, list.size());
list= fEngine.getCompletionsBackwards(documents[1],
@@ -202,8 +202,8 @@ public class HippieCompletionTest extends TestCase {
}
public void testSearch() {
- ArrayList docsList= new ArrayList(Arrays.asList(this.documents));
- List result= createSuggestions("te", docsList);
+ ArrayList<IDocument> docsList= new ArrayList<>(Arrays.asList(this.documents));
+ List<String> result= createSuggestions("te", docsList);
assertEquals("Number of completions does not match", 15, result.size());
result= fEngine.makeUnique(result);
assertEquals("Number of completions does not match", 7, result.size());
@@ -228,8 +228,8 @@ public class HippieCompletionTest extends TestCase {
}
public void testSearch2() {
- ArrayList docsList= new ArrayList(Arrays.asList(this.documents));
- List result= createSuggestions("printe", docsList);
+ ArrayList<IDocument> docsList= new ArrayList<>(Arrays.asList(this.documents));
+ List<String> result= createSuggestions("printe", docsList);
assertEquals("Number of completions does not match", 0, result.size());
result= createSuggestions("s", docsList);
@@ -242,7 +242,7 @@ public class HippieCompletionTest extends TestCase {
public void testForwardSearch() {
try {
- List result= fEngine.getCompletionsForward(documents[0],
+ List<String> result= fEngine.getCompletionsForward(documents[0],
"cl", documents[0].get().indexOf("cl"), true);
assertEquals(2, result.size());
@@ -263,7 +263,7 @@ public class HippieCompletionTest extends TestCase {
}
public void testForwardSearchInternational() {
- List result;
+ List<String> result;
try {
result= fEngine.getCompletionsForward(documents[4],
"$", documents[4].get().indexOf('$'), true);
@@ -350,7 +350,7 @@ public class HippieCompletionTest extends TestCase {
public void testInternational() {
IDocument intlDoc= documents[4];
- List result= createSuggestions("\u05D4", intlDoc); // hebrew letter heh
+ List<String> result= createSuggestions("\u05D4", intlDoc); // hebrew letter heh
assertEquals("Number of completions does not match", 4, result.size());
assertEquals(result.get(0), "\u05DE\u05D7\u05DC\u05E7\u05D4");
assertEquals(result.get(1), "\u05D6\u05D5");
@@ -417,7 +417,7 @@ public class HippieCompletionTest extends TestCase {
public void testInternationalBackwards() {
IDocument intlDoc= documents[4];
try {
- List list= fEngine.getCompletionsBackwards(intlDoc,
+ List<String> list= fEngine.getCompletionsBackwards(intlDoc,
"\u043B\u0443", intlDoc.get().indexOf("129"));
assertEquals(2, list.size());
assertEquals(list.get(0), "\u0447\u0448");
@@ -443,7 +443,7 @@ public class HippieCompletionTest extends TestCase {
}
}
- private Accessor createAccessor(Iterator suggestions, int startOffset) {
+ private Accessor createAccessor(Iterator<String> suggestions, int startOffset) {
return new Accessor("org.eclipse.ui.texteditor.HippieCompleteAction$CompletionState",
getClass().getClassLoader(), new Class[] { Iterator.class, int.class }, new
Object[] { suggestions, new Integer(startOffset) });
@@ -458,7 +458,7 @@ public class HippieCompletionTest extends TestCase {
* Getting completions lazily
*/
public void testCompletionState() throws Exception {
- ArrayList list= new ArrayList();
+ ArrayList<String> list= new ArrayList<>();
Accessor state= null;
try {
@@ -527,7 +527,7 @@ public class HippieCompletionTest extends TestCase {
"bar2\n" +
"");
- Iterator suggestions= fEngine.getMultipleDocumentsIterator(openDocument, new ArrayList(), "bar", 3);
+ Iterator<String> suggestions= fEngine.getMultipleDocumentsIterator(openDocument, new ArrayList<IDocument>(), "bar", 3);
assertEquals("1", suggestions.next());
assertEquals("2", suggestions.next());
assertEquals("", suggestions.next());
@@ -535,7 +535,7 @@ public class HippieCompletionTest extends TestCase {
//Check with 2 documents
- List otherDocuments= new ArrayList();
+ List<IDocument> otherDocuments= new ArrayList<>();
otherDocuments.add(new Document("" +
"bar3\n" +
"bar4\n" +
@@ -571,7 +571,7 @@ public class HippieCompletionTest extends TestCase {
"bar0 bar1 bar" +
"");
- suggestions= fEngine.getMultipleDocumentsIterator(openDocument, new ArrayList(), "bar", openDocument.getLength());
+ suggestions= fEngine.getMultipleDocumentsIterator(openDocument, new ArrayList<IDocument>(), "bar", openDocument.getLength());
assertEquals("1", suggestions.next());
assertEquals("0", suggestions.next());
assertEquals("", suggestions.next());
@@ -583,14 +583,14 @@ public class HippieCompletionTest extends TestCase {
return new TestSuite(HippieCompletionTest.class);
}
- private List createSuggestions(String prefix, IDocument doc) {
+ private List<String> createSuggestions(String prefix, IDocument doc) {
return createSuggestions(prefix, Arrays.asList(new IDocument[]{doc}));
}
- private List createSuggestions(String prefix, List docsList) {
- ArrayList results= new ArrayList();
- for (Iterator i= docsList.iterator(); i.hasNext();) {
- IDocument doc= (IDocument) i.next();
+ private List<String> createSuggestions(String prefix, List<IDocument> docsList) {
+ ArrayList<String> results= new ArrayList<>();
+ for (Iterator<IDocument> i= docsList.iterator(); i.hasNext();) {
+ IDocument doc= i.next();
try {
results.addAll(fEngine.getCompletionsForward(doc, prefix, 0, false));
} catch (BadLocationException e) {
diff --git a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java
index b0adab96d..b46573861 100644
--- a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java
+++ b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java
@@ -96,7 +96,7 @@ public class ScreenshotTest extends TestCase {
* @param out print stream to use for diagnostics.
* @return file system path to the screenshot file
*/
- public static String takeScreenshot(Class testClass, String name, PrintStream out) {
+ public static String takeScreenshot(Class<?> testClass, String name, PrintStream out) {
File resultsHtmlDir= getJunitReportOutput(); // ends up in testresults/linux.gtk.x86_6.0/<class>.<test>.png
if (resultsHtmlDir == null) { // Fallback. Warning: uses same file location on all test platforms:
diff --git a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/revisions/ChangeRegionTest.java b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/revisions/ChangeRegionTest.java
index 1ddac364e..d67ef01f3 100644
--- a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/revisions/ChangeRegionTest.java
+++ b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/revisions/ChangeRegionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2015 IBM Corporation and others.
* 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
@@ -13,19 +13,19 @@ package org.eclipse.ui.workbench.texteditor.tests.revisions;
import java.util.Date;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.swt.graphics.RGB;
import org.eclipse.jface.internal.text.revisions.ChangeRegion;
import org.eclipse.jface.internal.text.revisions.Hunk;
+import org.eclipse.jface.internal.text.revisions.Range;
import org.eclipse.jface.text.revisions.Revision;
-import org.eclipse.jface.text.source.ILineRange;
import org.eclipse.jface.text.source.LineRange;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
/**
*
* @since 3.2
@@ -85,36 +85,36 @@ public class ChangeRegionTest extends TestCase {
ChangeRegion r= new ChangeRegion(fRevision, new LineRange(12, 3));
assertEquals(fRevision, r.getRevision());
- RangeUtil.assertEqualRange(new LineRange(12, 3), (ILineRange) r.getAdjustedRanges().get(0));
+ RangeUtil.assertEqualRange(new LineRange(12, 3), r.getAdjustedRanges().get(0));
RangeUtil.assertEqualRange(new LineRange(12, 3), r.getAdjustedCoverage());
}
public void testHunkAfter() throws Exception {
ChangeRegion r= new ChangeRegion(fRevision, new LineRange(12, 3));
- List before= RangeUtil.deepClone(r.getAdjustedRanges());
+ List<Range> before= RangeUtil.deepClone(r.getAdjustedRanges());
r.adjustTo(new Hunk(16, 3, 2));
RangeUtil.assertEqualRanges(before, r.getAdjustedRanges());
- RangeUtil.assertEqualRange((ILineRange) before.get(0), r.getAdjustedCoverage());
+ RangeUtil.assertEqualRange(before.get(0), r.getAdjustedCoverage());
r= new ChangeRegion(fRevision, new LineRange(12, 3));
before= RangeUtil.deepClone(r.getAdjustedRanges());
r.adjustTo(new Hunk(16, -33, 2));
RangeUtil.assertEqualRanges(before, r.getAdjustedRanges());
- RangeUtil.assertEqualRange((ILineRange) before.get(0), r.getAdjustedCoverage());
+ RangeUtil.assertEqualRange(before.get(0), r.getAdjustedCoverage());
}
public void testHunkRightAfter() throws Exception {
ChangeRegion r= new ChangeRegion(fRevision, new LineRange(12, 3));
- List before= RangeUtil.deepClone(r.getAdjustedRanges());
+ List<Range> before= RangeUtil.deepClone(r.getAdjustedRanges());
r.adjustTo(new Hunk(15, 3, 2));
RangeUtil.assertEqualRanges(before, r.getAdjustedRanges());
- RangeUtil.assertEqualRange((ILineRange) before.get(0), r.getAdjustedCoverage());
+ RangeUtil.assertEqualRange(before.get(0), r.getAdjustedCoverage());
r= new ChangeRegion(fRevision, new LineRange(12, 3));
before= RangeUtil.deepClone(r.getAdjustedRanges());
r.adjustTo(new Hunk(15, -3, 2));
RangeUtil.assertEqualRanges(before, r.getAdjustedRanges());
- RangeUtil.assertEqualRange((ILineRange) before.get(0), r.getAdjustedCoverage());
+ RangeUtil.assertEqualRange(before.get(0), r.getAdjustedCoverage());
}
public void testHunkBefore() throws Exception {
diff --git a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/revisions/RangeUtil.java b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/revisions/RangeUtil.java
index ecd458e22..995325dca 100644
--- a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/revisions/RangeUtil.java
+++ b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/revisions/RangeUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2013 IBM Corporation and others.
+ * Copyright (c) 2005, 2015 IBM Corporation and others.
* 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
@@ -29,33 +29,33 @@ class RangeUtil extends Assert {
assertEquals(expected.getNumberOfLines(), actual.getNumberOfLines());
}
- static List deepClone(List ranges) {
- List list= new ArrayList(ranges.size());
- for (Iterator it= ranges.iterator(); it.hasNext();) {
- ILineRange range= (ILineRange) it.next();
+ static List<Range> deepClone(List<Range> ranges) {
+ List<Range> list= new ArrayList<>(ranges.size());
+ for (Iterator<Range> it= ranges.iterator(); it.hasNext();) {
+ ILineRange range= it.next();
list.add(Range.copy(range));
}
return list;
}
- static void assertEqualRanges(ILineRange expected1, ILineRange expected2, List actual) {
+ static void assertEqualRanges(ILineRange expected1, ILineRange expected2, List<Range> actual) {
assertEquals(2, actual.size());
- RangeUtil.assertEqualRange(expected1, (ILineRange) actual.get(0));
- RangeUtil.assertEqualRange(expected2, (ILineRange) actual.get(1));
+ RangeUtil.assertEqualRange(expected1, actual.get(0));
+ RangeUtil.assertEqualRange(expected2, actual.get(1));
}
- static void assertEqualSingleRange(ILineRange expected, List actual) {
+ static void assertEqualSingleRange(ILineRange expected, List<Range> actual) {
assertEquals(1, actual.size());
- RangeUtil.assertEqualRange(expected, (ILineRange) actual.get(0));
+ RangeUtil.assertEqualRange(expected, actual.get(0));
}
- static void assertEqualRanges(List expected, List actual) {
+ static void assertEqualRanges(List<Range> expected, List<Range> actual) {
assertEquals(expected.size(), actual.size());
- Iterator it1= expected.iterator();
- Iterator it2= actual.iterator();
+ Iterator<Range> it1= expected.iterator();
+ Iterator<Range> it2= actual.iterator();
while (it1.hasNext()) {
- ILineRange r1= (ILineRange) it1.next();
- ILineRange r2= (ILineRange) it2.next();
+ ILineRange r1= it1.next();
+ ILineRange r2= it2.next();
assertEqualRange(r1, r2);
}
}
diff --git a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/rulers/DAGTest.java b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/rulers/DAGTest.java
index ebb99a4c5..cb726bb02 100644
--- a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/rulers/DAGTest.java
+++ b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/rulers/DAGTest.java
@@ -27,15 +27,15 @@ public class DAGTest extends TestCase {
private static final Object B= "B";
private static final Object C= "C";
private static final Object D= "D";
- private static final Set AS= Collections.singleton(A);
- private static final Set BS= Collections.singleton(B);
- private static final Set CS= Collections.singleton(C);
- private static final Set AD= new LinkedHashSet(Arrays.asList(new Object[] { A, D }));
- private static final Set CD= new LinkedHashSet(Arrays.asList(new Object[] { C, D }));
- private static final Set ACD= new LinkedHashSet(Arrays.asList(new Object[] { A, C, D }));
- private static final Set BD= new LinkedHashSet(Arrays.asList(new Object[] { B, D }));
+ private static final Set<Object> AS= Collections.singleton(A);
+ private static final Set<Object> BS= Collections.singleton(B);
+ private static final Set<Object> CS= Collections.singleton(C);
+ private static final Set<Object> AD= new LinkedHashSet<>(Arrays.asList(new Object[] { A, D }));
+ private static final Set<Object> CD= new LinkedHashSet<>(Arrays.asList(new Object[] { C, D }));
+ private static final Set<Object> ACD= new LinkedHashSet<>(Arrays.asList(new Object[] { A, C, D }));
+ private static final Set<Object> BD= new LinkedHashSet<>(Arrays.asList(new Object[] { B, D }));
- private DAG fDag= new DAG();
+ private DAG<Object> fDag= new DAG<>();
public void testEmpty() throws Exception {
assertTrue(fDag.getChildren(new Object()).isEmpty());

Back to the top