Author: vpakan(a)redhat.com
Date: 2012-04-30 07:49:19 -0400 (Mon, 30 Apr 2012)
New Revision: 40633
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/MultiSelectionTest.java
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/VPEStableSubsetBotTests.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java
Log:
Added Multiple Selection test
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 2012-04-30
11:48:24 UTC (rev 40632)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2012-04-30
11:49:19 UTC (rev 40633)
@@ -17,6 +17,7 @@
import org.jboss.tools.vpe.ui.bot.test.editor.ExternalEditingTest;
import org.jboss.tools.vpe.ui.bot.test.editor.InsertActionsTest;
import org.jboss.tools.vpe.ui.bot.test.editor.MinMaxPanesTest;
+import org.jboss.tools.vpe.ui.bot.test.editor.MultiSelectionTest;
import org.jboss.tools.vpe.ui.bot.test.editor.StylesOnThePageTest;
import org.jboss.tools.vpe.ui.bot.test.editor.TextEditingActionsTest;
import org.jboss.tools.vpe.ui.bot.test.editor.TextSelectionTest;
@@ -214,7 +215,8 @@
RichFacesComponentTest.class,
UnicodeCharacterDisplayingTest.class,
ExternalEditingTest.class,
- VpeToolbarTest.class
+ VpeToolbarTest.class,
+ MultiSelectionTest.class
})
public class VPEAllBotTests extends SWTBotTestCase{
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEStableSubsetBotTests.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEStableSubsetBotTests.java 2012-04-30
11:48:24 UTC (rev 40632)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEStableSubsetBotTests.java 2012-04-30
11:49:19 UTC (rev 40633)
@@ -15,6 +15,7 @@
import org.jboss.tools.vpe.ui.bot.test.editor.BlockCommentTest;
import org.jboss.tools.vpe.ui.bot.test.editor.JspFileEditingTest;
import org.jboss.tools.vpe.ui.bot.test.editor.MinMaxPanesTest;
+import org.jboss.tools.vpe.ui.bot.test.editor.MultiSelectionTest;
import org.jboss.tools.vpe.ui.bot.test.editor.StylesOnThePageTest;
import org.jboss.tools.vpe.ui.bot.test.editor.TextSelectionTest;
import org.jboss.tools.vpe.ui.bot.test.editor.ToggleCommentTest;
@@ -95,7 +96,17 @@
import org.jboss.tools.vpe.ui.bot.test.wizard.VPESourceCodeTemplatesPreferencePageTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
-
+/**
+ * Test Suite containing stable SWT Bot test i. e. test which should always pass
+ * and are not firing events in Visual part of VPE.
+ * Main purpose of this sub suite of VPEAllBotTests suite is to be used by
+ * Continuous Integration Tools for testing VPE component
+ *
+ * Can be deleted once we have stable tests firing events in Visual part of VPE.
+ *
+ * @author vpakan
+ *
+ */
@RunWith(RequirementAwareSuite.class)
@SuiteClasses ({
NewXHTMLPageWizardTest.class,
@@ -178,7 +189,8 @@
OpenOnTest.class,
XhtmlFilePerformanceTest.class,
MarkersTest.class,
- JBIDE9445Test_DuplicateSourceMenu.class
+ JBIDE9445Test_DuplicateSourceMenu.class,
+ MultiSelectionTest.class
})
public class VPEStableSubsetBotTests extends SWTBotTestCase {
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/MultiSelectionTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/MultiSelectionTest.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/MultiSelectionTest.java 2012-04-30
11:49:19 UTC (rev 40633)
@@ -0,0 +1,136 @@
+/*******************************************************************************
+
+ * Copyright (c) 2007-2012 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 org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTJBTExt;
+import org.jboss.tools.vpe.ui.bot.test.tools.SWTBotWebBrowser;
+import org.mozilla.interfaces.nsIDOMNode;
+/**
+ * Tests multiple selection in source pane of VPE and her proper visual representation
+ * within visual pane of VPE
+ * @author vlado pakan
+ *
+ */
+public class MultiSelectionTest extends VPEEditorTestCase {
+
+ private SWTBotExt botExt = null;
+ private static final String OUTPUT_TEXT_0_TEXT = "!@#_OUTPUT-TEXT_0_#@!";
+ private static final String OUTPUT_TEXT_1_TEXT = "!@#_OUTPUT-TEXT_1_#@!";
+
+ private static final String PAGE_TEXT = "<%@ taglib
uri=\"http://java.sun.com/jsf/html\" prefix=\"h\" %>\n" +
+ "<html>\n" +
+ " <body>\n" +
+ "<h:outputText value=\"" + MultiSelectionTest.OUTPUT_TEXT_0_TEXT +
"\"/>" +
+ "<h:outputText value=\"" + MultiSelectionTest.OUTPUT_TEXT_1_TEXT +
"\"/>\n" +
+ " </body>\n" +
+ "</html>";
+
+ private static final String TEST_PAGE_NAME = "MultiSelectionTest.jsp";
+
+ private SWTBotEclipseEditor jspEditor;
+ private SWTBotWebBrowser webBrowser;
+
+ public MultiSelectionTest() {
+ super();
+ botExt = new SWTBotExt();
+ }
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ eclipse.maximizeActiveShell();
+ createJspPage(MultiSelectionTest.TEST_PAGE_NAME);
+ util.waitForNonIgnoredJobs();
+ jspEditor = botExt.editorByTitle(MultiSelectionTest.TEST_PAGE_NAME).toTextEditor();
+ webBrowser = new SWTBotWebBrowser(MultiSelectionTest.TEST_PAGE_NAME,botExt);
+
+ }
+ /**
+ * Tests Multiple Selection
+ */
+ public void testMultipleSeletion(){
+
+ jspEditor.show();
+ jspEditor.setText(MultiSelectionTest.PAGE_TEXT);
+ jspEditor.save();
+
+ SWTJBTExt.selectTextInSourcePane(botExt,
+ MultiSelectionTest.TEST_PAGE_NAME,
+ MultiSelectionTest.OUTPUT_TEXT_1_TEXT,
+ 0,
+ 0,
+ 0);
+
+ assertSelectedNodeHasText(webBrowser, MultiSelectionTest.OUTPUT_TEXT_1_TEXT);
+
+ SWTJBTExt.selectTextInSourcePane(botExt,
+ MultiSelectionTest.TEST_PAGE_NAME,
+ MultiSelectionTest.OUTPUT_TEXT_0_TEXT,
+ 0,
+ 0,
+ 0);
+
+ assertSelectedNodeHasText(webBrowser, MultiSelectionTest.OUTPUT_TEXT_0_TEXT);
+
+ final int xPos = jspEditor.cursorPosition().column;
+ final int yPos = jspEditor.cursorPosition().line;
+ final String tagsLine = jspEditor.getTextOnCurrentLine();
+
+ jspEditor.selectRange(yPos, xPos,
+ tagsLine.indexOf(MultiSelectionTest.OUTPUT_TEXT_1_TEXT) -
tagsLine.indexOf(MultiSelectionTest.OUTPUT_TEXT_0_TEXT));
+
+ assertSelectedNodeHasText(webBrowser, MultiSelectionTest.OUTPUT_TEXT_0_TEXT);
+
+ jspEditor.selectCurrentLine();
+
+ assertTrue("Multiple selection doesn't contain proper nodes.",
+ webBrowser.selectionContainsNodes(false, MultiSelectionTest.OUTPUT_TEXT_0_TEXT
+ , MultiSelectionTest.OUTPUT_TEXT_1_TEXT));
+
+ }
+ @Override
+ protected void closeUnuseDialogs() {
+
+ }
+
+ @Override
+ protected boolean isUnuseDialogOpened() {
+ return false;
+ }
+ @Override
+ public void tearDown() throws Exception {
+ jspEditor.close();
+ super.tearDown();
+ }
+ /**
+ * Asserts selected node in Visual pane has text textToHave
+ * @param webBrowser
+ * @param nodeNameToContain
+ */
+ private static void assertSelectedNodeHasText (SWTBotWebBrowser webBrowser,
+ String textToHave){
+
+ nsIDOMNode selectedNode = webBrowser.getSelectedDomNode();
+
+ assertNotNull("There is no selected node within Visual pane of
VPE",selectedNode);
+ assertNotNull("Selected node within Visual pane of VPE has no
value",selectedNode.getNodeValue());
+
+ final String nodeValue = selectedNode.getNodeValue();
+
+ assertTrue("Selected node within Visual pane has value:\n" + nodeValue
+ + "\nbut has to have value:\n"
+ + textToHave,
+ textToHave.equals(nodeValue));
+
+ }
+}
Property changes on:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/MultiSelectionTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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 2012-04-30
11:48:24 UTC (rev 40632)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java 2012-04-30
11:49:19 UTC (rev 40633)
@@ -94,6 +94,7 @@
public static final String SELECT_THIS_TAG_MENU_LABEL = "Select This Tag";
public static final String PREFERENCES_MENU_LABEL = "Preferences..";
public static final String EXTERNALIZE_STRING_MENU_LABEL = "Externalize selected
string...";
+ public static final String TEAM_MENU_LABEL = "Team";
public static final String JSF_MENU_LABEL = "JSF";
public static final String JBOSS_MENU_LABEL = "JBoss";
@@ -270,12 +271,7 @@
*/
public nsIDOMNode getSelectedDomNode (){
nsIDOMNode result = null;
- display.syncExec(new Runnable() {
- public void run() {
- mozillaEditor.setFocus();
- }
- });
- nsISelection selection =
getSelectionController().getSelection(nsISelectionController.SELECTION_NORMAL);
+ nsISelection selection = getSelection();
if (selection != null){
result = selection.getFocusNode();
}
@@ -941,4 +937,41 @@
}
return result;
}
+ /**
+ * Returns true when current selection contains exactly nodes with values
+ * @param containsWholeNodes if true selection has to contain whole nodes
+ * @param values
+ * @return
+ */
+ public boolean selectionContainsNodes(boolean containsWholeNodes,
+ String... values) {
+ boolean result = true;
+
+ List<nsIDOMNode> selectedNodes = mozillaEditor.getXulRunnerEditor()
+ .getSelectedNodes();
+ if (selectedNodes != null && values != null) {
+ if (selectedNodes.size() == values.length) {
+ int index = 0;
+ while (result && index < values.length) {
+ boolean selectedNodeContainsValue = false;
+ Iterator<nsIDOMNode> itSelectedNodes = selectedNodes.iterator();
+ while (!selectedNodeContainsValue && itSelectedNodes.hasNext()) {
+ if (containsNodeWithValue(itSelectedNodes.next(), values[index])){
+ selectedNodeContainsValue = true;
+ }
+ }
+ if (!selectedNodeContainsValue){
+ result = false;
+ }
+ index++;
+ }
+ } else {
+ result = false;
+ }
+ } else {
+ result = false;
+ }
+
+ return result;
+ }
}