[jbosstools-commits] JBoss Tools SVN: r35674 - in trunk: common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Fri Oct 14 14:39:47 EDT 2011
Author: dazarov
Date: 2011-10-14 14:39:46 -0400 (Fri, 14 Oct 2011)
New Revision: 35674
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CATest.java
trunk/common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist/AbstractContentAssistantTestCase.java
Log:
Updated test in order to check images in Content Assistant https://issues.jboss.org/browse/JBIDE-9897
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CATest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CATest.java 2011-10-14 18:15:12 UTC (rev 35673)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CATest.java 2011-10-14 18:39:46 UTC (rev 35674)
@@ -14,6 +14,8 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.cdi.core.CDIImages;
import org.jboss.tools.cdi.core.test.tck.TCKTest;
import org.jboss.tools.jst.jsp.test.ca.ContentAssistantTestCase;
@@ -26,7 +28,9 @@
private ContentAssistantTestCase caTest = new ContentAssistantTestCase();
private static final String PAGE_NAME = "WebContent/test.jsp";
private String[] beanProposals = new String[] {"example", "example.com", "fishJBT", "game", "haddock", "salmon", "sheep", "tunaFarm", "whitefishJBT", "wolf"};
+ private Image[] beanImages = new Image[] {CDIImages.BEAN_CLASS_IMAGE, CDIImages.BEAN_CLASS_IMAGE, CDIImages.BEAN_CLASS_IMAGE, CDIImages.BEAN_CLASS_IMAGE, CDIImages.BEAN_CLASS_IMAGE, CDIImages.BEAN_CLASS_IMAGE, CDIImages.BEAN_CLASS_IMAGE, CDIImages.BEAN_CLASS_IMAGE, CDIImages.BEAN_CLASS_IMAGE, CDIImages.BEAN_CLASS_IMAGE};
private String[] propertyProposals = new String[] {"game.value", "game.initialize()"};
+ private Image[] propertyImages = new Image[] {CDIImages.BEAN_FIELD_IMAGE, CDIImages.BEAN_METHOD_IMAGE};
public void setUp() {
project = ResourcesPlugin.getWorkspace().getRoot().getProject(TCKTest.PROJECT_NAME);
@@ -34,7 +38,16 @@
}
public void testEL() {
- caTest.checkProposals(PAGE_NAME, "value=\"#{", 9, beanProposals, false);
- caTest.checkProposals(PAGE_NAME, "rendered=\"#{(game.", 18, propertyProposals, false);
+// System.out.println("BEAN_CLASS_IMAGE - "+CDIImages.BEAN_CLASS_IMAGE);
+// System.out.println("BEAN_METHOD_IMAGE - "+CDIImages.BEAN_METHOD_IMAGE);
+// System.out.println("BEAN_FIELD_IMAGE - "+CDIImages.BEAN_FIELD_IMAGE);
+//
+// System.out.println("INJECTION_POINT_IMAGE - "+CDIImages.INJECTION_POINT_IMAGE);
+// System.out.println("ANNOTATION_IMAGE - "+CDIImages.ANNOTATION_IMAGE);
+// System.out.println("CDI_EVENT_IMAGE - "+CDIImages.CDI_EVENT_IMAGE);
+// System.out.println("MESSAGE_BUNDLE_IMAGE - "+CDIImages.MESSAGE_BUNDLE_IMAGE);
+
+ caTest.checkProposals(PAGE_NAME, "value=\"#{", 9, beanProposals, beanImages, false);
+ caTest.checkProposals(PAGE_NAME, "rendered=\"#{(game.", 18, propertyProposals, propertyImages, false);
}
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist/AbstractContentAssistantTestCase.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist/AbstractContentAssistantTestCase.java 2011-10-14 18:15:12 UTC (rev 35673)
+++ trunk/common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist/AbstractContentAssistantTestCase.java 2011-10-14 18:39:46 UTC (rev 35674)
@@ -23,6 +23,7 @@
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.ITextEditor;
@@ -80,13 +81,22 @@
}
public ICompletionProposal[] checkProposals(String fileName, int offset, String[] proposals, boolean exactly) {
- return checkProposals(fileName, null, offset, proposals, exactly, true);
+ return checkProposals(fileName, null, offset, proposals, null, exactly, true);
}
public ICompletionProposal[] checkProposals(String fileName, String substring, int offset, String[] proposals, boolean exactly) {
- return checkProposals(fileName, substring, offset, proposals, exactly, false);
+ return checkProposals(fileName, substring, offset, proposals, null, exactly, false);
}
- public ICompletionProposal[] checkProposals(String fileName, String substring, int offset, String[] proposals, boolean exactly, boolean excludeELProposalsFromExactTest){
+
+ public ICompletionProposal[] checkProposals(String fileName, String substring, int offset, String[] proposals, Image[] images, boolean exactly) {
+ return checkProposals(fileName, substring, offset, proposals, images, exactly, false);
+ }
+
+ public ICompletionProposal[] checkProposals(String fileName, String substring, int offset, String[] proposals, Image[] images, boolean exactly, boolean excludeELProposalsFromExactTest){
+ if(images != null){
+ assertEquals("number of images and number of proposals must be the same or images must be null", proposals.length, images.length);
+ }
+
openEditor(fileName);
int position = 0;
@@ -111,7 +121,12 @@
sb.append("]");
int foundCounter = 0;
for (int i = 0; i < proposals.length; i++) {
- boolean found = compareProposal(proposals[i], result);
+ Image image = null;
+ if(images != null){
+ image = images[i];
+ }
+ boolean found = compareProposal(proposals[i], image, result);
+
if (found)
foundCounter++;
assertTrue("Proposal " + proposals[i] + " not found! Found proposals: " + sb.toString(), found ); //$NON-NLS-1$ //$NON-NLS-2$
@@ -139,12 +154,12 @@
return false;
}
- public boolean compareProposal(String proposalName, ICompletionProposal[] proposals){
+ public boolean compareProposal(String proposalName, Image image, ICompletionProposal[] proposals){
for (int i = 0; i < proposals.length; i++) {
if (isRelevantProposal(proposals[i])) {
CustomCompletionProposal ap = (CustomCompletionProposal)proposals[i];
String replacementString = ap.getReplacementString().toLowerCase();
- if (replacementString.equalsIgnoreCase(proposalName)) return true;
+ if (replacementString.equalsIgnoreCase(proposalName)) return compareImages(image, proposals[i]);
// For a tag proposal there will be not only the the tag name but all others characters like default attributes, tag ending characters and so on
if (replacementString.indexOf("/>") != -1) {
@@ -153,36 +168,44 @@
if (replacementString.indexOf('>') != -1) {
replacementString = replacementString.substring(0, replacementString.indexOf('>'));
}
- if (replacementString.equalsIgnoreCase(proposalName)) return true;
+ if (replacementString.equalsIgnoreCase(proposalName)) return compareImages(image, proposals[i]);
String[] replacementStringParts = replacementString.split(" "); //$NON-NLS-1$
if (replacementStringParts != null && replacementStringParts.length > 0) {
- if (replacementStringParts[0].equalsIgnoreCase(proposalName)) return true;
+ if (replacementStringParts[0].equalsIgnoreCase(proposalName)) return compareImages(image, proposals[i]);
}
// for an attribute proposal there will be a pare of attribute-value (i.e. attrName="attrValue")
replacementStringParts = replacementString.split("="); //$NON-NLS-1$
if (replacementStringParts != null && replacementStringParts.length > 0) {
- if (replacementStringParts[0].equalsIgnoreCase(proposalName)) return true;
+ if (replacementStringParts[0].equalsIgnoreCase(proposalName)) return compareImages(image, proposals[i]);
}
// for an Unclosed EL the closing character is appended to the proposal string (i.e. person} )
// perform case insensitive compare operation
replacementStringParts = replacementString.split("}"); //$NON-NLS-1$
if (replacementStringParts != null && replacementStringParts.length > 0) {
- if (replacementStringParts[0].equalsIgnoreCase(proposalName)) return true;
+ if (replacementStringParts[0].equalsIgnoreCase(proposalName)) return compareImages(image, proposals[i]);
}
// For an attribute value proposal there will be the quote characters
replacementString = Utils.trimQuotes(replacementString);
- if (replacementString.equalsIgnoreCase(proposalName)) return true;
+ if (replacementString.equalsIgnoreCase(proposalName)) return compareImages(image, proposals[i]);
} else {
- if(proposals[i].getDisplayString().toLowerCase().equals(proposalName.toLowerCase())) return true;
+ if(proposals[i].getDisplayString().toLowerCase().equals(proposalName.toLowerCase())) return compareImages(image, proposals[i]);
}
}
return false;
}
+
+ private boolean compareImages(Image expected, ICompletionProposal proposal){
+ if(expected != null){
+ //System.out.println("<"+proposal.getDisplayString()+"> completion proposal image - "+proposal.getImage());
+ assertEquals("<"+proposal.getDisplayString()+"> completion proposal returns wrong image", expected, proposal.getImage());
+ }
+ return true;
+ }
public void closeEditor() {
if (editorPart != null) {
More information about the jbosstools-commits
mailing list