From jbosstools-commits at lists.jboss.org Tue Jul 1 15:42:01 2008 Content-Type: multipart/mixed; boundary="===============4844908563459720182==" MIME-Version: 1.0 From: jbosstools-commits at lists.jboss.org To: jbosstools-commits at lists.jboss.org Subject: [jbosstools-commits] JBoss Tools SVN: r9039 - in trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test: src/org/jboss/tools/jsf/vpe/jsf/test/jbide and 1 other directory. Date: Tue, 01 Jul 2008 15:42:01 -0400 Message-ID: --===============4844908563459720182== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mareshkau Date: 2008-07-01 15:42:01 -0400 (Tue, 01 Jul 2008) New Revision: 9039 Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebCo= ntent/pages/JBIDE/788/testCAforXHTML.xhtml trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf= /vpe/jsf/test/jbide/JBIDE788Test.java Log: http://jira.jboss.org/jira/browse/JBIDE-2444 Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTes= t/WebContent/pages/JBIDE/788/testCAforXHTML.xhtml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebC= ontent/pages/JBIDE/788/testCAforXHTML.xhtml 2008-07-01 19:18:15 UTC (rev 90= 38) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebC= ontent/pages/JBIDE/788/testCAforXHTML.xhtml 2008-07-01 19:42:01 UTC (rev 90= 39) @@ -12,11 +12,11 @@ - + <

Test of CA XHTML

