Author: sdzmitrovich
Date: 2008-08-14 08:07:01 -0400 (Thu, 14 Aug 2008)
New Revision: 9719
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2170/edit_doctype_test.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2569/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2569/selection.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2526Test.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/JsfJbide2170Test.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/VpeTest.java
Log:
was added junit tests
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2170/edit_doctype_test.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2170/edit_doctype_test.xhtml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2170/edit_doctype_test.xhtml 2008-08-14
12:07:01 UTC (rev 9719)
@@ -0,0 +1,74 @@
+<!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="resources" var="msg" />
+<head>
+<title><ui:insert name="pageTitle">Page
Title</ui:insert></title>
+<style type="text/css">
+body {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 14px;
+}
+
+.header {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 18px;
+}
+
+.bottom {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 9px;
+ text-align: center;
+ vertical-align: middle;
+ color: #8E969D;
+}
+</style>
+</head>
+
+<body bgcolor="#ffffff">
+<table style="border: 1px solid #CAD6E0" align="center"
cellpadding="0"
+ cellspacing="0" border="0" width="400">
+ <tbody>
+
+ <tr>
+ <td class="header" height="42" align="center"
valign="middle"
+ width="100%" bgcolor="#E4EBEB">Facelets Hello
Application</td>
+ </tr>
+ <tr>
+ <td height="1" width="100%"
bgcolor="#CAD6E0"></td>
+ </tr>
+
+ <tr>
+ <td width="100%" colspan="2">
+ <table width="100%" style="height: 150px"
align="left"
+ cellpadding="0" cellspacing="0" border="0">
+ <tbody>
+ <tr>
+ <td align="center" width="100%"
valign="middle"><h:message
+ showSummary="true" showDetail="false"
+ style="color: red; font-weight: bold;" for="name" />
+ <form jsfc="h:form" id="idForCheck">${msg.prompt}
<input
+ label="Name" jsfc="h:inputText" required="true"
id="name"
+ value="#{person.name}" /> <input type="submit"
+ jsfc="h:commandButton" id="submit"
action="greeting"
+ value="Say Hello" /></form>
+
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <td colspan="2" valign="bottom" height="1"
width="100%"
+ bgcolor="#CAD6E0"></td>
+ </tr>
+ </tbody>
+</table>
+</body>
+
+</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2569/selection.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2569/selection.jsp
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/2569/selection.jsp 2008-08-14
12:07:01 UTC (rev 9719)
@@ -0,0 +1,10 @@
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f" %>
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ some text
+ </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 2008-08-14
12:02:49 UTC (rev 9718)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2008-08-14
12:07:01 UTC (rev 9719)
@@ -31,6 +31,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.JBIDE2526Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE2582Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE2584Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE2594Test;
@@ -90,6 +91,7 @@
suite.addTestSuite(JBIDE2582Test.class);
suite.addTestSuite(JBIDE2594Test.class);
suite.addTestSuite(JBIDE924Test.class);
+ suite.addTestSuite(JBIDE2526Test.class);
// $JUnit-END$
// added by Max Areshkau
// add here projects which should be imported for junit tests
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2526Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2526Test.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE2526Test.java 2008-08-14
12:07:01 UTC (rev 9719)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ * Contributors:
+ * 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.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.SelectionUtil;
+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.nsISelection;
+import org.mozilla.interfaces.nsISelectionController;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ * @author sdzmitrovich
+ *
+ *
http://jira.jboss.com/jira/browse/JBIDE-2569
+ *
+ */
+public class JBIDE2526Test extends VpeTest {
+
+ private static final String SELECTION_PAGE_NAME = "JBIDE/2569/selection.jsp";
//$NON-NLS-1$
+
+ public JBIDE2526Test(String name) {
+ super(name);
+ }
+
+ /**
+ *
+ * @throws Throwable
+ */
+ public void testSourceSelection() throws Throwable {
+
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
+
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(SELECTION_PAGE_NAME,
+ JsfAllTests.IMPORT_PROJECT_NAME);
+
+ IEditorInput input = new FileEditorInput(file);
+
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ // get controller
+ VpeController controller = getVpeController(part);
+ assertNotNull(controller);
+
+ Document document = getSourceDocument(controller);
+
+ Node body = document.getDocumentElement().getElementsByTagName("body")
+ .item(0);
+
+ NodeList children = body.getChildNodes();
+
+ for (int i = 0; i < children.getLength(); i++) {
+
+ Node child = children.item(i);
+
+ if (child.getNodeType() == Node.TEXT_NODE
+ && child.getNodeValue() != null)
+
+ SelectionUtil.setSourceSelection(controller.getPageContext(),
+ child, 0, child.getNodeValue().length() - 1);
+
+ nsISelection selection = controller.getVisualSelectionController()
+ .getSelection(nsISelectionController.SELECTION_NORMAL);
+
+ assertEquals(0, selection.getAnchorOffset());
+ assertEquals(TextUtil.visualPosition(child.getNodeValue(), child
+ .getNodeValue().length() - 1), selection.getFocusOffset());
+
+ }
+
+ // check exception
+ if (getException() != null) {
+ throw getException();
+ }
+
+ }
+
+}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2170Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2170Test.java 2008-08-14
12:02:49 UTC (rev 9718)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2170Test.java 2008-08-14
12:07:01 UTC (rev 9719)
@@ -12,15 +12,21 @@
package org.jboss.tools.jsf.vpe.jsf.test.jbide;
import org.eclipse.core.resources.IFile;
+import org.eclipse.swt.custom.StyledText;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
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.DocTypeUtil;
import org.jboss.tools.vpe.ui.test.TestUtil;
import org.jboss.tools.vpe.ui.test.VpeTest;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMDocumentType;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
/**
*
@@ -39,6 +45,10 @@
private static final String COMPLEX_DOCTYPE_TEST_PAGE_NAME =
"JBIDE/2170/complex_doctype_test.xhtml"; //$NON-NLS-1$
+ private static final String EDIT_DOCTYPE_TEST_PAGE_NAME =
"JBIDE/2170/edit_doctype_test.xhtml"; //$NON-NLS-1$
+
+ private static final String ELEMENT_ID = "idForCheck"; //$NON-NLS-1$
+
private static final String CORRECT_NAME = "html3"; //$NON-NLS-1$
public JsfJbide2170Test(String name) {
@@ -57,8 +67,9 @@
setException(null);
// get test page path
- IFile file = (IFile) TestUtil.getComponentPath(
- WITHOUT_DOCTYPE_TEST_PAGE_NAME, JsfAllTests.IMPORT_PROJECT_NAME);
+ IFile file = (IFile) TestUtil
+ .getComponentPath(WITHOUT_DOCTYPE_TEST_PAGE_NAME,
+ JsfAllTests.IMPORT_PROJECT_NAME);
IEditorInput input = new FileEditorInput(file);
@@ -149,7 +160,8 @@
// get test page path
IFile file = (IFile) TestUtil.getComponentPath(
- TEMPLATE_DOCTYPE_TEST_PAGE_NAME, JsfAllTests.IMPORT_PROJECT_NAME);
+ TEMPLATE_DOCTYPE_TEST_PAGE_NAME,
+ JsfAllTests.IMPORT_PROJECT_NAME);
IEditorInput input = new FileEditorInput(file);
@@ -193,8 +205,9 @@
setException(null);
// get test page path
- IFile file = (IFile) TestUtil.getComponentPath(
- COMPLEX_DOCTYPE_TEST_PAGE_NAME, JsfAllTests.IMPORT_PROJECT_NAME);
+ IFile file = (IFile) TestUtil
+ .getComponentPath(COMPLEX_DOCTYPE_TEST_PAGE_NAME,
+ JsfAllTests.IMPORT_PROJECT_NAME);
IEditorInput input = new FileEditorInput(file);
@@ -227,4 +240,68 @@
}
+ /**
+ *
+ * @throws Throwable
+ */
+ public void testEditDoctypePage() throws Throwable {
+
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
+
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(
+ EDIT_DOCTYPE_TEST_PAGE_NAME, JsfAllTests.IMPORT_PROJECT_NAME);
+
+ IEditorInput input = new FileEditorInput(file);
+
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ VpeController controller = getVpeController(part);
+
+ // controller must be not null
+ assertNotNull(controller);
+
+ // get document from opened page
+ Document document = getSourceDocument(controller);
+
+ // controller must be not null
+ assertNotNull(document);
+
+ // get doctype
+ DocumentType documentType = document.getDoctype();
+
+ // documentType must be not null
+ assertNotNull(documentType);
+
+ int start = ((IDOMNode) documentType).getStartOffset();
+ int end = ((IDOMNode) documentType).getEndOffset();
+
+ // get editor control
+ StyledText styledText = part.getSourceEditor().getTextViewer()
+ .getTextWidget();
+ assertNotNull(styledText);
+ styledText.replaceTextRange(start, end - start, "");
+
+ TestUtil.delay(500);
+
+ controller.visualRefresh();
+
+ TestUtil.delay(500);
+
+ nsIDOMDocument visualDocument = getVpeVisualDocument(part);
+
+ nsIDOMElement element = visualDocument.getElementById(ELEMENT_ID);
+ assertNotNull(element);
+
+ // check exception
+ if (getException() != null) {
+ throw getException();
+ }
+
+ }
+
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-08-14
12:02:49 UTC (rev 9718)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-08-14
12:07:01 UTC (rev 9719)
@@ -3228,5 +3228,13 @@
public VpeSelectionController getVisualSelectionController() {
return visualSelectionController;
}
+
+ /**
+ *
+ * @return sourceBuilder
+ */
+ public VpeSourceDomBuilder getSourceBuilder() {
+ return sourceBuilder;
+ }
}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/VpeTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/VpeTest.java 2008-08-14
12:02:49 UTC (rev 9718)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/VpeTest.java 2008-08-14
12:07:01 UTC (rev 9719)
@@ -33,6 +33,7 @@
import org.jboss.tools.vpe.editor.VpeEditorPart;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
import org.mozilla.interfaces.nsIDOMDocument;
+import org.w3c.dom.Document;
/**
@@ -168,7 +169,17 @@
return document;
}
+
+ /**
+ *
+ * @return source document
+ */
+ protected Document getSourceDocument(VpeController controller) {
+ return controller.getSourceBuilder().getSourceDocument();
+
+ }
+
/**
* Gets visual page editor controller.
*
@@ -279,6 +290,4 @@
this.checkWarning = checkWarning;
}
-
-
}