Author: mareshkau
Date: 2009-02-13 11:48:40 -0500 (Fri, 13 Feb 2009)
New Revision: 13617
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3650/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3650/jbide3650Test.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3650Test.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/JBIDE3030Test.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3650, junit test
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3650/jbide3650Test.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3650/jbide3650Test.xhtml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3650/jbide3650Test.xhtml 2009-02-13
16:48:40 UTC (rev 13617)
@@ -0,0 +1,15 @@
+<!DOCTYPE composition 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">
+<body>
+©20sasd asdsadas asdsaded.
+ 1 a•
+ Design by <a href="sdfsdfzxc"> CSS Templates</a>
+ •
+ Icons by <a href="asdasdasd">zxczxczxc</a>.
+ <h1> d123456789 1</h1>
+ <h:outputText value="<>JBIDE-3650<>" />
+</body>
+</html>
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 2009-02-13
15:35:32 UTC (rev 13616)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-02-13
16:48:40 UTC (rev 13617)
@@ -51,6 +51,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3482Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3617Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3632Test;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3650Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3734Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE675Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE788Test;
@@ -129,8 +130,8 @@
suite.addTestSuite(JBIDE3396Test.class);
suite.addTestSuite(JBIDE3482Test.class);
suite.addTestSuite(JBIDE3632Test.class);
+ suite.addTestSuite(JBIDE3650Test.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/JBIDE3030Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3030Test.java 2009-02-13
15:35:32 UTC (rev 13616)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3030Test.java 2009-02-13
16:48:40 UTC (rev 13617)
@@ -39,7 +39,7 @@
fileNames.add(jbide3030Path+"test.jsp"); //$NON-NLS-1$
fileNames.add(jbide3030Path+"test.html"); //$NON-NLS-1$
fileNames.add(jbide3030Path+"test.xhtml"); //$NON-NLS-1$
- fileNames.add(jbide3030Path+"jbide3385.jsp");
+ fileNames.add(jbide3030Path+"jbide3385.jsp"); //$NON-NLS-1$
}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3650Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3650Test.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3650Test.java 2009-02-13
16:48:40 UTC (rev 13617)
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.ui.IEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.wst.xml.core.internal.document.NodeImpl;
+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.util.NodesManagingUtil;
+import org.jboss.tools.vpe.editor.util.TextUtil;
+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.Element;
+
+/**
+ * junit for
https://jira.jboss.org/jira/browse/JBIDE-3650
+ * @author mareshkau
+ *
+ */
+public class JBIDE3650Test extends VpeTest {
+
+ public JBIDE3650Test(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ setException(null);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if(getException()!=null) {
+ throw new Exception(getException());
+ }
+ super.tearDown();
+ }
+
+ public void testJBIDE3650inTextNodes() throws Exception {
+ testSelection("JBIDE/3650/jbide3650Test.xhtml", null, 12, 7, 17);
//$NON-NLS-1$
+ }
+
+ public void testJBIDE3650inAttributNodes() throws Exception {
+ testSelection("JBIDE/3650/jbide3650Test.xhtml", "value", 7, 13,
43); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ private void testSelection(String pageName, String attributeName, int
expectedVisualPosition, int srcLine, int srcLinePos) throws Exception{
+ IFile ifile = (IFile) TestUtil.getComponentPath(pageName,
+ JsfAllTests.IMPORT_PROJECT_NAME);
+ IEditorInput input = new FileEditorInput(ifile);
+ JSPMultiPageEditor part = openEditor(input);
+ //wait for initialization of editor
+ VpeController vpeController = TestUtil.getVpeController(part);
+ int focusOffcetInSourceDocument =
TestUtil.getLinePositionOffcet(part.getSourceEditor().getTextViewer(), srcLine,
srcLinePos);
+
part.getSourceEditor().getTextViewer().getTextWidget().setCaretOffset(focusOffcetInSourceDocument);
+
vpeController.getPageContext().getSourceBuilder().getStructuredTextViewer().setSelectedRange(focusOffcetInSourceDocument,
0);
+ nsIDOMNode lastSelectedNode =
vpeController.getXulRunnerEditor().getLastSelectedNode();
+ NodeImpl sourceSelectedNode=null;
+ //was selected source el
+ if(attributeName!=null) {
+ Element sourceSelectedElement = (Element)
vpeController.getDomMapping().getNearSourceNode(lastSelectedNode);
+ sourceSelectedNode = (NodeImpl)
sourceSelectedElement.getAttributeNode(attributeName);
+ } else {
+ sourceSelectedNode = (NodeImpl)
vpeController.getDomMapping().getNearSourceNode(lastSelectedNode);
+ }
+ int focusOffcetReferenceToSourceNode = focusOffcetInSourceDocument
+ - NodesManagingUtil.getStartOffsetNode(sourceSelectedNode);
+ int visualPosition = TextUtil.visualPosition(sourceSelectedNode.getValueSource(),
focusOffcetReferenceToSourceNode);
+ assertEquals("Visual Position should be ", expectedVisualPosition ,
visualPosition); //$NON-NLS-1$
+ int calculatedSourcePositon =
TextUtil.sourcePosition(sourceSelectedNode.getValueSource(),
lastSelectedNode.getNodeValue(), visualPosition);
+ assertEquals("calculated Source position and visual position should be
equals", calculatedSourcePositon,focusOffcetReferenceToSourceNode);
//$NON-NLS-1$
+ closeEditors();
+ }
+}