Author: sdzmitrovich
Date: 2008-04-04 10:39:38 -0400 (Fri, 04 Apr 2008)
New Revision: 7335
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE788Test.java
Log:
corrected tests
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE788Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE788Test.java 2008-04-04
14:31:21 UTC (rev 7334)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE788Test.java 2008-04-04
14:39:38 UTC (rev 7335)
@@ -1,13 +1,13 @@
/*******************************************************************************
-* Copyright (c) 2007 Red Hat, Inc.
-* Distributed under license by Red Hat, Inc. All rights reserved.
-* This program is 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:
-* Red Hat, Inc. - initial API and implementation
-******************************************************************************/
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.jsf.vpe.jsf.test.jbide;
import org.eclipse.core.resources.IFile;
@@ -20,6 +20,7 @@
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
+import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.vpe.ui.test.TestUtil;
@@ -27,20 +28,22 @@
/**
* @author Max Areshkau
- *
- * JUnit test for
http://jira.jboss.com/jira/browse/JBIDE-788
+ *
+ * JUnit test for
http://jira.jboss.com/jira/browse/JBIDE-788
*/
-public class JBIDE788Test extends VpeTest{
-
+public class JBIDE788Test extends VpeTest {
+
private static final String IMPORT_PROJECT_NAME = "jsfTest";
-
+
private static final String CA_NAME = "org.eclipse.wst.html.HTML_DEFAULT";
-
+
public JBIDE788Test(String name) {
super(name);
}
+
/**
* Tests inner nodes include URI
+ *
* @throws Throwable
*/
public void testCAforIncludeTaglibInInenerNodes() throws Throwable {
@@ -48,18 +51,22 @@
TestUtil.waitForJobs();
// set exception
setException(null);
- //Tests CA
+ // Tests CA
- baseCheckofCA(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xhtml", 395,
185);
- baseCheckofCA(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xhtml", 503,
125);
- baseCheckofCA(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xhtml", 567,
199);
+ baseCheckofCA(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xhtml",
+ 395, 185);
+ baseCheckofCA(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xhtml",
+ 503, 125);
+ baseCheckofCA(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xhtml",
+ 567, 199);
+
// check exception
if (getException() != null) {
-
+
throw getException();
- }
+ }
}
-
+
/**
* Tests Path proposals of CA
*/
@@ -68,7 +75,7 @@
TestUtil.waitForJobs();
// set exception
setException(null);
- //Tests CA
+ // Tests CA
baseCheckofCA(CA_NAME, "JBIDE/788/testCAPathProposals.xhtml", 514, 3);
baseCheckofCA(CA_NAME, "JBIDE/788/testCAPathProposals.xhtml", 586, 5);
@@ -76,12 +83,14 @@
baseCheckofCA(CA_NAME, "JBIDE/788/testCAPathProposals.xhtml", 719, 46);
// check exception
if (getException() != null) {
-
+
throw getException();
- }
- }
+ }
+ }
+
/**
* Tests CA for Messages Bundles and EL Values
+ *
* @throws Throwable
*/
public void testCAforMessageBundlesAndELExpressions() throws Throwable {
@@ -89,19 +98,21 @@
TestUtil.waitForJobs();
// set exception
setException(null);
- //Tests CA
+ // Tests CA
- baseCheckofCA(CA_NAME, "JBIDE/788/testCAMessageBundlesAndEL.xhtml", 1245,
13);
-
+ baseCheckofCA(CA_NAME, "JBIDE/788/testCAMessageBundlesAndEL.xhtml",
+ 1245, 13);
+
// check exception
if (getException() != null) {
-
+
throw getException();
}
}
-
+
/**
* Tests CA for proposals for JSFC
+ *
* @throws Throwable
*/
public void testCAforForJSFCProposals() throws Throwable {
@@ -109,18 +120,21 @@
TestUtil.waitForJobs();
// set exception
setException(null);
- //Tests CA
- baseCheckofCA(CA_NAME, "JBIDE/788/testCAMessageBundlesAndEL.xhtml", 1200,
112);
-
+ // Tests CA
+ baseCheckofCA(CA_NAME, "JBIDE/788/testCAMessageBundlesAndEL.xhtml",
+ 1200, 112);
+
// check exception
if (getException() != null) {
-
+
throw getException();
}
-
+
}
+
/**
* Tests CA on html files
+ *
* @throws Throwable
*/
public void testCAforHtmlFiles() throws Throwable {
@@ -128,17 +142,22 @@
TestUtil.waitForJobs();
// set exception
setException(null);
- //Tests CA
+ // Tests CA
baseCheckofCA(CA_NAME, "JBIDE/788/testCAforHtml.html", 39, 79);
+ // cursor will set after "<" simbol
+ checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforHtml.html",
"a", 26);
+
// check exception
if (getException() != null) {
-
+
throw getException();
}
}
+
/**
* Tests CA on jsp files
+ *
* @throws Throwable
*/
public void testCAforJSPFiles() throws Throwable {
@@ -146,16 +165,23 @@
TestUtil.waitForJobs();
// set exception
setException(null);
- //Tests CA
+ // Tests CA
baseCheckofCA(CA_NAME, "JBIDE/788/testCAforJSP.jsp", 1000, 110);
+
+ // cursor will set after "outputText" tag
+ // checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforJSP.jsp",
"s",
+ // 1032);
+
// check exception
if (getException() != null) {
-
+
throw getException();
}
}
+
/**
* Tests CA on jsp files
+ *
* @throws Throwable
*/
public void testCAforXHTMLFiles() throws Throwable {
@@ -163,24 +189,40 @@
TestUtil.waitForJobs();
// set exception
setException(null);
- //Tests CA
+ // Tests CA
baseCheckofCA(CA_NAME, "JBIDE/788/testCAforXHTML.xhtml", 745, 96);
+
+ // cursor will set after "<" simbol
+ checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforXHTML.xhtml",
"c",
+ 687);
+
+ // cursor will set after "outputText" tag
+ checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforXHTML.xhtml",
"s",
+ 778);
+
// check exception
if (getException() != null) {
-
+
throw getException();
}
}
+
/**
- * Perfoms base test of ca, compare number of proposals which what returned by ca
- * with etalon
- * @param caName - content assistent name
- * @param testPagePath - test page
- * @param position - position on test page
- * @param numberOfProposals - standard number of proposals
- * @throws CoreException
+ * Perfoms base test of ca, compare number of proposals which what returned
+ * by ca with etalon
+ *
+ * @param caName -
+ * content assistent name
+ * @param testPagePath -
+ * test page
+ * @param position -
+ * position on test page
+ * @param numberOfProposals -
+ * standard number of proposals
+ * @throws CoreException
*/
- private void baseCheckofCA(String caName,String testPagePath, int position, int
numberOfProposals) throws CoreException {
+ private void baseCheckofCA(String caName, String testPagePath,
+ int position, int numberOfProposals) throws CoreException {
// get test page path
IFile file = (IFile) TestUtil.getComponentPath(testPagePath,
IMPORT_PROJECT_NAME);
@@ -190,24 +232,103 @@
IEditorInput input = new FileEditorInput(file);
assertNotNull("Editor input is null", input);
-
+
// open and get editor
JSPMultiPageEditor part = openEditor(input);
-
- //sets cursor position
- part.getSourceEditor().getTextViewer().getTextWidget().setCaretOffset(position);
+
+ // sets cursor position
+ part.getSourceEditor().getTextViewer().getTextWidget().setCaretOffset(
+ position);
TestUtil.waitForJobs();
TestUtil.delay(2000);
- SourceViewerConfiguration sourceViewerConfiguration =
((JSPTextEditor)part.getSourceEditor()).getSourceViewerConfigurationForTest();
- //errase errors which can be on start of editor(for example xuklunner not found)
+ SourceViewerConfiguration sourceViewerConfiguration = ((JSPTextEditor) part
+ .getSourceEditor()).getSourceViewerConfigurationForTest();
+ // errase errors which can be on start of editor(for example xuklunner
+ // not found)
setException(null);
- StructuredTextViewerConfiguration stvc = (StructuredTextViewerConfiguration)
sourceViewerConfiguration;
- IContentAssistant iContentAssistant = stvc.getContentAssistant((ISourceViewer)
part.getSourceEditor().getAdapter(ISourceViewer.class));
+ StructuredTextViewerConfiguration stvc = (StructuredTextViewerConfiguration)
sourceViewerConfiguration;
+ IContentAssistant iContentAssistant = stvc
+ .getContentAssistant((ISourceViewer) part.getSourceEditor()
+ .getAdapter(ISourceViewer.class));
assertNotNull(iContentAssistant);
- IContentAssistProcessor iContentAssistProcessor=
iContentAssistant.getContentAssistProcessor(caName);
+ IContentAssistProcessor iContentAssistProcessor = iContentAssistant
+ .getContentAssistProcessor(caName);
assertNotNull(iContentAssistProcessor);
- ICompletionProposal[] results =
iContentAssistProcessor.computeCompletionProposals(part.getSourceEditor().getTextViewer(),
position);
+ ICompletionProposal[] results = iContentAssistProcessor
+ .computeCompletionProposals(part.getSourceEditor()
+ .getTextViewer(), position);
assertNotNull(results);
- assertEquals(numberOfProposals,results.length);
+ assertEquals(numberOfProposals, results.length);
}
+
+ /**
+ *
+ * @param caName
+ * @param testPagePath
+ * @param partOfString
+ * @param position
+ * @param numberOfProposals
+ * @throws CoreException
+ */
+ private void checkOfCAByStartString(String caName, String testPagePath,
+ String partOfString, int position) throws CoreException {
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(testPagePath,
+ IMPORT_PROJECT_NAME);
+ assertNotNull("Could not open specified file " + file.getFullPath(),
+ file);
+
+ IEditorInput input = new FileEditorInput(file);
+
+ assertNotNull("Editor input is null", input);
+
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ // insert string
+ part.getSourceEditor().getTextViewer().getTextWidget()
+ .replaceTextRange(position, 0, partOfString);
+
+ int newPosition = position + partOfString.length();
+
+ // sets cursor position
+ part.getSourceEditor().getTextViewer().getTextWidget().setCaretOffset(
+ newPosition);
+ TestUtil.waitForJobs();
+ TestUtil.delay(2000);
+ SourceViewerConfiguration sourceViewerConfiguration = ((JSPTextEditor) part
+ .getSourceEditor()).getSourceViewerConfigurationForTest();
+ // errase errors which can be on start of editor(for example xuklunner
+ // not found)
+ setException(null);
+ StructuredTextViewerConfiguration stvc = (StructuredTextViewerConfiguration)
sourceViewerConfiguration;
+ IContentAssistant iContentAssistant = stvc
+ .getContentAssistant((ISourceViewer) part.getSourceEditor()
+ .getAdapter(ISourceViewer.class));
+ assertNotNull(iContentAssistant);
+ IContentAssistProcessor iContentAssistProcessor = iContentAssistant
+ .getContentAssistProcessor(caName);
+ assertNotNull(iContentAssistProcessor);
+ ICompletionProposal[] results = iContentAssistProcessor
+ .computeCompletionProposals(part.getSourceEditor()
+ .getTextViewer(), newPosition);
+
+ // remove inserted string
+ part.getSourceEditor().getTextViewer().getTextWidget()
+ .replaceTextRange(position, partOfString.length(), "");
+
+ assertNotNull(results);
+
+ for (int i = 0; i < results.length; i++) {
+
+ String displayString = ((ICompletionProposal) results[i])
+ .getDisplayString();
+ assertNotNull(displayString);
+
+ System.out.print("\n" + displayString);
+ assertEquals(true, displayString.startsWith(partOfString));
+ }
+
+ }
+
}