Author: vpakan(a)redhat.com
Date: 2010-10-27 02:31:55 -0400 (Wed, 27 Oct 2010)
New Revision: 26079
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/EditingActionsTest.java
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/InsertActionsTest.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java
Log:
Added EditingActionsTest.
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-10-27
06:02:19 UTC (rev 26078)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-10-27
06:31:55 UTC (rev 26079)
@@ -81,6 +81,7 @@
public static final String CUT = "Cut";
public static final String COPY = "Copy";
public static final String PASTE = "Paste";
+ public static final String UNDO = "Undo";
}
public class Button {
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-10-27
06:02:19 UTC (rev 26078)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-10-27
06:31:55 UTC (rev 26079)
@@ -5,6 +5,7 @@
import junit.framework.TestSuite;
import org.eclipse.swtbot.swt.finder.SWTBotTestCase;
import org.jboss.tools.vpe.ui.bot.test.editor.BlockCommentTest;
+import org.jboss.tools.vpe.ui.bot.test.editor.EditingActionsTest;
import org.jboss.tools.vpe.ui.bot.test.editor.InsertActionsTest;
import org.jboss.tools.vpe.ui.bot.test.editor.ToggleCommentTest;
import org.jboss.tools.vpe.ui.bot.test.editor.VerificationOfNameSpacesTest;
@@ -68,6 +69,7 @@
suite.addTestSuite(ToolbarTextFormattingTest.class);
suite.addTestSuite(VisualEditorContextMenuTest.class);
suite.addTestSuite(InsertActionsTest.class);
+ suite.addTestSuite(EditingActionsTest.class);
return new TestSetup(suite);
}
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/EditingActionsTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/EditingActionsTest.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/EditingActionsTest.java 2010-10-27
06:31:55 UTC (rev 26079)
@@ -0,0 +1,170 @@
+/*******************************************************************************
+
+ * Copyright (c) 2007-2010 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.ui.bot.test.editor;
+
+import java.awt.event.KeyEvent;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.helper.KeyboardHelper;
+import org.jboss.tools.vpe.ui.bot.test.tools.SWTBotWebBrowser;
+import org.mozilla.interfaces.nsIDOMNode;
+/**
+ * Tests JSP file Cut, Copy, Paste, Undo and Delete actions through Visual Editor Menu
+ * @author vlado pakan
+ *
+ */
+public class EditingActionsTest extends VPEEditorTestCase {
+
+ private SWTBotExt botExt = null;
+
+ private static final String PAGE_TEXT = "<%@ taglib
uri=\"http://java.sun.com/jsf/html\" prefix=\"h\" %>\n" +
+ "<%@ taglib
uri=\"http://richfaces.org/rich\"
prefix=\"rich\"%>\n" +
+ "<html>\n" +
+ " <body>\n" +
+ " <h:inputText/>\n" +
+ " <h:outputText value = \"outputText\"/>\n" +
+ " <h:inputText/>\n" +
+ " <rich:comboBox></rich:comboBox>\n" +
+ " </body>\n" +
+ "</html>";
+
+ private static final String TEST_PAGE_NAME = "EditingActionsTest.jsp";
+
+ private SWTBotEclipseEditor jspTextEditor;
+ private SWTBotWebBrowser webBrowser;
+
+ public EditingActionsTest() {
+ super();
+ botExt = new SWTBotExt();
+ }
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ eclipse.maximizeActiveShell();
+ createJspPage(EditingActionsTest.TEST_PAGE_NAME);
+ jspTextEditor =
botExt.editorByTitle(EditingActionsTest.TEST_PAGE_NAME).toTextEditor();
+ webBrowser = new SWTBotWebBrowser(EditingActionsTest.TEST_PAGE_NAME,botExt);
+
+ }
+ /**
+ * Insert Tag After Selected Tag
+ */
+ public void testCutCopyPasteUndo(){
+
+ nsIDOMNode node = initJspPageBeforeInserting(EditingActionsTest.PAGE_TEXT,
"INPUT");
+ // Check Copy Functionality
+ webBrowser.clickContextMenu(node,
+ SWTBotWebBrowser.COPY_MENU_LABEL);
+ jspTextEditor.setFocus();
+ jspTextEditor.selectRange(4,18,1);
+ jspTextEditor.insertText(4,18,"");
+ webBrowser.clickContextMenu(node,
+ SWTBotWebBrowser.PASTE_MENU_LABEL);
+ jspTextEditor.save();
+ botExt.sleep(Timing.time3S());
+webBrowser.displayWebBrowserDOM();
+ assertSourceEditorContains(stripHTMLSourceText(jspTextEditor.getText()),
+
"<h:inputText/><h:inputText/><h:outputTextvalue=\"outputText\"/><h:inputText/>",
+ EditingActionsTest.TEST_PAGE);
+ assertVisualEditorContainsManyNodes(webBrowser, "INPUT", 6,
EditingActionsTest.TEST_PAGE);
+ assertProbelmsViewNoErrors(botExt);
+ // Check Cut Functionality
+ node = webBrowser.getDomNodeByTagName("INPUT",0);
+ webBrowser.selectDomNode(node, 0);
+ botExt.sleep(Timing.time1S());
+ webBrowser.clickContextMenu(node,
+ SWTBotWebBrowser.CUT_MENU_LABEL);
+ jspTextEditor.save();
+ botExt.sleep(Timing.time3S());
+ assertSourceEditorContains(stripHTMLSourceText(jspTextEditor.getText()),
+
"<body><h:inputText/><h:outputTextvalue=\"outputText\"/><h:inputText/><rich:comboBox>",
+ EditingActionsTest.TEST_PAGE);
+ assertVisualEditorContainsManyNodes(webBrowser, "INPUT", 5,
EditingActionsTest.TEST_PAGE);
+ assertProbelmsViewNoErrors(botExt);
+ // Check Paste Functionality
+ node = webBrowser.getDomNodeByTagName("INPUT",1);
+ jspTextEditor.setFocus();
+ jspTextEditor.selectRange(6,18,1);
+ jspTextEditor.insertText(6,18,"");
+ webBrowser.clickContextMenu(node,
+ SWTBotWebBrowser.PASTE_MENU_LABEL);
+ jspTextEditor.save();
+ botExt.sleep(Timing.time3S());
+ assertSourceEditorContains(stripHTMLSourceText(jspTextEditor.getText()),
+
"<h:inputText/><h:outputTextvalue=\"outputText\"/><h:inputText/><h:inputText/>",
+ EditingActionsTest.TEST_PAGE);
+ assertVisualEditorContainsManyNodes(webBrowser, "INPUT", 6,
EditingActionsTest.TEST_PAGE);
+ assertProbelmsViewNoErrors(botExt);
+ // Check Undo Functionality
+ webBrowser.setFocus();
+ KeyboardHelper.typeKeyCodeUsingAWT(KeyEvent.VK_Z, KeyEvent.VK_CONTROL);
+ jspTextEditor.save();
+ botExt.sleep(Timing.time3S());
+ assertSourceEditorContains(stripHTMLSourceText(jspTextEditor.getText()),
+
"<h:outputTextvalue=\"outputText\"/><h:inputText/><rich:comboBox>",
+ EditingActionsTest.TEST_PAGE);
+ KeyboardHelper.typeKeyCodeUsingAWT(KeyEvent.VK_Z, KeyEvent.VK_CONTROL);
+ jspTextEditor.save();
+ botExt.sleep(Timing.time3S());
+ assertSourceEditorContains(stripHTMLSourceText(jspTextEditor.getText()),
+
"<h:inputText/><h:inputText/><h:outputTextvalue=\"outputText\"/>",
+ EditingActionsTest.TEST_PAGE);KeyboardHelper.typeKeyCodeUsingAWT(KeyEvent.VK_Z,
KeyEvent.VK_CONTROL);
+ jspTextEditor.save();
+ botExt.sleep(Timing.time3S());
+ assertSourceEditorContains(stripHTMLSourceText(jspTextEditor.getText()),
+
"<body><h:inputText/><h:outputTextvalue=\"outputText\"/>",
+ EditingActionsTest.TEST_PAGE);
+ // Check Delete Functionality
+ webBrowser.setFocus();
+ webBrowser.selectDomNode(webBrowser.getDomNodeByTagName("INPUT",2),0);
+ botExt.sleep(Timing.time1S());
+ KeyboardHelper.typeKeyCodeUsingAWT(KeyEvent.VK_DELETE);
+ jspTextEditor.save();
+ botExt.sleep(Timing.time3S());
+ assertSourceEditorContains(stripHTMLSourceText(jspTextEditor.getText()),
+
"<body><h:inputText/><h:outputTextvalue=\"outputText\"/><h:inputText/></body>",
+ EditingActionsTest.TEST_PAGE);
+ assertVisualEditorContainsManyNodes(webBrowser, "INPUT", 2,
EditingActionsTest.TEST_PAGE);
+ }
+ /**
+ * Inits JSP Page before Tag will be inserted
+ */
+ private nsIDOMNode initJspPageBeforeInserting(String pageText , String nodeText) {
+
+ jspTextEditor.setText(pageText);
+ jspTextEditor.save();
+ botExt.sleep(Timing.time3S());
+ nsIDOMNode node = webBrowser.getDomNodeByTagName(nodeText, 0);
+ webBrowser.selectDomNode(node, 0);
+ botExt.sleep(Timing.time1S());
+
+ return node;
+
+ }
+
+ @Override
+ protected void closeUnuseDialogs() {
+
+ }
+
+ @Override
+ protected boolean isUnuseDialogOpened() {
+ return false;
+ }
+ @Override
+ protected void tearDown() throws Exception {
+ jspTextEditor.close();
+ super.tearDown();
+ }
+}
Property changes on:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/EditingActionsTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/InsertActionsTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/InsertActionsTest.java 2010-10-27
06:02:19 UTC (rev 26078)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/InsertActionsTest.java 2010-10-27
06:31:55 UTC (rev 26079)
@@ -66,17 +66,10 @@
jspTextEditor.save();
botExt.sleep(Timing.time3S());
- String editorText = jspTextEditor.getText();
- // Check if tag <rich:calendar> was properly added
- assertTrue("File " + TEST_PAGE
- + " has to contain string
'<h:inputText/><rich:calendar>' but it doesn't.\nIt contains:
" + editorText,
- editorText.contains("<h:inputText/><rich:calendar>"));
-
- assertTrue("Visual Representation of file " + TEST_PAGE
- + " has to contain rich:calendar but it doesn't",
-
webBrowser.containsNodeWithNameAndAttributes(webBrowser.getMozillaEditor().getDomDocument(),
"SPAN",
- new String[]{"title"},new String[] {"rich:calendar"}));
-
+ // Check if tag <rich:calendar> was properly added.
+ assertSourceEditorContains(jspTextEditor.getText(),
"<h:inputText/><rich:calendar>", InsertActionsTest.TEST_PAGE);
+ assertVisualEditorContains(webBrowser, "SPAN", new
String[]{"title"},new String[] {"rich:calendar"},
+ InsertActionsTest.TEST_PAGE);
assertProbelmsViewNoErrors(botExt);
}
@@ -94,17 +87,11 @@
jspTextEditor.save();
botExt.sleep(Timing.time3S());
- String trimedEditorText =
VPEEditorTestCase.stripHTMLSourceText(jspTextEditor.getText());
// Check if tag <rich:calendar> was properly added
- assertTrue("File " + TEST_PAGE
- + " has to contain string
'<rich:calendar></rich:calendar><h:inputText/>' but it
doesn't.\nIt contains: " + trimedEditorText,
-
trimedEditorText.contains("<rich:calendar></rich:calendar><h:inputText/>"));
-
- assertTrue("Visual Representation of file " + TEST_PAGE
- + " has to contain rich:calendar but it doesn't",
-
webBrowser.containsNodeWithNameAndAttributes(webBrowser.getMozillaEditor().getDomDocument(),
"SPAN",
- new String[]{"title"},new String[] {"rich:calendar"}));
-
+
assertSourceEditorContains(VPEEditorTestCase.stripHTMLSourceText(jspTextEditor.getText()),
+ "<rich:calendar></rich:calendar><h:inputText/>",
InsertActionsTest.TEST_PAGE);
+ assertVisualEditorContains(webBrowser, "SPAN", new
String[]{"title"},new String[] {"rich:calendar"},
+ InsertActionsTest.TEST_PAGE);
assertProbelmsViewNoErrors(botExt);
}
@@ -131,16 +118,10 @@
jspTextEditor.save();
botExt.sleep(Timing.time3S());
- String trimedEditorText =
VPEEditorTestCase.stripHTMLSourceText(jspTextEditor.getText());
// Check if tag <rich:calendar> was properly added
- assertTrue("File " + TEST_PAGE
- + " has to contain string
'<form><rich:calendar></rich:calendar></form>' but it
doesn't.\nIt contains: " + trimedEditorText,
-
trimedEditorText.contains("<form><rich:calendar></rich:calendar></form>"));
-
- assertTrue("Visual Representation of file " + TEST_PAGE
- + " has to contain rich:calendar but it doesn't",
-
webBrowser.containsNodeWithNameAndAttributes(webBrowser.getMozillaEditor().getDomDocument(),
"FORM"));
-
+
assertSourceEditorContains(VPEEditorTestCase.stripHTMLSourceText(jspTextEditor.getText()),
+ "<form><rich:calendar></rich:calendar></form>",
InsertActionsTest.TEST_PAGE);
+ assertVisualEditorContains(webBrowser, "FORM",
null,null,InsertActionsTest.TEST_PAGE);
assertProbelmsViewNoErrors(botExt);
}
@@ -159,16 +140,10 @@
jspTextEditor.save();
botExt.sleep(Timing.time3S());
- String trimedEditorText =
VPEEditorTestCase.stripHTMLSourceText(jspTextEditor.getText());
// Check if tag <h:form> was properly added
- assertTrue("File " + TEST_PAGE
- + " has to contain string
'<h:form><h:inputText/></h:form>' but it doesn't.\nIt
contains: " + trimedEditorText,
-
trimedEditorText.contains("<h:form><h:inputText/></h:form>"));
-
- assertTrue("Visual Representation of file " + TEST_PAGE
- + " has to contain h:form but it doesn't",
-
webBrowser.containsNodeWithNameAndAttributes(webBrowser.getMozillaEditor().getDomDocument(),
"FORM"));
-
+
assertSourceEditorContains(VPEEditorTestCase.stripHTMLSourceText(jspTextEditor.getText()),
+ "<h:form><h:inputText/></h:form>",
InsertActionsTest.TEST_PAGE);
+ assertVisualEditorContains(webBrowser, "FORM",
null,null,InsertActionsTest.TEST_PAGE);
assertProbelmsViewNoErrors(botExt);
}
@@ -188,7 +163,12 @@
return node;
}
-
+ @Override
+ protected void tearDown() throws Exception {
+ jspTextEditor.close();
+ super.tearDown();
+ }
+
@Override
protected void closeUnuseDialogs() {
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java 2010-10-27
06:02:19 UTC (rev 26078)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java 2010-10-27
06:31:55 UTC (rev 26079)
@@ -12,6 +12,7 @@
import org.jboss.tools.ui.bot.test.WidgetVariables;
import org.jboss.tools.vpe.ui.bot.test.Activator;
import org.jboss.tools.vpe.ui.bot.test.VPEAutoTestCase;
+import org.jboss.tools.vpe.ui.bot.test.tools.SWTBotWebBrowser;
public abstract class VPEEditorTestCase extends VPEAutoTestCase{
@@ -87,5 +88,64 @@
protected static String stripHTMLSourceText(String editorText){
return editorText.replaceAll("\n", "").replaceAll("\t",
"").replaceAll(" ", "");
}
-
+ /**
+ * Asserts if sourceEditorText of file with fileName contains textToContain
+ * @param sourceEditorText
+ * @param textToContain
+ * @param fileName
+ */
+ protected static void assertSourceEditorContains (String sourceEditorText, String
textToContain, String fileName){
+
+ assertTrue("File " + fileName
+ + " has to contain string '"
+ + textToContain
+ + "' but it doesn't.\nIt contains: " + sourceEditorText,
+ sourceEditorText.contains(textToContain));
+
+ }
+ /**
+ * Asserts if Visual Editor contains node with particular attributes
+ * @param webBrowser
+ * @param nodeNameToContain
+ * @param attributeNames
+ * @param attributeValues
+ * @param fileName
+ */
+ protected static void assertVisualEditorContains (SWTBotWebBrowser webBrowser,
+ String nodeNameToContain,
+ String[] attributeNames, String[] attributeValues,
+ String fileName){
+
+ assertTrue("Visual Representation of file " + fileName
+ + " has to contain "
+ + nodeNameToContain
+ + " node but it doesn't",
+
webBrowser.containsNodeWithNameAndAttributes(webBrowser.getMozillaEditor().getDomDocument(),
+ nodeNameToContain,
+ attributeNames,
+ attributeValues));
+
+ }
+ /**
+ * Asserts if Visual Editor contains node nodeNameToContain at least numOccurrencies
times
+ * @param webBrowser
+ * @param nodeNameToContain
+ * @param numOccurrences
+ * @param fileName
+ */
+ protected static void assertVisualEditorContainsManyNodes (SWTBotWebBrowser webBrowser,
+ String nodeNameToContain,
+ int numOccurrences,
+ String fileName){
+
+ assertTrue("Visual Representation of file " + fileName
+ + " has to contain "
+ + nodeNameToContain
+ + " node "
+ + (numOccurrences)
+ + " times but it doesn't",
+ webBrowser.getDomNodeOccurenciesByTagName(nodeNameToContain) == numOccurrences);
+
+ }
+
}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java 2010-10-27
06:02:19 UTC (rev 26078)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java 2010-10-27
06:31:55 UTC (rev 26079)
@@ -205,6 +205,16 @@
}
/**
+ * Returns number of occurrences of specified tagName
+ * @param tagName
+ * @return
+ */
+ public long getDomNodeOccurenciesByTagName(String tagName) {
+
+ return getNsIDOMDocument().getElementsByTagName(tagName).getLength();
+
+ }
+ /**
* Returns first node corresponding to specified tagName
* @param tagName
* @return