Author: yzhishko
Date: 2009-07-30 11:57:14 -0400 (Thu, 30 Jul 2009)
New Revision: 16906
Added:
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/resources/VerificationOfNameSpaces.xml
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VerificationOfNameSpaces.java
Modified:
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/BlockCommentTest.java
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/ToggleCommentTest.java
Log:
I wrote a method that checked all VPE content. Test for namespace's verification was
added.
Added:
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/resources/VerificationOfNameSpaces.xml
===================================================================
---
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/resources/VerificationOfNameSpaces.xml
(rev 0)
+++
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/resources/VerificationOfNameSpaces.xml 2009-07-30
15:57:14 UTC (rev 16906)
@@ -0,0 +1,6 @@
+<BODY ID="__content__area__">
+<SPAN CLASS="vpe-text">
+...
+</SPAN><BR VPE:PSEUDO-ELEMENT="yes" STYLE="font-style: italic;
color: green; -moz-user-modify: read-only;"/>
+
+</BODY>
\ No newline at end of file
Modified:
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java
===================================================================
---
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java 2009-07-30
15:53:13 UTC (rev 16905)
+++
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java 2009-07-30
15:57:14 UTC (rev 16906)
@@ -3,6 +3,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.eclipse.core.runtime.FileLocator;
@@ -16,10 +17,16 @@
import org.jboss.tools.ui.bot.test.SWTBotMultiPageEditor;
import org.jboss.tools.ui.bot.test.WidgetVariables;
import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.editor.VpeEditorPart;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
+import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMNodeList;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
public abstract class VPEAutoTestCase extends JBTSWTBotTestCase{
@@ -99,15 +106,14 @@
waitForJobs();
}
- protected void performContentTest(String expectedVPEContent, SWTBotMultiPageEditor
editor) throws Throwable{
+ protected void performContentTestByIDs(String expectedVPEContentFile,
SWTBotMultiPageEditor editor) throws Throwable{
JSPMultiPageEditor multiPageEditor = editor.getJSPMultiPageEditor();
assertNotNull(multiPageEditor);
VpeController controller = TestUtil.getVpeController(multiPageEditor);
- String expectedVPEContentFilePath = getPathToResources(expectedVPEContent);
-// expectedVPEContentFilePath = expectedVPEContentFilePath.substring(16);
+ String expectedVPEContentFilePath = getPathToResources(expectedVPEContentFile);
File xmlTestFile = new File (expectedVPEContentFilePath);
@@ -212,6 +218,29 @@
}
}
+ protected void performContentTestByDocument(String expectedVPEContentFile,
SWTBotMultiPageEditor editor) throws Throwable{
+ JSPMultiPageEditor multiPageEditor = editor.getJSPMultiPageEditor();
+ assertNotNull(multiPageEditor);
+
+ nsIDOMDocument visualDocument =
((VpeEditorPart)multiPageEditor.getVisualEditor()).getVisualEditor().getDomDocument();
+
+ String expectedVPEContentFilePath = getPathToResources(expectedVPEContentFile);
+
+ File xmlTestFile = new File (expectedVPEContentFilePath);
+
+ Document xmlTestDocument = TestDomUtil.getDocument(xmlTestFile);
+ assertNotNull("Can't get test file, possibly file not exists
"+xmlTestFile,xmlTestDocument); //$NON-NLS-1$
+
+ compareDocuments(visualDocument, xmlTestDocument);
+
+ }
+
+ private void compareDocuments (nsIDOMDocument visualDocument, Document xmlTestDocument)
throws ComparisonException{
+ nsIDOMNode visualBodyNode =
visualDocument.getElementsByTagName("BODY").item(0);
+ Node testBodyNode = xmlTestDocument.getElementsByTagName("BODY").item(0);
+ TestDomUtil.compareNodes(visualBodyNode, testBodyNode);
+ }
+
protected abstract void closeUnuseDialogs();
protected abstract boolean isUnuseDialogOpened();
Modified:
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/BlockCommentTest.java
===================================================================
---
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/BlockCommentTest.java 2009-07-30
15:53:13 UTC (rev 16905)
+++
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/BlockCommentTest.java 2009-07-30
15:57:14 UTC (rev 16906)
@@ -1,11 +1,9 @@
package org.jboss.tools.vpe.ui.bot.test.editor;
-import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.jboss.tools.ui.bot.test.WidgetVariables;
@@ -23,14 +21,6 @@
SWTBot innerBot = bot.viewByTitle(WidgetVariables.PACKAGE_EXPLORER).bot();
SWTBotTree tree = innerBot.tree();
try {
- List<? extends SWTBotEditor> editors = bot.editors();
- for (int i = 0; i < editors.size(); i++) {
- editors.get(i).close();
- }
-
- } catch (Exception e) {
- }
- try {
tree.expandNode(projectProperties.getProperty("JSFProjectName"))
.expandNode("WebContent").expandNode("pages").getNode(TEST_PAGE).doubleClick();
} catch (Exception e) {
@@ -115,7 +105,7 @@
}
editor.save();
waitForJobs();
- performContentTest(testPage, bot.multiPageEditorByTitle(TEST_PAGE));
+ performContentTestByIDs(testPage, bot.multiPageEditorByTitle(TEST_PAGE));
}
private void pressBlockCommentHotKeys(){
Modified:
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/ToggleCommentTest.java
===================================================================
---
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/ToggleCommentTest.java 2009-07-30
15:53:13 UTC (rev 16905)
+++
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/ToggleCommentTest.java 2009-07-30
15:57:14 UTC (rev 16906)
@@ -1,11 +1,9 @@
package org.jboss.tools.vpe.ui.bot.test.editor;
-import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.jboss.tools.ui.bot.test.WidgetVariables;
@@ -23,14 +21,6 @@
SWTBot innerBot = bot.viewByTitle(WidgetVariables.PACKAGE_EXPLORER).bot();
SWTBotTree tree = innerBot.tree();
try {
- List<? extends SWTBotEditor> editors = bot.editors();
- for (int i = 0; i < editors.size(); i++) {
- editors.get(i).close();
- }
-
- } catch (Exception e) {
- }
- try {
tree.expandNode(projectProperties.getProperty("JSFProjectName"))
.expandNode("WebContent").expandNode("pages").getNode(TEST_PAGE).doubleClick();
} catch (Exception e) {
@@ -81,7 +71,7 @@
}
editor.save();
waitForJobs();
- performContentTest(testPage, bot.multiPageEditorByTitle(TEST_PAGE));
+ performContentTestByIDs(testPage, bot.multiPageEditorByTitle(TEST_PAGE));
}
private void pressToggleCommentHotKeys(){
Added:
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VerificationOfNameSpaces.java
===================================================================
---
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VerificationOfNameSpaces.java
(rev 0)
+++
workspace/yzhishko/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VerificationOfNameSpaces.java 2009-07-30
15:57:14 UTC (rev 16906)
@@ -0,0 +1,76 @@
+package org.jboss.tools.vpe.ui.bot.test.editor;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.jboss.tools.ui.bot.test.WidgetVariables;
+import org.jboss.tools.vpe.ui.bot.test.VPEAutoTestCase;
+
+public class VerificationOfNameSpaces extends VPEAutoTestCase{
+
+ private static String textEditor;
+ private static String testText = "<jsp:root\n" +
+ "xmlns:jsp=\"http://java.sun.com/JSP/Page\n" +
+ "xmlns:public=\"http://www.jspcentral.com/tags\"\n" +
+ "version=\"1.2\">\n" +
+ "...\n" +
+ "</jsp:root>";
+ private static SWTBotEclipseEditor editor;
+
+ public void testVerificationOfNameSpaces() throws Throwable{
+
+ //Test open page
+
+ SWTBot innerBot = bot.viewByTitle(WidgetVariables.PACKAGE_EXPLORER).bot();
+ SWTBotTree tree = innerBot.tree();
+ try {
+ tree.expandNode(projectProperties.getProperty("JSFProjectName"))
+ .expandNode("WebContent").expandNode("pages").getNode(TEST_PAGE).doubleClick();
+ } catch (Exception e) {
+ }
+
+ editor = bot.editorByTitle(TEST_PAGE).toTextEditor();
+ textEditor = editor.getText();
+
+ //Test clear source
+
+ editor.setFocus();
+ bot.menu("Edit").menu("Select All").click();
+ waitForJobs();
+ bot.menu("Edit").menu("Delete").click();
+
+ //Test insert test text
+
+ editor.setText(testText);
+ editor.save();
+ waitForJobs();
+ performContentTestByDocument("VerificationOfNameSpaces.xml",
bot.multiPageEditorByTitle(TEST_PAGE));
+
+ }
+
+ @Override
+ protected void closeUnuseDialogs() {
+
+ }
+
+ @Override
+ protected boolean isUnuseDialogOpened() {
+ return false;
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+
+ //Restore page state before tests
+
+ editor.setFocus();
+ bot.menu("Edit").menu("Select All").click();
+ bot.menu("Edit").menu("Delete").click();
+ editor.setText(textEditor);
+ editor.save();
+ waitForJobs();
+ editor.close();
+ super.tearDown();
+ }
+
+}
Show replies by date