Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 352433 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.compare; singleton:=true
4
Bundle-SymbolicName: org.eclipse.compare; singleton:=true
5
Bundle-Version: 3.5.200.qualifier
5
Bundle-Version: 3.5.201.qualifier
6
Bundle-Activator: org.eclipse.compare.internal.CompareUIPlugin
6
Bundle-Activator: org.eclipse.compare.internal.CompareUIPlugin
7
Bundle-Vendor: %providerName
7
Bundle-Vendor: %providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
(-)compare/org/eclipse/compare/internal/CompareUIPlugin.java (-1 / +1 lines)
Lines 942-948 Link Here
942
942
943
			return (ViewerDescriptor[]) result.toArray(new ViewerDescriptor[0]);
943
			return (ViewerDescriptor[]) result.toArray(new ViewerDescriptor[0]);
944
		}
944
		}
945
		return null;
945
		return result.size() > 0 ? (ViewerDescriptor[])result.toArray(new ViewerDescriptor[0]) : null;
946
	}
946
	}
947
	
947
	
948
	/**
948
	/**
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.compare.tests;singleton:=true
4
Bundle-SymbolicName: org.eclipse.compare.tests;singleton:=true
5
Bundle-Version: 3.5.100.qualifier
5
Bundle-Version: 3.5.201.qualifier
6
Bundle-ClassPath: comparetests.jar
6
Bundle-ClassPath: comparetests.jar
7
Require-Bundle: org.junit,
7
Require-Bundle: org.junit,
8
 org.eclipse.compare,
8
 org.eclipse.compare,
(-)src/org/eclipse/compare/tests/AllTests.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 35-40 Link Here
35
		suite.addTestSuite(PatchLinesTest.class);
35
		suite.addTestSuite(PatchLinesTest.class);
36
		suite.addTestSuite(PatchUITest.class);
36
		suite.addTestSuite(PatchUITest.class);
37
		suite.addTestSuite(RangeDifferencerThreeWayDiffTest.class);
37
		suite.addTestSuite(RangeDifferencerThreeWayDiffTest.class);
38
		suite.addTestSuite(CompareUIPluginTest.class);
38
		// $JUnit-END$
39
		// $JUnit-END$
39
		return suite;
40
		return suite;
40
	}
41
	}
(-)src/org/eclipse/compare/tests/CompareUIPluginTest.java (+113 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.compare.tests;
12
13
import java.io.ByteArrayInputStream;
14
import java.io.InputStream;
15
16
import junit.framework.TestCase;
17
18
import org.eclipse.compare.CompareConfiguration;
19
import org.eclipse.compare.IStreamContentAccessor;
20
import org.eclipse.compare.ITypedElement;
21
import org.eclipse.compare.internal.CompareUIPlugin;
22
import org.eclipse.compare.internal.ViewerDescriptor;
23
import org.eclipse.compare.structuremergeviewer.DiffNode;
24
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.swt.graphics.Image;
26
27
public class CompareUIPluginTest extends TestCase {
28
29
	private static class UnknownTypedElement implements ITypedElement {
30
		public Image getImage() {
31
			return null;
32
		}
33
34
		public String getName() {
35
			return "test";
36
		}
37
38
		public String getType() {
39
			return UNKNOWN_TYPE;
40
		}
41
	}
42
43
	private static class TextTypedElement implements ITypedElement {
44
		public Image getImage() {
45
			return null;
46
		}
47
48
		public String getName() {
49
			return "test";
50
		}
51
52
		public String getType() {
53
			return TEXT_TYPE;
54
		}
55
	}
56
57
	private static class TextTypedElementStreamAccessor implements ITypedElement, IStreamContentAccessor {
58
		public Image getImage() {
59
			return null;
60
		}
61
62
		public String getName() {
63
			return "test";
64
		}
65
66
		public String getType() {
67
			return TEXT_TYPE;
68
		}
69
70
		public InputStream getContents() throws CoreException {
71
			/*
72
			 * Whatever we return has no importance as long as it is not "null", this is only to make
73
			 * CompareUIPlugin#guessType happy. However, it is only happy if what we return resembles a text.
74
			 */
75
			return new ByteArrayInputStream(new byte[] {' '});
76
		}
77
	}
78
79
	public void testFindContentViewerDescriptor_UnknownType() {
80
		CompareConfiguration cc = new CompareConfiguration();
81
		DiffNode in = new DiffNode(new UnknownTypedElement(), new UnknownTypedElement());
82
		ViewerDescriptor[] result = CompareUIPlugin.getDefault().findContentViewerDescriptor(null, in, cc);
83
84
		// API Compatibility : "no descriptor found" should return a null array instead of a 0-lengthed one.
85
		assertNull(result);
86
	}
87
88
	public void testFindContentViewerDescriptor_TextType_NotStreamAccessor() {
89
		CompareConfiguration cc = new CompareConfiguration();
90
		DiffNode in = new DiffNode(new TextTypedElement(), new TextTypedElement());
91
		ViewerDescriptor[] result = CompareUIPlugin.getDefault().findContentViewerDescriptor(null, in, cc);
92
93
		/*
94
		 * "TextTypedElement" is "text" typed : it thus has a Content Viewer attached. However, this content
95
		 * viewer is currently NOT returned because of bug 293926
96
		 */
97
		assertNotNull(result);
98
		assertEquals(1, result.length);
99
	}
100
101
	public void testFindContentViewerDescriptorForTextType_StreamAccessor() {
102
		CompareConfiguration cc = new CompareConfiguration();
103
		DiffNode in = new DiffNode(new TextTypedElementStreamAccessor(), new TextTypedElementStreamAccessor());
104
		ViewerDescriptor[] result = CompareUIPlugin.getDefault().findContentViewerDescriptor(null, in, cc);
105
106
		/*
107
		 * "TextTypedElement" is "text" typed : it thus has a Content Viewer attached. However, the content
108
		 * viewer will only be returned because we made our "ITypedElement" be an IStreamContentAccessor.
109
		 */
110
		assertNotNull(result);
111
		assertEquals(1, result.length);
112
	}
113
}

Return to bug 352433