Author: vpakan(a)redhat.com
Date: 2011-06-10 04:25:29 -0400 (Fri, 10 Jun 2011)
New Revision: 32003
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/OpenOnTest.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/OpenOnHelper.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/OpenOnTest.java
Log:
Refactoring Open Ons testing functionality
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/OpenOnTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/OpenOnTest.java 2011-06-10
07:55:13 UTC (rev 32002)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/OpenOnTest.java 2011-06-10
08:25:29 UTC (rev 32003)
@@ -10,33 +10,21 @@
******************************************************************************/
package org.jboss.tools.jsf.ui.bot.test.smoke;
-import org.apache.log4j.Logger;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
import org.jboss.tools.jsf.ui.bot.test.JSFAutoTestCase;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.helper.OpenOnHelper;
-import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.jboss.tools.ui.bot.test.JBTSWTBotTestCase;
/**
* Test open on functionality of JSF components within jsp page
* @author Vladimir Pakan
*
*/
public class OpenOnTest extends JSFAutoTestCase{
- private static Logger log = Logger.getLogger(JBTSWTBotTestCase.class);
+
public void testOpenOn() throws Throwable{
- try{
- bot.menu(IDELabel.Menu.FILE).menu(IDELabel.Menu.CLOSE_ALL).click();
- log.info("All Editors closed");
- } catch (WidgetNotFoundException wnfe){
- log.info("No Editors to close");
- } catch (TimeoutException te){
- log.info("No Editors to close");
- }
-
+
+ eclipse.closeAllEditors();
openPage();
checkOpenOn();
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2011-06-10
07:55:13 UTC (rev 32002)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2011-06-10
08:25:29 UTC (rev 32003)
@@ -12,14 +12,12 @@
package org.jboss.tools.ui.bot.ext;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
-import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
import static org.hamcrest.Matchers.allOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -34,7 +32,6 @@
import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
@@ -46,6 +43,7 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
import org.hamcrest.Matcher;
import org.jboss.tools.ui.bot.ext.condition.ButtonIsDisabled;
import org.jboss.tools.ui.bot.ext.entity.JavaClassEntity;
@@ -54,8 +52,6 @@
import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject;
import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.ServerServer;
import org.jboss.tools.ui.bot.ext.gen.ActionItem.Preference;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem.View;
-import org.jboss.tools.ui.bot.ext.gen.INewObject;
import org.jboss.tools.ui.bot.ext.gen.IServer;
import org.jboss.tools.ui.bot.ext.gen.IServerRuntime;
import org.jboss.tools.ui.bot.ext.types.EntityType;
@@ -63,7 +59,6 @@
import org.jboss.tools.ui.bot.ext.types.IDELabel.PreferencesDialog;
import org.jboss.tools.ui.bot.ext.types.PerspectiveType;
import org.jboss.tools.ui.bot.ext.types.ViewType;
-import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
import org.jboss.tools.ui.bot.ext.view.RemoteSystems;
/**
@@ -1439,4 +1434,17 @@
return null;
}
}
+ /**
+ * Closes all opened Editors
+ */
+ public void closeAllEditors(){
+ try{
+ bot.menu(IDELabel.Menu.FILE).menu(IDELabel.Menu.CLOSE_ALL).click();
+ log.info("All Editors closed");
+ } catch (WidgetNotFoundException wnfe){
+ log.info("No Editors to close");
+ } catch (TimeoutException te){
+ log.info("No Editors to close");
+ }
+ }
}
\ No newline at end of file
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java 2011-06-10
07:55:13 UTC (rev 32002)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java 2011-06-10
08:25:29 UTC (rev 32003)
@@ -18,6 +18,7 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
@@ -520,4 +521,78 @@
log.info("Report usage window didn't appear");
}
}
+
+ /**
+ * Selects textToSelect within Source Pane of editor with title editorTitle
+ * @param bot
+ * @param editorTitle
+ * @param textToSelect
+ * @param selectionOffset
+ * @param selectionLength
+ * @param textToSelectIndex
+ * @return SWTBotEclipseEditor
+ */
+ public static SWTBotEclipseEditor selectTextInSourcePane(SWTBotExt bot,
+ String editorTitle, String textToSelect ,
+ int selectionOffset , int selectionLength , int textToSelectIndex) {
+
+ SWTBotEclipseEditor editor = bot.editorByTitle(editorTitle).toTextEditor();
+ String editorText = editor.getText();
+ boolean found = false;
+ int iStartIndex = 0;
+ int iRow = 0;
+ if (editorText != null && editorText.length() > 0 &&
editorText.contains(textToSelect)){
+ String[] editorLines = editorText.split("\n");
+ int iOccurenceIndex = 0;
+ while (!found && iRow < editorLines.length){
+ String lineText = editorLines[iRow];
+ iStartIndex = 0;
+ while (!found && lineText.contains(textToSelect)){
+ if (iOccurenceIndex == textToSelectIndex){
+ found = true;
+ iStartIndex += lineText.indexOf(textToSelect);
+ }
+ else{
+ iOccurenceIndex++;
+ int iNewStartIndex = lineText.indexOf(textToSelect) + textToSelect.length();
+ iStartIndex += iNewStartIndex;
+ lineText = lineText.substring(iNewStartIndex);
+ }
+ }
+ if (!found){
+ iRow++;
+ }
+ }
+
+ }
+
+ if (found) {
+ editor.selectRange(iRow, iStartIndex + selectionOffset, selectionLength);
+ }
+ else{
+ throw new SelectTextInSourcePaneException ("Wrong parameters specified for
method selectTextInSourcePane.\n" +
+ "Unable to select required text '" + textToSelect +
+ "' within editor with title " + editorTitle + ".\n" +
+ "Editor text is: " + editorText);
+ }
+
+ return editor;
+
+ }
+
+ /**
+ * Selects textToSelect within Source Pane of editor with title editorTitle
+ * @param bot
+ * @param editorTitle
+ * @param textToSelect
+ * @param selectionOffset
+ * @param selectionLength
+ * @return SWTBotEclipseEditor
+ */
+ public static SWTBotEclipseEditor selectTextInSourcePane(SWTBotExt bot,
+ String editorTitle, String textToSelect ,
+ int selectionOffset , int selectionLength) {
+ return SWTJBTExt.selectTextInSourcePane(bot, editorTitle, textToSelect,
+ selectionOffset, selectionLength, 0);
+ }
}
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2011-06-10
07:55:13 UTC (rev 32002)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2011-06-10
08:25:29 UTC (rev 32003)
@@ -32,7 +32,6 @@
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.SWTBot;
@@ -800,77 +799,5 @@
File.separator +
projectName;
}
- /**
- * Selects textToSelect within Source Pane of editor with title editorTitle
- * @param bot
- * @param editorTitle
- * @param textToSelect
- * @param selectionOffset
- * @param selectionLength
- * @return SWTBotEclipseEditor
- */
- public static SWTBotEclipseEditor selectTextInSourcePane(SWTBotExt bot,
- String editorTitle, String textToSelect ,
- int selectionOffset , int selectionLength) {
- return selectTextInSourcePane(bot, editorTitle, textToSelect,
- selectionOffset, selectionLength, 0);
- }
- /**
- * Selects textToSelect within Source Pane of editor with title editorTitle
- * @param bot
- * @param editorTitle
- * @param textToSelect
- * @param selectionOffset
- * @param selectionLength
- * @param textToSelectIndex
- * @return SWTBotEclipseEditor
- */
- public static SWTBotEclipseEditor selectTextInSourcePane(SWTBotExt bot,
- String editorTitle, String textToSelect ,
- int selectionOffset , int selectionLength , int textToSelectIndex) {
-
- SWTBotEclipseEditor editor = bot.editorByTitle(editorTitle).toTextEditor();
- String editorText = editor.getText();
- boolean found = false;
- int iStartIndex = 0;
- int iRow = 0;
- if (editorText != null && editorText.length() > 0 &&
editorText.contains(textToSelect)){
- String[] editorLines = editorText.split("\n");
- int iOccurenceIndex = 0;
- while (!found && iRow < editorLines.length){
- String lineText = editorLines[iRow];
- iStartIndex = 0;
- while (!found && lineText.contains(textToSelect)){
- if (iOccurenceIndex == textToSelectIndex){
- found = true;
- iStartIndex += lineText.indexOf(textToSelect);
- }
- else{
- iOccurenceIndex++;
- int iNewStartIndex = lineText.indexOf(textToSelect) + textToSelect.length();
- iStartIndex += iNewStartIndex;
- lineText = lineText.substring(iNewStartIndex);
- }
- }
- if (!found){
- iRow++;
- }
- }
-
- }
-
- if (found) {
- editor.selectRange(iRow, iStartIndex + selectionOffset, selectionLength);
- }
- else{
- throw new SelectTextInSourcePaneException ("Wrong parameters specified for
method selectTextInSourcePane.\n" +
- "Unable to select required text '" + textToSelect +
- "' within editor with title " + editorTitle + ".\n" +
- "Editor text is: " + editorText);
- }
-
- return editor;
-
- }
}
\ No newline at end of file
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/OpenOnHelper.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/OpenOnHelper.java 2011-06-10
07:55:13 UTC (rev 32002)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/OpenOnHelper.java 2011-06-10
08:25:29 UTC (rev 32003)
@@ -19,7 +19,7 @@
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
-import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.SWTJBTExt;
import org.jboss.tools.ui.bot.ext.Timing;
/**
@@ -46,7 +46,7 @@
SWTBotEditor openedEditor = null;
- SWTBotEclipseEditor sourceEditor = SWTUtilExt.selectTextInSourcePane(bot,
editorTitle, textToSelect,
+ SWTBotEclipseEditor sourceEditor = SWTJBTExt.selectTextInSourcePane(bot, editorTitle,
textToSelect,
selectionOffset, selectionLength, textToSelectIndex);
bot.sleep(Timing.time1S());
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/OpenOnTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/OpenOnTest.java 2011-06-10
07:55:13 UTC (rev 32002)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/smoke/OpenOnTest.java 2011-06-10
08:25:29 UTC (rev 32003)
@@ -10,14 +10,9 @@
******************************************************************************/
package org.jboss.tools.vpe.ui.bot.test.smoke;
-import org.apache.log4j.Logger;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.helper.OpenOnHelper;
-import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.jboss.tools.ui.bot.test.JBTSWTBotTestCase;
import org.jboss.tools.vpe.ui.bot.test.editor.VPEEditorTestCase;
/**
* Test open on functionality
@@ -25,18 +20,9 @@
*
*/
public class OpenOnTest extends VPEEditorTestCase{
- private static Logger log = Logger.getLogger(JBTSWTBotTestCase.class);
public void testOpenOn() throws Throwable{
- try{
- bot.menu(IDELabel.Menu.FILE).menu(IDELabel.Menu.CLOSE_ALL).click();
- log.info("All Editors closed");
- } catch (WidgetNotFoundException wnfe){
- log.info("No Editors to close");
- } catch (TimeoutException te){
- log.info("No Editors to close");
- }
-
-
+
+ eclipse.closeAllEditors();
openPage();
checkOpenOn();