Author: vpakan(a)redhat.com
Date: 2010-12-14 15:19:53 -0500 (Tue, 14 Dec 2010)
New Revision: 27481
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/VPEAutoTestCase.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/selectionbar/SelectionBarTest.java
Log:
Update SelectionBarTest and add it to test suite.
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-12-14
19:53:38 UTC (rev 27480)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-12-14
20:19:53 UTC (rev 27481)
@@ -27,6 +27,7 @@
import org.jboss.tools.vpe.ui.bot.test.editor.preferences.ShowNonVisualTagsTest;
import
org.jboss.tools.vpe.ui.bot.test.editor.preferences.ShowResourceBundlesUsageasELexpressionsTest;
import org.jboss.tools.vpe.ui.bot.test.editor.preferences.ShowSelectionTagBarTest;
+import org.jboss.tools.vpe.ui.bot.test.editor.selectionbar.SelectionBarTest;
import org.jboss.tools.vpe.ui.bot.test.jbide.JBIDE4556Test;
import org.jboss.tools.vpe.ui.bot.test.palette.CancelTagLibDefenitionTest;
import org.jboss.tools.vpe.ui.bot.test.palette.ImportTagsFromTLDFileTest;
@@ -84,6 +85,8 @@
suite.addTestSuite(MinMaxPanesTest.class);
suite.addTestSuite(EditingELValueTest.class);
suite.addTestSuite(ManipulatingELValueTest.class);
+ suite.addTestSuite(SelectionBarTest.class);
+
return new TestSetup(suite);
}
}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java 2010-12-14
19:53:38 UTC (rev 27480)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java 2010-12-14
20:19:53 UTC (rev 27481)
@@ -1,5 +1,7 @@
package org.jboss.tools.vpe.ui.bot.test;
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -13,14 +15,18 @@
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.test.TestProperties;
import org.jboss.tools.vpe.ui.bot.test.Activator;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
import org.jboss.tools.ui.bot.ext.SWTJBTExt;
import org.jboss.tools.ui.bot.ext.Timing;
import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+import org.jboss.tools.vpe.editor.xpl.CustomSashForm;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.test.JBTSWTBotTestCase;
import org.jboss.tools.ui.bot.test.SWTBotJSPMultiPageEditor;
@@ -488,4 +494,76 @@
bot.shell("Confirm Delete").activate(); //$NON-NLS-1$
bot.button("OK").click(); //$NON-NLS-1$
}
+ /**
+ * Maximize Source Pane
+ * @param botExt
+ * @param pageName
+ */
+ public void maximizeSourcePane(SWTBotExt botExt, String pageName) {
+ botExt.swtBotEditorExtByTitle(pageName).selectPage(
+ IDELabel.VisualPageEditor.VISUAL_SOURCE_TAB_LABEL);
+
+ final org.jboss.tools.vpe.editor.xpl.CustomSashForm csf =
+ bot.widgets(widgetOfType(CustomSashForm.class)).get(0);
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ csf.maxDown();
+ }
+ });
+ }
+ /**
+ * Maximize Visual Pane
+ * @param botExt
+ * @param pageName
+ */
+ public void maximizeVisualPane(SWTBotExt botExt, String pageName) {
+ botExt.swtBotEditorExtByTitle(pageName).selectPage(
+ IDELabel.VisualPageEditor.VISUAL_SOURCE_TAB_LABEL);
+
+ final org.jboss.tools.vpe.editor.xpl.CustomSashForm csf =
+ bot.widgets(widgetOfType(CustomSashForm.class)).get(0);
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ csf.maxUp();
+ }
+ });
+ }
+ /**
+ * Restore Source Pane
+ * @param botExt
+ * @param pageName
+ */
+ public void restoreSourcePane(SWTBotExt botExt, String pageName) {
+ botExt.swtBotEditorExtByTitle(pageName).selectPage(
+ IDELabel.VisualPageEditor.VISUAL_SOURCE_TAB_LABEL);
+
+ final org.jboss.tools.vpe.editor.xpl.CustomSashForm csf =
+ bot.widgets(widgetOfType(CustomSashForm.class)).get(0);
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ csf.downClicked();
+ }
+ });
+ }
+ /**
+ * Restore Visual Pane
+ * @param botExt
+ * @param pageName
+ */
+ public void restoreVisualPane(SWTBotExt botExt, String pageName) {
+ botExt.swtBotEditorExtByTitle(pageName).selectPage(
+ IDELabel.VisualPageEditor.VISUAL_SOURCE_TAB_LABEL);
+
+ final org.jboss.tools.vpe.editor.xpl.CustomSashForm csf =
+ bot.widgets(widgetOfType(CustomSashForm.class)).get(0);
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ csf.upClicked();
+ }
+ });
+ }
}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/selectionbar/SelectionBarTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/selectionbar/SelectionBarTest.java 2010-12-14
19:53:38 UTC (rev 27480)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/selectionbar/SelectionBarTest.java 2010-12-14
20:19:53 UTC (rev 27481)
@@ -13,7 +13,10 @@
import java.awt.event.KeyEvent;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
+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.VPEAutoTestCase;
@@ -22,11 +25,15 @@
*/
public class SelectionBarTest extends VPEAutoTestCase {
- private final String SELECTED_TEXT = "<h:inputText
value=\"#{user.name}\" required=\"true\"> <f:validateLength
maximum=\"30\" minimum=\"3\"/> </h:inputText>";
//$NON-NLS-1$
- private final String SELECTED_TEXT2 = "<f:validateLength
maximum=\"30\" minimum=\"3\"/>"; //$NON-NLS-1$
+ private static final String SELECTED_TEXT = "<h:inputText
value=\"#{user.name}\" required=\"true\"> <f:validateLength
maximum=\"30\" minimum=\"3\"/> </h:inputText>";
//$NON-NLS-1$
+ private static final String SELECTED_TEXT2 = "<f:validateLength
maximum=\"30\" minimum=\"3\"/>"; //$NON-NLS-1$
+ private SWTBotExt botExt = null;
+ private String sashStatus = "restored";
+
public SelectionBarTest() {
super();
+ botExt = new SWTBotExt();
}
@Override
@@ -41,32 +48,88 @@
return false;
}
- public void testSelectionBarTagsList() throws Throwable {
+ public void testSelectionBarContent () {
SWTBotEditor editor = SWTTestExt.packageExplorer.openFile(JBT_TEST_PROJECT_NAME,
- "WebContent", "pages", TEST_PAGE); //$NON-NLS-1$ //$NON-NLS-2$
+ "WebContent", "pages", VPEAutoTestCase.TEST_PAGE); //$NON-NLS-1$
//$NON-NLS-2$
editor.setFocus();
/*
* Navigate to '<h:inputText value="#{user.name}"
required="true">'
*/
editor.toTextEditor().navigateTo(18, 10);
- /*
- * Send key press event to fire VPE listeners
- */
- KeyboardHelper.typeKeyCodeUsingAWT(KeyEvent.VK_LEFT);
- /*
- * Click on the tag in the selection bar
- */
- bot.toolbarDropDownButton("h:inputText").click(); //$NON-NLS-1$
-
- String line = editor.toTextEditor().getSelection();
- line = line.replaceAll("\n", ""); //$NON-NLS-1$ //$NON-NLS-2$
- line = line.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
- line = line.replaceAll("\t", ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("<h:inputText> should be selected", SELECTED_TEXT, line);
//$NON-NLS-1$
-
- bot.toolbarDropDownButton("h:inputText").menuItem("f:validateLength").click();
//$NON-NLS-1$ //$NON-NLS-2$
- line = editor.toTextEditor().getSelection();
- assertEquals("<f:validateLength> should be selected", SELECTED_TEXT2,
line); //$NON-NLS-1$
+ bot.sleep(Timing.time3S());
+ String errorMessage = checkSelectionBarContent();
+ assertNull(errorMessage,errorMessage);
+ maximizeVisualPane(botExt, VPEAutoTestCase.TEST_PAGE);
+ sashStatus = "VisualPageMaximized";
+ errorMessage = checkSelectionBarContent();
+ assertNull(errorMessage,errorMessage);
+ maximizeSourcePane(botExt, VPEAutoTestCase.TEST_PAGE);
+ sashStatus = "SourcePageMaximized";
+ errorMessage = checkSelectionBarContent();
+ assertNull(errorMessage,errorMessage);
+ restoreVisualPane(botExt, VPEAutoTestCase.TEST_PAGE);
+ sashStatus = "restored";
+
}
+ public void testSelectionBarButtonSelection () {
+ SWTBotEditor editor = SWTTestExt.packageExplorer.openFile(JBT_TEST_PROJECT_NAME,
+ "WebContent", "pages", TEST_PAGE); //$NON-NLS-1$
//$NON-NLS-2$
+ editor.setFocus();
+ /*
+ * Navigate to '<h:inputText value="#{user.name}"
required="true">'
+ */
+ editor.toTextEditor().navigateTo(18, 10);
+ /*
+ * Send key press event to fire VPE listeners
+ */
+ KeyboardHelper.typeKeyCodeUsingAWT(KeyEvent.VK_LEFT);
+ /*
+ * Click on the tag in the selection bar
+ */
+ bot.toolbarDropDownButton("h:inputText").click(); //$NON-NLS-1$
+
+ String line = editor.toTextEditor().getSelection();
+ line = line.replaceAll("\n", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ line = line.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ line = line.replaceAll("\t", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("<h:inputText> should be selected", SELECTED_TEXT,
line); //$NON-NLS-1$
+
+
bot.toolbarDropDownButton("h:inputText").menuItem("f:validateLength").click();
//$NON-NLS-1$ //$NON-NLS-2$
+ line = editor.toTextEditor().getSelection();
+ assertEquals("<f:validateLength> should be selected",
SELECTED_TEXT2, line); //$NON-NLS-1$
+ }
+ /**
+ * Checks if Selection Bar has proper buttons
+ * @return error message when Selection Bar has wrong content
+ */
+ private String checkSelectionBarContent () {
+ String errorMessage = null;
+ String buttonLabel = "html";
+ try {
+ bot.toolbarDropDownButton(buttonLabel);
+ buttonLabel = "body";
+ bot.toolbarDropDownButton(buttonLabel);
+ buttonLabel = "f:view";
+ bot.toolbarDropDownButton(buttonLabel);
+ buttonLabel = "h:inputText";
+ bot.toolbarDropDownButton(buttonLabel);
+ } catch (WidgetNotFoundException wnfe){
+ errorMessage = "Selection Bar has to contain Drop Down Button with label
"
+ + buttonLabel
+ + " but it doesn't.";
+ }
+
+ return errorMessage;
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (sashStatus.equals("VisualPageMaximized")){
+ restoreSourcePane(botExt, VPEAutoTestCase.TEST_PAGE);
+ } else if (sashStatus.equals("SourcePageMaximized")){
+ restoreVisualPane(botExt, VPEAutoTestCase.TEST_PAGE);
+ }
+ super.tearDown();
+ }
}