Author: dazarov
Date: 2008-02-26 13:03:41 -0500 (Tue, 26 Feb 2008)
New Revision: 6583
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1812
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2008-02-26
18:03:18 UTC (rev 6582)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2008-02-26
18:03:41 UTC (rev 6583)
@@ -5,6 +5,8 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.ui.IEditorPart;
@@ -83,7 +85,38 @@
(document instanceof IStructuredDocument));
}
+
+ protected void contentAssistantCommonTest(String fileName, int offset, String[]
proposals, boolean exactly){
+ openEditor(fileName);
+
+ ICompletionProposal[] result= null;
+ IContentAssistProcessor p= TestUtil.getProcessor(viewer, offset, contentAssistant);
+ if (p != null) {
+ try {
+ result= p.computeCompletionProposals(viewer, offset);
+ } catch (Throwable x) {
+ x.printStackTrace();
+ }
+ }
+
+ assertTrue("Content Assistant peturned no proposals", (result != null
&& result.length > 0));
+
+ for (int i = 0; i < proposals.length; i++) {
+ assertTrue("Proposal "+proposals[i]+" not found!",
compareProposal(proposals[i], result));
+ }
+
+ if(exactly)
+ assertTrue("Some other proposals was found!", result.length ==
proposals.length);
+ }
+
+ protected boolean compareProposal(String proposalName, ICompletionProposal[]
proposals){
+ for (int i = 0; i < proposals.length; i++) {
+ if(proposals[i].getDisplayString().equals(proposalName)) return true;
+ }
+ return false;
+ }
+
protected void closeEditor() {
if (jspEditor != null) {
PlatformUI.getWorkbench().getActiveWorkbenchWindow()