Author: sdzmitrovich
Date: 2008-07-08 10:57:00 -0400 (Tue, 08 Jul 2008)
New Revision: 9090
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2362/editing.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2362Test.java
Log:
junit for
http://jira.jboss.com/jira/browse/JBIDE-2362
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2362/editing.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2362/editing.jsp 2008-07-08
13:24:18 UTC (rev 9089)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2362/editing.jsp 2008-07-08
14:57:00 UTC (rev 9090)
@@ -7,6 +7,13 @@
<f:view>
<h:outputText></h:outputText>
+ <h:outputFormat></h:outputFormat>
+ <h:outputLabel></h:outputLabel>
+ <h:outputLink></h:outputLink>
+ <h:inputText></h:inputText>
+ <h:inputTextarea></h:inputTextarea>
+ <h:inputSecret></h:inputSecret>
+ <h:inputHidden></h:inputHidden>
</f:view>
</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/jbide/JsfJbide2362Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2362Test.java 2008-07-08
13:24:18 UTC (rev 9089)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2362Test.java 2008-07-08
14:57:00 UTC (rev 9090)
@@ -11,7 +11,9 @@
package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IFile;
@@ -20,16 +22,19 @@
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
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.VpeNodeMapping;
+import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.jboss.tools.vpe.editor.util.SelectionUtil;
import org.jboss.tools.vpe.ui.test.TestUtil;
import org.jboss.tools.vpe.ui.test.VpeTest;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
-import org.mozilla.interfaces.nsIDOMNode;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
*
@@ -44,9 +49,21 @@
private static final String SELECTION_PAGE_NAME = "JBIDE/2362/selection.jsp";
private static final String EDITING_PAGE_NAME = "JBIDE/2362/editing.jsp";
- private static final String OUTPUT_TEXT = "outputText";
- private static final String INSERT_TEXT = "value=\"x\"";
+ private static final List<String> ELEMENTS;
+
+ static {
+ ELEMENTS = new ArrayList<String>();
+ ELEMENTS.add("h:outputText");
+ ELEMENTS.add("h:outputFormat");
+ ELEMENTS.add("h:outputLabel");
+ ELEMENTS.add("h:outputLink");
+ ELEMENTS.add("h:inputText");
+ ELEMENTS.add("h:inputTextarea");
+ ELEMENTS.add("h:inputSecret");
+ ELEMENTS.add("h:inputHidden");
+ }
+
public JsfJbide2362Test(String name) {
super(name);
}
@@ -100,8 +117,6 @@
XulRunnerEditor xulRunnerEditor = controller.getXulRunnerEditor();
assertNotNull(xulRunnerEditor);
- domMapping.printMapping();
-
for (VpeNodeMapping nodeMapping : mappings) {
/**
@@ -114,7 +129,7 @@
SelectionUtil.setSourceSelection(controller.getPageContext(),
nodeMapping.getSourceNode(), 0, 0);
- // TestUtil.delay(50);
+ TestUtil.delay(50);
assertNotNull(xulRunnerEditor.getLastSelectedNode());
assertEquals(nodeMapping.getVisualNode(), xulRunnerEditor
@@ -129,87 +144,9 @@
}
- // /**
- // * It is simple selection test.
- // *
- // * @throws Throwable
- // */
- // public void testSimpleVisualSelection() throws Throwable {
- //
- // // wait
- // TestUtil.waitForJobs();
- // // set exception
- // setException(null);
- //
- // // get test page path
- // IFile file = (IFile) TestUtil.getComponentPath(SELECTION_PAGE_NAME,
- // IMPORT_PROJECT_NAME);
- //
- // IEditorInput input = new FileEditorInput(file);
- //
- // // open and get editor
- // JSPMultiPageEditor part = openEditor(input);
- //
- // // get controller
- // VpeController controller = getVpeController(part);
- // assertNotNull(controller);
- //
- // // get dommapping
- // VpeDomMapping domMapping = controller.getDomMapping();
- //
- // assertNotNull(domMapping);
- //
- // // get source map
- // Map<nsIDOMNode, VpeNodeMapping> visualMap = domMapping.getVisualMap();
- // assertNotNull(visualMap);
- //
- // // get collection of VpeNodeMapping
- // Collection<VpeNodeMapping> mappings = visualMap.values();
- // assertNotNull(mappings);
- //
- // // get editor control
- // StyledText styledText = part.getSourceEditor().getTextViewer()
- // .getTextWidget();
- // assertNotNull(styledText);
- //
- // // get xulrunner editor
- // XulRunnerEditor xulRunnerEditor = controller.getXulRunnerEditor();
- // assertNotNull(xulRunnerEditor);
- //
- // VpeSelectionController selectionController = controller
- // .getVisualSelectionController();
- //
- // StructuredTextEditor sourceEditor = controller.getSourceEditor();
- // assertNotNull(sourceEditor);
- //
- // IStructuredModel model = NodesManagingUtil
- // .getStructuredModel(sourceEditor);
- // assertNotNull(model);
- //
- // for (VpeNodeMapping nodeMapping : mappings) {
- //
- // selectionController.getSelection(0).collapse(
- // nodeMapping.getVisualNode(), 0);
- //
- // TestUtil.delay(5000);
- //
- // Point range = SelectionUtil.getSourceSelection(sourceEditor);
- //
- // assertEquals(nodeMapping.getSourceNode(), SelectionUtil
- // .getSourceNodeByPosition(model, range.x));
- // }
- //
- // // check exception
- // if (getException() != null) {
- // throw getException();
- // }
- //
- // }
-
/**
- * It is simple selection test. We set cursor for each source node ( from
- * VpeDomMapping). Then we compare visual nodes which was selected and which
- * was associated with current source node.
+ * This test checks selection after editing of source. If selection is not
+ * lost then test pass.
*
* @throws Throwable
*/
@@ -255,41 +192,44 @@
XulRunnerEditor xulRunnerEditor = controller.getXulRunnerEditor();
assertNotNull(xulRunnerEditor);
- domMapping.printMapping();
+ IDOMDocument document = ((IDOMModel) NodesManagingUtil
+ .getStructuredModel(controller.getSourceEditor()))
+ .getDocument();
- for (VpeNodeMapping nodeMapping : mappings) {
+ for (String tag : ELEMENTS) {
- /**
- * exclude out DomDocument ( it is added to mapping specially ) and
- * nodes without visual representation
- */
- if (OUTPUT_TEXT.equals(nodeMapping.getSourceNode().getLocalName())) {
+ NodeList tagList = document.getElementsByTagName(tag);
- IDOMElement element = (IDOMElement) nodeMapping.getSourceNode();
+ if (tagList.getLength() > 0) {
+ Node node = tagList.item(0);
+
SelectionUtil.setSourceSelection(controller.getPageContext(),
- element, 0, 0);
+ node, 0, 0);
- nsIDOMNode firstSelectedNode = xulRunnerEditor
- .getLastSelectedNode();
+ assertEquals(domMapping.getNearNodeMapping(node)
+ .getVisualNode(), xulRunnerEditor.getLastSelectedNode());
- assertEquals(nodeMapping.getVisualNode(), firstSelectedNode);
+ String insertedString = null;
+ int offset;
+ if (node.getNodeType() == node.ELEMENT_NODE) {
+ offset = ((IDOMElement) node).getStartEndOffset() - 1;
+ insertedString = " value=\"x\" ";
+ } else {
+ offset = ((IDOMNode) node).getStartOffset();
+ insertedString = "someText";
+ }
- int endStart = element.getStartEndOffset() - 1;
-
- styledText.setCaretOffset(endStart);
- styledText.insert(" ");
- TestUtil.delay(50);
- for (int i = 0; i < INSERT_TEXT.length(); i++) {
- endStart++;
- styledText.setCaretOffset(endStart);
- styledText.insert(String.valueOf(INSERT_TEXT.charAt(i)));
+ for (int j = 0; j < insertedString.length(); j++) {
+ styledText.setCaretOffset(offset + j);
+ styledText.insert(String.valueOf(insertedString.charAt(j)));
TestUtil.delay(50);
}
+ // wait
+ TestUtil.delay(500);
+ // wait
assertNotNull(xulRunnerEditor.getLastSelectedNode());
- assertEquals(firstSelectedNode, xulRunnerEditor
- .getLastSelectedNode());
}
}