[jbosstools-commits] JBoss Tools SVN: r41987 - in trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf: ui/test and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Jun 14 11:57:24 EDT 2012


Author: vrubezhny
Date: 2012-06-14 11:57:24 -0400 (Thu, 14 Jun 2012)
New Revision: 41987

Added:
   trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAJsfPredictiveTagNameProposalsTest.java
Modified:
   trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java
Log:
JBIDE-12177
autocompletion is broken in visual editor 

JUnit Test is added for the issue: org.jboss.tools.jsf.jsp.ca.test.CAJsfPredictiveTagNameProposalsTest.

Added: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAJsfPredictiveTagNameProposalsTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAJsfPredictiveTagNameProposalsTest.java	                        (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAJsfPredictiveTagNameProposalsTest.java	2012-06-14 15:57:24 UTC (rev 41987)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ *
+ * Contributor:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.jsp.ca.test;
+
+import java.util.List;
+
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.jboss.tools.common.base.test.contentassist.CATestUtil;
+import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
+import org.jboss.tools.jst.jsp.test.ca.ContentAssistantTestCase;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.TestProjectProvider;
+
+/**
+ * The JUnit test case for issue JBIDE-12177
+ * 
+ * @author Victor V. Rubezhny
+ *
+ */
+public class CAJsfPredictiveTagNameProposalsTest extends ContentAssistantTestCase {
+	private static final String PROJECT_NAME = "JSF2KickStartWithoutLibs";
+	private static final String PAGE_NAME = "WebContent/pages/inputname.xhtml";
+
+	private static final String INSERT_BEFORE = "</ui:composition>";
+	private static final String INSERTION = "<define";
+	private static final String PROPOSAL_TO_APPLY = "ui:define";
+	
+	private TestProjectProvider provider = null;
+
+	public void setUp() throws Exception {
+       provider = new TestProjectProvider("org.jboss.tools.jsf.ui.test", null, PROJECT_NAME,false);  //$NON-NLS-1$
+       project = provider.getProject();
+	}
+
+	public void testJsfPredictiveTagNameProposals() {
+		assertNotNull("Test project '" + PROJECT_NAME + "' is not prepared", project);
+		
+		openEditor(PAGE_NAME);
+		try {
+			// Find start of <ui:composition> tag
+			String documentContent = document.get();
+
+			int start = (documentContent == null ? -1 : documentContent.indexOf(INSERT_BEFORE));
+			assertFalse("Required text '" + INSERT_BEFORE + "' not found in document", (start == -1));
+
+			String newDocumentContent = documentContent.substring(0, start) + 
+					INSERTION + ' ' + documentContent.substring(start);
+
+			int offsetToTest = start + INSERTION.length();
+
+			// Update the document with a new text
+			document.set(newDocumentContent);
+			JobUtils.waitForIdle();
+			
+			List<ICompletionProposal> res = CATestUtil.collectProposals(contentAssistant, viewer, offsetToTest);
+
+			assertTrue("Content Assistant returned no proposals", (res != null && res.size() > 0));
+
+			String replacementString = null;
+			boolean bPropoosalToApplyFound = false;
+			for (ICompletionProposal p : res) {
+				if (!(p instanceof AutoContentAssistantProposal)) 
+					continue;
+				AutoContentAssistantProposal proposal = (AutoContentAssistantProposal)p;
+				String proposalString = proposal.getReplacementString();
+
+				if (proposalString != null && proposalString.startsWith(PROPOSAL_TO_APPLY)) {
+					bPropoosalToApplyFound = true;
+					replacementString = proposal.getReplacementString();
+					proposal.apply(document);
+					break;
+				}
+			}
+			assertTrue("The proposal to apply not found.", bPropoosalToApplyFound && replacementString != null);
+
+			JobUtils.waitForIdle();
+
+			String documentUpdatedContent = document.get();
+			// Make the document text to compare
+			String documentContentToCompare = newDocumentContent.substring(0, start + 1) +
+					replacementString + newDocumentContent.substring(start + INSERTION.length());
+
+			assertTrue("The proposal replacement is failed.", documentContentToCompare.equals(documentUpdatedContent));
+		} finally {
+			closeEditor();
+		}
+	}
+
+
+}


Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/CAJsfPredictiveTagNameProposalsTest.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java	2012-06-14 15:28:31 UTC (rev 41986)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java	2012-06-14 15:57:24 UTC (rev 41987)
@@ -31,6 +31,7 @@
 import org.jboss.tools.jsf.jsp.ca.test.CAJsfAddInfoInELMessagesTest;
 import org.jboss.tools.jsf.jsp.ca.test.CAJsfMessagesProposalsFilteringTest;
 import org.jboss.tools.jsf.jsp.ca.test.CAJsfMessagesProposalsTest;
+import org.jboss.tools.jsf.jsp.ca.test.CAJsfPredictiveTagNameProposalsTest;
 import org.jboss.tools.jsf.jsp.ca.test.CAJsfResourceBundlePropertyApplyTest;
 import org.jboss.tools.jsf.jsp.ca.test.CANotEmptyWhenThereIsNoSpaceBetweenInvertedCommandsInAttributeJBIDE1759Test;
 import org.jboss.tools.jsf.jsp.ca.test.CASuggestsNotOnlyELProposalsJBIDE2437Test;
@@ -176,6 +177,11 @@
 				new String[] { "projects/JSF2KickStartWithoutLibs", }, //$NON-NLS-1$
 				new String[] { "JSF2KickStartWithoutLibs" })); //$NON-NLS-1$
 
+		suite.addTest(new ProjectImportTestSetup(new TestSuite(
+				CAJsfPredictiveTagNameProposalsTest.class), "org.jboss.tools.jsf.base.test", //$NON-NLS-1$
+				new String[] { "projects/JSF2KickStartWithoutLibs", }, //$NON-NLS-1$
+				new String[] { "JSF2KickStartWithoutLibs" })); //$NON-NLS-1$
+
 		return suite;
 	}
 }
\ No newline at end of file



More information about the jbosstools-commits mailing list