Author: mareshkau
Date: 2008-08-05 11:10:20 -0400 (Tue, 05 Aug 2008)
New Revision: 9522
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2505/testJBIDE2505.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2584/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2584/text.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2584Test.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2505Test.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java
Log:
JBIDE-2584
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2505/testJBIDE2505.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2505/testJBIDE2505.xhtml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2505/testJBIDE2505.xhtml 2008-08-05
15:10:20 UTC (rev 9522)
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core">
+
+<f:loadBundle basename="demo.Messages" var="msg" />
+<head>
+<title>Test Page</title>
+</head>
+
+<body>
+ <!-- Comment Node -->
+ Text Node1
+ <p/>#{msg.hello_message}
+ <h:outputText value="#{msg.hello_message}" />
+</body>
+
+</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2584/text.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2584/text.xhtml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2584/text.xhtml 2008-08-05
15:10:20 UTC (rev 9522)
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core">
+
+<f:loadBundle basename="demo.Messages" var="msg" />
+<head>
+<title><ui:insert name="pageTitle">Page
Title</ui:insert></title>
+</head>
+
+<body>
+ <!-- Comment Node -->
+ Text Node1
+ <p/>#{msg.hello_message}
+</body>
+
+</html>
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2008-08-05
15:09:03 UTC (rev 9521)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2008-08-05
15:10:20 UTC (rev 9522)
@@ -30,6 +30,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE2297Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE2434Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE2505Test;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE2584Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE675Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE788Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide1467Test;
@@ -79,6 +80,7 @@
suite.addTestSuite(JBIDE2119Test.class);
suite.addTestSuite(JBIDE2219Test.class);
suite.addTestSuite(JBIDE2505Test.class);
+ suite.addTestSuite(JBIDE2584Test.class);
// $JUnit-END$
// added by Max Areshkau
// add here projects which should be imported for junit tests
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2505Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2505Test.java 2008-08-05
15:09:03 UTC (rev 9521)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2505Test.java 2008-08-05
15:10:20 UTC (rev 9522)
@@ -44,17 +44,37 @@
setException(null);
//test for element node
- testCaretManupulation(11, 34);
+ testCaretManupulationWithoutElSubstitution("JBIDE/2505/testJBIDE2505.jsp",11,
34); //$NON-NLS-1$
//test for sourceNode
- testCaretManupulation(12, 58);
+ testCaretManupulationWithoutElSubstitution("JBIDE/2505/testJBIDE2505.jsp",12,
58); //$NON-NLS-1$
if(getException()!=null) {
throw getException();
}
}
+ /**
+ * Tests inner nodes include URI
+ *
+ * @throws Throwable
+ */
+ public void testCursorXHTMLJSEL() throws Throwable {
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
- private void testCaretManupulation(int sourceLine, int positioninLine) throws Throwable
{
+ //test for element node
+ testCaretManupulationWithElSubstitution("JBIDE/2505/testJBIDE2505.xhtml",14,
10); //$NON-NLS-1$
+ //test for sourceNode
+ testCaretManupulationWithElSubstitution("JBIDE/2505/testJBIDE2505.xhtml",15,
27); //$NON-NLS-1$
+ if(getException()!=null) {
+ throw getException();
+ }
+ }
+
+
+ private void testCaretManupulationWithoutElSubstitution(String fileName, int sourceLine,
int positioninLine) throws Throwable {
// get test page path
- IFile file = (IFile)
TestUtil.getComponentPath("JBIDE/2505/testJBIDE2505.jsp", //$NON-NLS-1$
+ IFile file = (IFile) TestUtil.getComponentPath(fileName,
JsfAllTests.IMPORT_PROJECT_NAME);
assertNotNull("Could not open specified file " + file.getFullPath(),
//$NON-NLS-1$
file);
@@ -88,4 +108,36 @@
assertEquals("Cursor position doesn't
equals",offset+i,styledText.getCaretOffset()); //$NON-NLS-1$
}
}
+
+ private void testCaretManupulationWithElSubstitution(String fileName, int sourceLine,
int positioninLine) throws Throwable {
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(fileName,
+ JsfAllTests.IMPORT_PROJECT_NAME);
+ assertNotNull("Could not open specified file " + file.getFullPath(),
//$NON-NLS-1$
+ file);
+
+ IEditorInput input = new FileEditorInput(file);
+
+ assertNotNull("Editor input is null", input); //$NON-NLS-1$
+
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ int offset =
TestUtil.getLinePositionOffcet(part.getSourceEditor().getTextViewer(),sourceLine,
positioninLine);
+ // get editor control
+
+ part.getSourceEditor().getTextViewer().getTextWidget().setCaretOffset(offset);
+
+
+
+ VpeController vpeController = getVpeController(part);
+ vpeController.sourceSelectionChanged();
+
+ for (int i=0;i<10;i++) {
+
+ nsIDOMNode domNode = vpeController.getXulRunnerEditor().getLastSelectedNode();
+ assertNotNull(domNode);
+ vpeController.visualRefresh();
+ }
+ }
}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2584Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2584Test.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2584Test.java 2008-08-05
15:10:20 UTC (rev 9522)
@@ -0,0 +1,117 @@
+/*******************************************************************************
+* Copyright (c) 2007-2008 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.vpe.jsf.test.jbide;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
+import org.jboss.tools.vpe.editor.template.VpeTemplate;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Node;
+
+
+
+/**
+ * @author mareshkau
+ * Test class which tests text template
+ */
+public class JBIDE2584Test extends VpeTest {
+
+ public JBIDE2584Test(String name) {
+ super(name);
+ }
+
+ public void testForSimpleText() throws Throwable {
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
+ // Tests CA
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath("JBIDE/2584/text.xhtml",
//$NON-NLS-1$
+ JsfAllTests.IMPORT_PROJECT_NAME);
+ assertNotNull("Could not open specified file " +
"JBIDE/2584/text.xhtml", file); //$NON-NLS-1$ //$NON-NLS-2$
+
+ IEditorInput input = new FileEditorInput(file);
+
+ assertNotNull("Editor input is null", input); //$NON-NLS-1$
+
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ ITextViewer itextViewer = part.getSourceEditor().getTextViewer();
+
+
+ Node simpleTextNode = TestUtil.getNodeMappingBySourcePosition(itextViewer, 14, 10);
+
+ VpeController vpeController = getVpeController(part);
+
+ VpeDomMapping domMapping = vpeController.getDomMapping();
+
+ VpeElementMapping simpleTextMapping = (VpeElementMapping)
domMapping.getNearNodeMapping(simpleTextNode);
+
+ VpeTemplate simpleTextTemplate = simpleTextMapping.getTemplate();
+
+
+ nsIDOMNode domNode =
simpleTextTemplate.getVisualNodeByBySourcePosition(simpleTextMapping,
TestUtil.getLinePositionOffcet(itextViewer, 14, 10), 0, domMapping).getFirstChild();
+
+ assertEquals(simpleTextNode ,simpleTextTemplate.getNodeData(domNode, null,
domMapping).getSourceNode());
+ assertEquals("Node should be a text node",
nsIDOMNode.TEXT_NODE,domNode.getNodeType()); //$NON-NLS-1$
+
+ assertEquals(simpleTextNode.getNodeValue(), domNode.getNodeValue());
+ }
+
+ public void testForElText() throws Throwable {
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
+ // Tests CA
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath("JBIDE/2584/text.xhtml",
//$NON-NLS-1$
+ JsfAllTests.IMPORT_PROJECT_NAME);
+ assertNotNull("Could not open specified file " +
"JBIDE/2584/text.xhtml", file); //$NON-NLS-1$ //$NON-NLS-2$
+
+ IEditorInput input = new FileEditorInput(file);
+
+ assertNotNull("Editor input is null", input); //$NON-NLS-1$
+
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ ITextViewer itextViewer = part.getSourceEditor().getTextViewer();
+
+ Node simpleTextNode = TestUtil.getNodeMappingBySourcePosition(itextViewer, 15, 27);
+
+ VpeController vpeController = getVpeController(part);
+
+ VpeDomMapping domMapping = vpeController.getDomMapping();
+
+ VpeElementMapping simpleTextMapping = (VpeElementMapping)
domMapping.getNearNodeMapping(simpleTextNode);
+
+ VpeTemplate simpleTextTemplate = simpleTextMapping.getTemplate();
+
+ nsIDOMNode domNode =
simpleTextTemplate.getVisualNodeByBySourcePosition(simpleTextMapping,
TestUtil.getLinePositionOffcet(itextViewer, 15, 27), 0, domMapping).getFirstChild();
+
+ assertEquals("Node should be a text node",
nsIDOMNode.TEXT_NODE,domNode.getNodeType()); //$NON-NLS-1$
+ assertEquals(simpleTextNode ,simpleTextTemplate.getNodeData(domNode, null,
domMapping).getSourceNode());
+ assertEquals("Hello", domNode.getNodeValue().trim()); //$NON-NLS-1$
+ }
+
+}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java 2008-08-05
15:09:03 UTC (rev 9521)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestUtil.java 2008-08-05
15:10:20 UTC (rev 9522)
@@ -22,14 +22,19 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.IOverwriteQuery;
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
+import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.ui.test.beans.ImportBean;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
import org.mozilla.xpcom.XPCOMException;
+import org.w3c.dom.Node;
/**
* Class for importing project from jar file
@@ -250,6 +255,18 @@
return importBean;
}
/**
+ * Utility function which returns node mapping by source position(line and position in
line)
+ * @param lineIndex
+ * @param linePosition
+ * @return node for specified src position
+ */
+ public static Node getNodeMappingBySourcePosition(ITextViewer itextViewer, int
lineIndex, int linePosition) {
+ int offset = getLinePositionOffcet(itextViewer, lineIndex, linePosition);
+ IndexedRegion treeNode = ContentAssistUtils.getNodeAt(itextViewer, offset);
+ return (Node) treeNode;
+ }
+
+ /**
* Utility function which is used to calculate offcet in document by line number and
character position
*
* @param textViewer