Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2011-07-14 13:35:42 +0000
committerTomasz Zarna2011-07-14 13:35:42 +0000
commitdd38224d400ed09c933187ff5a3e1735d02b7b22 (patch)
treec745adbc8c1f6e65a3c193b5cd7792d6037b27dd /tests/org.eclipse.compare.tests/src/org/eclipse
parentd155b2c7fa7a8546a8a5802f5d3c9b2f90052d8d (diff)
downloadeclipse.platform.team-dd38224d400ed09c933187ff5a3e1735d02b7b22.tar.gz
eclipse.platform.team-dd38224d400ed09c933187ff5a3e1735d02b7b22.tar.xz
eclipse.platform.team-dd38224d400ed09c933187ff5a3e1735d02b7b22.zip
bug 293926: CompareUIPlugin.findContentViewerDescriptor returns null even if a viewer is registered via extension point="org.eclipse.compare.contentMergeViewers"
Diffstat (limited to 'tests/org.eclipse.compare.tests/src/org/eclipse')
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AllTests.java3
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareUIPluginTest.java113
2 files changed, 115 insertions, 1 deletions
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AllTests.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AllTests.java
index 27de4c9a8..a47c61fc2 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AllTests.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -35,6 +35,7 @@ public class AllTests {
suite.addTestSuite(PatchLinesTest.class);
suite.addTestSuite(PatchUITest.class);
suite.addTestSuite(RangeDifferencerThreeWayDiffTest.class);
+ suite.addTestSuite(CompareUIPluginTest.class);
// $JUnit-END$
return suite;
}
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareUIPluginTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareUIPluginTest.java
new file mode 100644
index 000000000..3107b5f74
--- /dev/null
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareUIPluginTest.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.IStreamContentAccessor;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.internal.CompareUIPlugin;
+import org.eclipse.compare.internal.ViewerDescriptor;
+import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.graphics.Image;
+
+public class CompareUIPluginTest extends TestCase {
+
+ private static class UnknownTypedElement implements ITypedElement {
+ public Image getImage() {
+ return null;
+ }
+
+ public String getName() {
+ return "test";
+ }
+
+ public String getType() {
+ return UNKNOWN_TYPE;
+ }
+ }
+
+ private static class TextTypedElement implements ITypedElement {
+ public Image getImage() {
+ return null;
+ }
+
+ public String getName() {
+ return "test";
+ }
+
+ public String getType() {
+ return TEXT_TYPE;
+ }
+ }
+
+ private static class TextTypedElementStreamAccessor implements ITypedElement, IStreamContentAccessor {
+ public Image getImage() {
+ return null;
+ }
+
+ public String getName() {
+ return "test";
+ }
+
+ public String getType() {
+ return TEXT_TYPE;
+ }
+
+ public InputStream getContents() throws CoreException {
+ /*
+ * Whatever we return has no importance as long as it is not "null", this is only to make
+ * CompareUIPlugin#guessType happy. However, it is only happy if what we return resembles a text.
+ */
+ return new ByteArrayInputStream(new byte[] {' '});
+ }
+ }
+
+ public void testFindContentViewerDescriptor_UnknownType() {
+ CompareConfiguration cc = new CompareConfiguration();
+ DiffNode in = new DiffNode(new UnknownTypedElement(), new UnknownTypedElement());
+ ViewerDescriptor[] result = CompareUIPlugin.getDefault().findContentViewerDescriptor(null, in, cc);
+
+ // API Compatibility : "no descriptor found" should return a null array instead of a 0-lengthed one.
+ assertNull(result);
+ }
+
+ public void testFindContentViewerDescriptor_TextType_NotStreamAccessor() {
+ CompareConfiguration cc = new CompareConfiguration();
+ DiffNode in = new DiffNode(new TextTypedElement(), new TextTypedElement());
+ ViewerDescriptor[] result = CompareUIPlugin.getDefault().findContentViewerDescriptor(null, in, cc);
+
+ /*
+ * "TextTypedElement" is "text" typed : it thus has a Content Viewer attached. However, this content
+ * viewer is currently NOT returned because of bug 293926
+ */
+ assertNotNull(result);
+ assertEquals(1, result.length);
+ }
+
+ public void testFindContentViewerDescriptorForTextType_StreamAccessor() {
+ CompareConfiguration cc = new CompareConfiguration();
+ DiffNode in = new DiffNode(new TextTypedElementStreamAccessor(), new TextTypedElementStreamAccessor());
+ ViewerDescriptor[] result = CompareUIPlugin.getDefault().findContentViewerDescriptor(null, in, cc);
+
+ /*
+ * "TextTypedElement" is "text" typed : it thus has a Content Viewer attached. However, the content
+ * viewer will only be returned because we made our "ITypedElement" be an IStreamContentAccessor.
+ */
+ assertNotNull(result);
+ assertEquals(1, result.length);
+ }
+} \ No newline at end of file

Back to the top