CA Test - + <
= = Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/to= ols/jsf/vpe/jsf/test/jbide/JBIDE788Test.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/jbide/JBIDE788Test.java 2008-07-01 19:18:15 UTC (rev 9038) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/jbide/JBIDE788Test.java 2008-07-01 19:42:01 UTC (rev 9039) @@ -12,6 +12,7 @@ = import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; +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; @@ -53,9 +54,9 @@ setException(null); // Tests CA = - checkOfCAByStartString(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xht= ml","s:validateFormat",359); //$NON-NLS-1$//$NON-NLS-2$ - checkOfCAByStartString(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xht= ml","rich:validateA", 427); //$NON-NLS-1$ //$NON-NLS-2$ - checkOfCAByStartString(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xht= ml","c:otherwi",493); //$NON-NLS-1$//$NON-NLS-2$ + checkOfCAByStartString(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xht= ml","s:validateFormat",11,2); //$NON-NLS-1$//$NON-NLS-2$ + checkOfCAByStartString(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xht= ml","rich:validateA", 14,14); //$NON-NLS-1$ //$NON-NLS-2$ + checkOfCAByStartString(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xht= ml","c:otherwi",18,6); //$NON-NLS-1$//$NON-NLS-2$ = // check exception if (getException() !=3D null) { @@ -74,7 +75,7 @@ setException(null); // Tests CA = - ICompletionProposal[] results =3D checkOfCAByStartString(CA_NAME, "JBIDE= /788/testCAMessageBundlesAndEL.xhtml","",545,false); //$NON-NLS-1$ //$NON-N= LS-2$ + ICompletionProposal[] results =3D checkOfCAByStartString(CA_NAME, "JBIDE= /788/testCAMessageBundlesAndEL.xhtml","",11,31,false); //$NON-NLS-1$ //$NON= -NLS-2$ assertNotNull(results); assertTrue("The lenft should be more than 0",results.length>0); //$NON-N= LS-1$ boolean isMatches=3Dtrue; @@ -87,8 +88,8 @@ = } assertTrue("String not matches", isMatches); //$NON-NLS-1$ - = - results =3D checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAPathProposa= ls.xhtml","",511,false); //$NON-NLS-1$//$NON-NLS-2$ + //TODO Max Areshkau This functionality doesn't works now, + results =3D checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAPathProposa= ls.xhtml","",11,41,false); //$NON-NLS-1$//$NON-NLS-2$ assertNotNull(results); isMatches =3D false; for(ICompletionProposal completionProposal : results) { @@ -139,7 +140,7 @@ // set exception setException(null); // Tests CA - ICompletionProposal[] results =3DcheckOfCAByStartString(CA_NAME, "JBIDE/= 788/testCAforHtml.html", "", 42,false); //$NON-NLS-1$//$NON-NLS-2$ + ICompletionProposal[] results =3DcheckOfCAByStartString(CA_NAME, "JBIDE/= 788/testCAforHtml.html", "", 5, 13,false); //$NON-NLS-1$//$NON-NLS-2$ = assertNotNull(results); assertTrue("The lenft should be more than 0",results.length>0); //$NON-N= LS-1$ @@ -174,7 +175,7 @@ // Tests CA = // cursor will set after "outputText" tag - ICompletionProposal[] results =3D checkOfCAByStartString(CA_NAME, "JBIDE= /788/testCAforJSP.jsp", "h:outp",1139,false); //$NON-NLS-1$ //$NON-NLS-2$ + ICompletionProposal[] results =3D checkOfCAByStartString(CA_NAME, "JBIDE= /788/testCAforJSP.jsp", "h:outp",26,14,false); //$NON-NLS-1$ //$NON-NLS-2$ = for (ICompletionProposal completionProposal : results) { = @@ -205,11 +206,11 @@ = // cursor will set after "<" simbol checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforXHTML.xhtml", "c", /= /$NON-NLS-1$ //$NON-NLS-2$ - 687); + 15,12); = // cursor will set after "outputText" tag checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforXHTML.xhtml", "s", = //$NON-NLS-1$//$NON-NLS-2$ - 778); + 19,43); = // check exception if (getException() !=3D null) { @@ -223,13 +224,14 @@ * @param caName * @param testPagePath * @param partOfString - * @param position - * @param numberOfProposals + * @param lineIndex + * @param linePosition + * @return * @throws CoreException */ private ICompletionProposal[] checkOfCAByStartString(String caName, St= ring testPagePath, - String partOfString, int position) throws CoreException { - return this.checkOfCAByStartString(caName, testPagePath, partOfStr= ing, position,true); + String partOfString, int lineIndex, int linePosition) throws C= oreException { + return this.checkOfCAByStartString(caName, testPagePath, partOfStr= ing, lineIndex, linePosition,true); = } /** @@ -237,14 +239,15 @@ * @param caName * @param testPagePath * @param partOfString - * @param position + * @param lineIndex + * @param linePosition * @param isCheck * @return * @throws CoreException */ = private ICompletionProposal[] checkOfCAByStartString(String caName, Strin= g testPagePath, - String partOfString, int position,boolean isCheck) throws Core= Exception { + String partOfString, int lineIndex, int linePosition,boolean i= sCheck) throws CoreException { // get test page path IFile file =3D (IFile) TestUtil.getComponentPath(testPagePath, IMPORT_PROJECT_NAME); @@ -257,6 +260,8 @@ = // open and get editor JSPMultiPageEditor part =3D openEditor(input); + = + int position =3D getLinePositionOffcet(part.getSourceEditor().getT= extViewer(), lineIndex, linePosition); = // insert string part.getSourceEditor().getTextViewer().getTextWidget() @@ -267,6 +272,7 @@ // sets cursor position part.getSourceEditor().getTextViewer().getTextWidget().setCaretOff= set( newPosition); + = TestUtil.waitForJobs(); TestUtil.delay(1000); SourceViewerConfiguration sourceViewerConfiguration =3D ((JSPTextE= ditor) part @@ -289,7 +295,6 @@ // remove inserted string part.getSourceEditor().getTextViewer().getTextWidget() .replaceTextRange(position, partOfString.length(), ""); //= $NON-NLS-1$ - assertNotNull(results); assertTrue("Number of ca proposals shouldn't be a null",results.le= ngth>0); //$NON-NLS-1$ if (isCheck) { @@ -305,5 +310,46 @@ TestUtil.delay(1000L); return results; } - + /** + * Utility function which is used to calculate offcet in document by line= number and character position + * = + * @param textViewer + * @param lineIndex + * @param linePosition + * @return offcet in document + * @throws IllegalArgumentException + */ + private static final int getLinePositionOffcet(ITextViewer textViewer, in= t lineIndex, int linePosition) throws IllegalArgumentException { + = + int resultOffcet =3D 0; + = + if(textViewer=3D=3Dnull) { + = + throw new IllegalArgumentException("Text viewer shouldn't be a null");= //$NON-NLS-1$ + } = + //lineIndex-1 becose calculating of line begibns in eclipse from one, bu= t should be form zero + resultOffcet=3DtextViewer.getTextWidget().getOffsetAtLine(lineIndex-1); + //here we get's tabs length + //for more example you can see code org.eclipse.ui.texteditor.AbstractTe= xtEditor(a)getCursorPosition() and class $PositionLabelValue + int tabWidth =3D textViewer.getTextWidget().getTabs(); + int characterOffset=3D0; + String currentString =3D textViewer.getTextWidget().getLine(lineIndex-1); + int pos=3D1; + for (int i=3D 0; (i < currentString.length())&&(pos