Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2018-06-14 21:27:37 +0000
committerAndrey Loskutov2018-06-14 21:29:44 +0000
commit6aa6b162f1a8b4cb5ec8ee23eae96112e818b9ee (patch)
tree97a7e54d5e121e09cedde86a076d69e4121ff253
parentbca7a5d8b76cb8916cc51bc1060ee4589712a03a (diff)
downloadeclipse.platform.ui-6aa6b162f1a8b4cb5ec8ee23eae96112e818b9ee.tar.gz
eclipse.platform.ui-6aa6b162f1a8b4cb5ec8ee23eae96112e818b9ee.tar.xz
eclipse.platform.ui-6aa6b162f1a8b4cb5ec8ee23eae96112e818b9ee.zip
IEditorRegistryTest.testFindExternalEditor test fails Test didn't considered the fact that there can be multiple editor descriptors with same id reported by OS, because descriptor id is nothing else as a program name, which is not unique. Change-Id: Ib5461ec23881de47db9f00ae869268bd1e0d33ff Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorRegistryTest.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorRegistryTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorRegistryTest.java
index 2960f9c2f4d..e1baca8984e 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorRegistryTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorRegistryTest.java
@@ -15,6 +15,12 @@ package org.eclipse.ui.tests.api;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertThat;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+
import org.eclipse.core.internal.content.ContentTypeManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -24,6 +30,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.program.Program;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.IFileEditorMapping;
@@ -120,13 +127,24 @@ public class IEditorRegistryTest extends TestCase {
IEditorDescriptor[] sortedEditorsFromOS = ((EditorRegistry) fReg).getSortedEditorsFromOS();
assertThat("The OS should have at least one external editor", sortedEditorsFromOS.length,
Matchers.greaterThan(1));
+
+ List<EditorDescriptor> list = Arrays.asList(sortedEditorsFromOS).stream().map(x -> (EditorDescriptor) x)
+ .collect(Collectors.toList());
+ Map<String, List<Program>> map = list.stream().collect(Collectors.groupingBy(IEditorDescriptor::getId,
+ Collectors.mapping(EditorDescriptor::getProgram, Collectors.toList())));
+
+ assertTrue(!map.isEmpty());
+
// cycle through external editors
- for (IEditorDescriptor ied : sortedEditorsFromOS) {
- EditorDescriptor ed = (EditorDescriptor) ied;
+ for (Entry<String, List<Program>> entry : map.entrySet()) {
+ String id = entry.getKey();
// find external editor from registry
- EditorDescriptor found = (EditorDescriptor) fReg.findEditor(ed.getId());
+ EditorDescriptor found = (EditorDescriptor) fReg.findEditor(id);
assertNotNull("Found editor must not be null", found);
- assertEquals("External editor should be found using find(id)", ed.getProgram(), found.getProgram());
+ List<Program> candidates = entry.getValue();
+ boolean contains = candidates.contains(found.getProgram());
+ assertTrue("No matching external editor found for id: " + id + ", list: " + candidates + ", expected: "
+ + found + " / " + found.getProgram(), contains);
}
}

Back to the top