Author: dazarov
Date: 2008-02-27 13:17:13 -0500 (Wed, 27 Feb 2008)
New Revision: 6611
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1645Test.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistTest.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1812
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1645Test.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1645Test.java 2008-02-27
17:59:03 UTC (rev 6610)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistJbide1645Test.java 2008-02-27
18:17:13 UTC (rev 6611)
@@ -1,32 +1,20 @@
package org.jboss.tools.seam.ui.test.ca;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-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;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.jboss.tools.common.test.util.TestProjectProvider;
-import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
-import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.test.TestUtil;
+import org.jboss.tools.jst.jsp.test.ca.ContentAssistantTestCase;
import org.jboss.tools.seam.ui.text.java.SeamELProposalProcessor;
import org.jboss.tools.test.util.xpl.EditorTestHelper;
-public class SeamELContentAssistJbide1645Test extends TestCase {
+public class SeamELContentAssistJbide1645Test extends ContentAssistantTestCase {
TestProjectProvider provider = null;
- IProject project = null;
boolean makeCopy = false;
private static final String PROJECT_NAME = "TestSeamELContentAssist";
private static final String PAGE_NAME = "/WebContent/home.xhtml";
@@ -59,52 +47,8 @@
}
public void testSeamELContentAssistJbide1645() {
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- }
- assertTrue("Test project \"" + PROJECT_NAME + "\" is not
loaded", (project != null));
-
- IFile jspFile = project.getFile(PAGE_NAME);
-
- assertTrue("The file \"" + PAGE_NAME + "\" is not found",
(jspFile != null));
- assertTrue("The file \"" + PAGE_NAME + "\" is not found",
(jspFile.exists()));
-
- FileEditorInput editorInput = new FileEditorInput(jspFile);
- Throwable exception = null;
- IEditorPart editorPart = null;
- try {
- editorPart =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
"org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor");
- } catch (PartInitException ex) {
- exception = ex;
- ex.printStackTrace();
- assertTrue("The JSP Visual Editor couldn't be initialized.", false);
- }
-
- JSPMultiPageEditor jspEditor = null;
+ openEditor(PAGE_NAME);
- if (editorPart instanceof JSPMultiPageEditor)
- jspEditor = (JSPMultiPageEditor)editorPart;
-
- // Delay for 3 seconds so that
- // the Favorites view can be seen.
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue("Waiting for the jobs to complete has failed.", false);
- }
- TestUtil.delay(3000);
-
- JSPTextEditor jspTextEditor = jspEditor.getJspEditor();
- StructuredTextViewer viewer = jspTextEditor.getTextViewer();
- IDocument document = viewer.getDocument();
- SourceViewerConfiguration config =
TestUtil.getSourceViewerConfiguration(jspTextEditor);
- IContentAssistant contentAssistant = (config == null ? null :
config.getContentAssistant(viewer));
-
- assertTrue("Cannot get the Content Assistant instance for the editor for page
\"" + PAGE_NAME + "\"", (contentAssistant != null));
-
// Find start of <rich:panel> tag
String documentContent = document.get();
int start = (documentContent == null ? -1 :
documentContent.indexOf(INSERT_BEFORE_STRING));
@@ -130,25 +74,12 @@
errorMessage= p.getErrorMessage();
}
-// if (errorMessage != null && errorMessage.trim().length() > 0) {
-// System.out.println("#" + offsetToTest + ": ERROR MESSAGE: " +
errorMessage);
-// }
assertTrue("Content Assistant peturned no proposals", (result != null
&& result.length > 0));
for (int i = 0; i < result.length; i++) {
// There should not be a proposal of type SeamELProposalProcessor.Proposal in the
result
assertFalse("Content Assistant peturned proposals of type (" +
result[i].getClass().getName() + ").", (result[i] instanceof
SeamELProposalProcessor.Proposal));
-// if (!(result[i] instanceof RedHatCustomCompletionProposal))
-// continue;
-// RedHatCustomCompletionProposal proposal =
(RedHatCustomCompletionProposal)result[i];
-// String proposalString = proposal.getReplacementString();
-// int proposalReplacementOffset = proposal.getReplacementOffset();
-// int proposalReplacementLength = proposal.getReplacementLength();
-// try {
-// System.out.println("Result#" + i + " ==> Offs: " +
offsetToTest + " RedHatCustomCompletionProposal[" + proposalString + "],
Offs: " + proposalReplacementOffset + ", Len: " + proposalReplacementLength
+ ", Doc: [" + document.get(proposalReplacementOffset,
proposalReplacementLength));
-// } catch (BadLocationException e) {
-// }
}
try {
@@ -158,7 +89,6 @@
assertTrue("Waiting for the jobs to complete has failed.", false);
}
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .closeEditor(editorPart, false);
+ closeEditor();
}
}
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistTest.java 2008-02-27
17:59:03 UTC (rev 6610)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/ca/SeamELContentAssistTest.java 2008-02-27
18:17:13 UTC (rev 6611)
@@ -9,7 +9,6 @@
import junit.framework.TestSuite;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.text.BadLocationException;
@@ -18,21 +17,13 @@
import org.eclipse.jface.text.ITextViewer;
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;
-import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
import org.jboss.tools.common.test.util.TestProjectProvider;
-import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
-import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.test.TestUtil;
import org.jboss.tools.jst.jsp.test.ca.ContentAssistantTestCase;
import org.jboss.tools.seam.ui.text.java.SeamELProposalProcessor;
@@ -439,52 +430,8 @@
}
public void testSeamELContentAssist() {
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- }
- assertTrue("Test project \"" + PROJECT_NAME + "\" is not
loaded", (project != null));
+ openEditor(PAGE_NAME);
- IFile jspFile = project.getFile(PAGE_NAME);
-
- assertTrue("The file \"" + PAGE_NAME + "\" is not found",
(jspFile != null));
- assertTrue("The file \"" + PAGE_NAME + "\" is not found",
(jspFile.exists()));
-
- FileEditorInput editorInput = new FileEditorInput(jspFile);
- Throwable exception = null;
- IEditorPart editorPart = null;
- try {
- editorPart =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(editorInput,
"org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor");
- } catch (PartInitException ex) {
- exception = ex;
- ex.printStackTrace();
- assertTrue("The JSP Visual Editor couldn't be initialized.", false);
- }
-
- JSPMultiPageEditor jspEditor = null;
-
- if (editorPart instanceof JSPMultiPageEditor)
- jspEditor = (JSPMultiPageEditor)editorPart;
-
- // Delay for 3 seconds so that
- // the Favorites view can be seen.
- try {
- EditorTestHelper.joinBackgroundActivities();
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue("Waiting for the jobs to complete has failed.", false);
- }
- TestUtil.delay(3000);
-
- JSPTextEditor jspTextEditor = jspEditor.getJspEditor();
- StructuredTextViewer viewer = jspTextEditor.getTextViewer();
- IDocument document = viewer.getDocument();
- SourceViewerConfiguration config =
TestUtil.getSourceViewerConfiguration(jspTextEditor);
- IContentAssistant contentAssistant = (config == null ? null :
config.getContentAssistant(viewer));
-
- assertTrue("Cannot get the Content Assistant instance for the editor for page
\"" + PAGE_NAME + "\"", (contentAssistant != null));
-
List<IRegion> regionsToTest = getELRegionsToTest(document);
if (regionsToTest != null) {
for (IRegion region : regionsToTest) {
@@ -646,8 +593,7 @@
}
}
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .closeEditor(editorPart, false);
+ closeEditor();
}
}