Author: vpakan(a)redhat.com
Date: 2010-05-10 09:17:38 -0400 (Mon, 10 May 2010)
New Revision: 21987
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/DragAndDropHelper.java
Modified:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/META-INF/MANIFEST.MF
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/GuvnorRepositoriesTest.java
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsProject.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ContextMenuHelper.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/EntityType.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java
Log:
Added Guvnor repository Tests.
Modified: trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/META-INF/MANIFEST.MF 2010-05-10
11:56:49 UTC (rev 21986)
+++ trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/META-INF/MANIFEST.MF 2010-05-10
13:17:38 UTC (rev 21987)
@@ -13,7 +13,8 @@
org.junit4;bundle-version="4.5.0",
org.jboss.tools.ui.bot.ext;bundle-version="1.0.0",
org.drools.eclipse;bundle-version="5.1.0",
- org.eclipse.swtbot.eclipse.gef.finder;bundle-version="0.1.0"
+ org.eclipse.swtbot.eclipse.gef.finder;bundle-version="0.1.0",
+ org.apache.log4j;bundle-version="1.2.13"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: JBoss by Red Hat
Modified:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/GuvnorRepositoriesTest.java
===================================================================
---
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/GuvnorRepositoriesTest.java 2010-05-10
11:56:49 UTC (rev 21986)
+++
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/GuvnorRepositoriesTest.java 2010-05-10
13:17:38 UTC (rev 21987)
@@ -11,25 +11,29 @@
package org.jboss.tools.drools.ui.bot.test.smoke;
-import static org.jboss.tools.ui.bot.ext.SWTTestExt.bot;
-
import java.awt.event.KeyEvent;
+import org.apache.log4j.Logger;
+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.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.drools.ui.bot.test.DroolsAllBotTests;
+import org.jboss.tools.ui.bot.ext.config.requirement.PrepareViews;
import org.jboss.tools.ui.bot.ext.config.requirement.RequirementNotFulfilledException;
import org.jboss.tools.ui.bot.ext.config.requirement.StartServer;
import org.jboss.tools.ui.bot.ext.config.requirement.StopServer;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem.View.GeneralInternalWebBrowser;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.helper.DragAndDropHelper;
import org.jboss.tools.ui.bot.ext.helper.KeyboardHelper;
import org.jboss.tools.ui.bot.ext.parts.SWTBotBrowserExt;
+import org.jboss.tools.ui.bot.ext.types.EntityType;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.ui.bot.ext.types.JobName;
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.GuvnorRepositories;
import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
@@ -42,19 +46,26 @@
*
*/
public class GuvnorRepositoriesTest extends SWTTestExt{
+ @SuppressWarnings("unused")
+ private static final Logger log = Logger.getLogger(GuvnorRepositoriesTest.class);
+ private static final String GUVNOR_TEST_FILE = "Dummy rule.drl";
+ private static final String GUVNOR_REPOSITORY_IMPORT_TEST_FILE =
"Underage.brl";
private GuvnorRepositories guvnorRepositories = new GuvnorRepositories();
/**
* Tests Guvnor Repositories
*/
@Test
public void testGuvnorRepositories() {
- //startGuvnor();
+ startGuvnor();
addGuvnorRepository();
deleteGuvnorRepository();
addGuvnorRepository();
openGuvnorConsole();
- browseGuvnorRepository();
- //stopGuvnor();
+ browseGuvnorRepository(GuvnorRepositoriesTest.GUVNOR_TEST_FILE);
+ importFileFromGuvnorRepository(GuvnorRepositoriesTest.GUVNOR_TEST_FILE,
+ DroolsAllBotTests.SAMPLE_DROOLS_RULE_NAME,
+ GuvnorRepositoriesTest.GUVNOR_REPOSITORY_IMPORT_TEST_FILE);
+ stopGuvnor();
}
/**
@@ -114,14 +125,14 @@
KeyboardHelper.releaseKeyCodeUsingAWT(KeyEvent.VK_ENTER);
}
/**
- * Browse Guvnor Repository
+ * Browse Guvnor Repository and open fileToOpenFile
+ * @param fileToOpen
*/
- private void browseGuvnorRepository(){
+ private void browseGuvnorRepository(String fileToOpen){
guvnorRepositories.show();
- String fileToOpen = "Underage.brl";
-
guvnorRepositories.openFile(Timing.time1S(),IDELabel.GuvnorRepositories.GUVNOR_REPOSITORY_ROOT_TREE_ITEM,
+
guvnorRepositories.openFile(Timing.time3S(),IDELabel.GuvnorRepositories.GUVNOR_REPOSITORY_ROOT_TREE_ITEM,
IDELabel.GuvnorRepositories.PACKAGES_TREE_ITEM,
IDELabel.GuvnorRepositories.MORTGAGE_TREE_ITEM,
fileToOpen);
@@ -136,6 +147,7 @@
private void startGuvnor(){
try {
new StartServer().fulfill();
+ new PrepareViews().fulfill();
} catch (RequirementNotFulfilledException e) {
throw new RuntimeException(e);
}
@@ -150,4 +162,170 @@
throw new RuntimeException(e);
}
}
+ /**
+ * Imports file with fileName to Drools project
+ * @param fileName
+ * @param sampleFileName
+ * @param importFileName
+ */
+ private void importFileFromGuvnorRepository(String fileName, String sampleFileName,
String importFileName){
+ eclipse.openPerspective(PerspectiveType.JAVA);
+ guvnorRepositories.show().bot();
+ SWTBotTreeItem tiGuvnorFile =
guvnorRepositories.selectTreeItem(Timing.time3S(),fileName,
+ new String[]{IDELabel.GuvnorRepositories.GUVNOR_REPOSITORY_ROOT_TREE_ITEM,
+ IDELabel.GuvnorRepositories.PACKAGES_TREE_ITEM,
+ IDELabel.GuvnorRepositories.MORTGAGE_TREE_ITEM});
+ tiGuvnorFile.select();
+ SWTBot packageExplorerBot = packageExplorer.show().bot();
+ SWTBotTreeItem tiDroolRuleDir =
packageExplorer.selectTreeItem(DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE,
+ new String[] {DroolsAllBotTests.DROOLS_PROJECT_NAME});
+ DragAndDropHelper.dragAndDropOnTo(tiGuvnorFile.widget,tiDroolRuleDir.widget);
+ bot.sleep(Timing.time5S());
+ SWTBotTree packageExplorerTree = packageExplorerBot.tree();
+ // File is renamed because there is appended Guvnor info to Tree Item Label
+ // So we need to get real label of Tree Item and use it later
+ SWTBotTreeItem tiDroolRuleFile =
SWTEclipseExt.getTreeItemOnPathStartsWith(packageExplorerBot,
+ packageExplorerTree,
+ Timing.time1S(),
+ fileName,
+ new String[]{DroolsAllBotTests.DROOLS_PROJECT_NAME,
+ DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE});
+ SWTBotEditor editor = packageExplorer.openFile(DroolsAllBotTests.DROOLS_PROJECT_NAME,
+ DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE,
+ tiDroolRuleFile.getText());
+
+ assertTrue("File moved from Guvnor Repository to Drools project was not opened
properly. File " + fileName + " is not opened in editor",
+ SWTEclipseExt.existEditorWithLabel(bot,fileName));
+ // Test Update from Guvnor Repository
+ final String changeText = "#$%SWTBot Change#$%";
+ final String originalEditorText = editor.toTextEditor().getText();
+ editor.toTextEditor().insertText(0, 0, changeText);
+ editor.save();
+ bot.sleep(Timing.time1S());
+ ContextMenuHelper.prepareTreeItemForContextMenu(packageExplorerTree,
tiDroolRuleFile);
+ ContextMenuHelper.clickContextMenu(packageExplorerTree,
+ IDELabel.Menu.GUVNOR,IDELabel.Menu.GUVNOR_UPDATE);
+ bot.sleep(Timing.time5S());
+ assertTrue("Update from Guvnor Repository was not successful. File " +
fileName + " has not updated content.",
+ editor.toTextEditor().getText().equals(originalEditorText));
+ // Test commit to Guvnor Repository
+ editor.toTextEditor().insertText(0, 0, changeText);
+ editor.save();
+ bot.sleep(Timing.time1S());
+ ContextMenuHelper.prepareTreeItemForContextMenu(packageExplorerTree,
tiDroolRuleFile);
+ ContextMenuHelper.clickContextMenu(packageExplorerTree,
+ IDELabel.Menu.GUVNOR,IDELabel.Menu.GUVNOR_COMMIT);
+ bot.sleep(Timing.time5S());
+ editor.close();
+ editor =
guvnorRepositories.openFile(Timing.time2S(),IDELabel.GuvnorRepositories.GUVNOR_REPOSITORY_ROOT_TREE_ITEM,
+ IDELabel.GuvnorRepositories.PACKAGES_TREE_ITEM,
+ IDELabel.GuvnorRepositories.MORTGAGE_TREE_ITEM,
+ fileName);
+ assertTrue("Commit to Guvnor Repository was not successful. File " +
fileName + " was not commited properly." +
+ "\nIt has content: " + editor.toTextEditor().getText() +
+ "\nExpected content: " + changeText + originalEditorText,
+ editor.toTextEditor().getText().equals(changeText + originalEditorText));
+ // Test Add To Repository
+ SWTBotTreeItem tiSampleFile = packageExplorer.selectTreeItem(sampleFileName,
+ new String[] {DroolsAllBotTests.DROOLS_PROJECT_NAME,
+ DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE});
+ ContextMenuHelper.prepareTreeItemForContextMenu(packageExplorerTree, tiSampleFile);
+ ContextMenuHelper.clickContextMenu(packageExplorerTree,
+ IDELabel.Menu.GUVNOR,IDELabel.Menu.GUVNOR_ADD);
+ eclipse.waitForShell("");
+ SWTBotShell addToGuvnorShell = packageExplorerBot.activeShell();
+ SWTBot addToGuvnorDialogBot = addToGuvnorShell.bot();
+ addToGuvnorDialogBot.button(IDELabel.Button.NEXT).click();
+ SWTEclipseExt.getTreeItemOnPath(addToGuvnorDialogBot,
+ addToGuvnorDialogBot.tree(),
+ Timing.time3S(),
+ IDELabel.GuvnorRepositories.MORTGAGE_TREE_ITEM,
+ new String[]{IDELabel.GuvnorRepositories.GUVNOR_REPOSITORY_ROOT_TREE_ITEM,
+ IDELabel.GuvnorRepositories.PACKAGES_TREE_ITEM})
+ .select();
+ addToGuvnorDialogBot.button(IDELabel.Button.FINISH).click();
+ eclipse.waitForClosedShell(addToGuvnorShell);
+ boolean isAddedToGuvnorRepository = false;
+ try{
+ guvnorRepositories.selectTreeItem(Timing.time2S(),sampleFileName,
+ new String[]{IDELabel.GuvnorRepositories.GUVNOR_REPOSITORY_ROOT_TREE_ITEM,
+ IDELabel.GuvnorRepositories.PACKAGES_TREE_ITEM,
+ IDELabel.GuvnorRepositories.MORTGAGE_TREE_ITEM});
+ isAddedToGuvnorRepository = true;
+ } catch (WidgetNotFoundException wnfe){
+ isAddedToGuvnorRepository = false;
+ }
+
+ assertTrue("File " + sampleFileName + " was not added to Guvnor
Repository.",
+ isAddedToGuvnorRepository);
+ // Test Deleting from Guvnor Repository file is already selected in Guvnor Repository
Tree
+ packageExplorerBot = packageExplorer.show().bot();
+ packageExplorerTree = packageExplorerBot.tree();
+ packageExplorerBot.sleep(Timing.time2S());
+ ContextMenuHelper.prepareTreeItemForContextMenu(packageExplorerTree, tiSampleFile);
+ ContextMenuHelper.clickContextMenu(packageExplorerTree,
+ IDELabel.Menu.GUVNOR,IDELabel.Menu.GUVNOR_DELETE);
+ SWTBot dialogBot =
packageExplorerBot.shell(IDELabel.Shell.CONFIRM_DELETE).activate().bot();
+ dialogBot.button(IDELabel.Button.OK).click();
+ packageExplorerBot.sleep(Timing.time2S());
+ boolean isRemovedFromGuvnorRepository = false;
+ try{
+ guvnorRepositories.selectTreeItem(Timing.time2S(),sampleFileName,
+ new String[]{IDELabel.GuvnorRepositories.GUVNOR_REPOSITORY_ROOT_TREE_ITEM,
+ IDELabel.GuvnorRepositories.PACKAGES_TREE_ITEM,
+ IDELabel.GuvnorRepositories.MORTGAGE_TREE_ITEM});
+ isRemovedFromGuvnorRepository = false;
+ } catch (WidgetNotFoundException wnfe){
+ isRemovedFromGuvnorRepository = true;
+ }
+ assertTrue("File " + sampleFileName + " was not removed from Guvnor
Repository.",
+ isRemovedFromGuvnorRepository);
+ // Import File From Repository
+ eclipse.createNew(EntityType.RESOURCES_FROM_GUVNOR);
+ bot.button(IDELabel.Button.NEXT).click();
+ SWTEclipseExt.getTreeItemOnPath(
+ bot,
+ bot.tree(),
+ Timing.time3S(),
+ importFileName,
+ new String[] {
+ IDELabel.GuvnorRepositories.GUVNOR_REPOSITORY_ROOT_TREE_ITEM,
+ IDELabel.GuvnorRepositories.PACKAGES_TREE_ITEM,
+ IDELabel.GuvnorRepositories.MORTGAGE_TREE_ITEM }).select();
+ bot.button(IDELabel.Button.NEXT).click();
+ SWTEclipseExt.getTreeItemOnPath(bot,
+ bot.tree(),
+ Timing.time1S(),
+ "rules",
+ new String[]
{DroolsAllBotTests.DROOLS_PROJECT_NAME,"src","main"}).select();
+ bot.button(IDELabel.Button.FINISH).click();
+ util.waitForJobs(Timing.time5S(),JobName.BUILDING_WS);
+ bot.sleep(Timing.time1S());
+ packageExplorerBot = packageExplorer.show().bot();
+ packageExplorerTree = packageExplorerBot.tree();
+ boolean isAddedFromGuvnorRepository = false;
+ SWTBotTreeItem tiImportRuleFile = null;
+ try{
+ tiImportRuleFile = SWTEclipseExt.getTreeItemOnPathStartsWith(packageExplorerBot,
+ packageExplorerTree,
+ Timing.time1S(),
+ importFileName,
+ new String[]{DroolsAllBotTests.DROOLS_PROJECT_NAME,
+ DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE});
+ isAddedFromGuvnorRepository = true;
+ } catch (WidgetNotFoundException wnfe){
+ isAddedFromGuvnorRepository = false;
+ }
+ assertTrue("File " + importFileName + " was not added from Guvnor
Repository.",
+ isAddedFromGuvnorRepository);
+
+ ContextMenuHelper.prepareTreeItemForContextMenu(packageExplorerTree,
tiImportRuleFile);
+ ContextMenuHelper.clickContextMenu(packageExplorerTree,
+ IDELabel.Menu.GUVNOR,IDELabel.Menu.GUVNOR_DISCONNECT);
+ bot.sleep(Timing.time1S());
+ // name of the file has to be without Guvnor information appended to end of file
name
+ // when imported from Guvnor repository
+ assertTrue("File " + importFileName + " was not disconnected from
Guvnor Repository.",
+ tiImportRuleFile.getText().trim().equals(importFileName));
+ }
}
\ No newline at end of file
Modified:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsProject.java
===================================================================
---
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsProject.java 2010-05-10
11:56:49 UTC (rev 21986)
+++
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsProject.java 2010-05-10
13:17:38 UTC (rev 21987)
@@ -73,7 +73,7 @@
}
bot.button(IDELabel.Button.NEXT).click();
bot.button(IDELabel.Button.FINISH).click();
- SWTTestExt.util.waitForAll(20*1000L);
+ SWTTestExt.util.waitForAll(30*1000L);
jbt.delay();
assertTrue("Project "
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2010-05-10
11:56:49 UTC (rev 21986)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2010-05-10
13:17:38 UTC (rev 21987)
@@ -117,7 +117,7 @@
SWTBotMenu menu1 = bot.menu(IDELabel.Menu.WINDOW);
SWTBotMenu menu2 = menu1.menu(IDELabel.Menu.SHOW_VIEW);
menu2.menu(IDELabel.Menu.OTHER).click();
-
+ bot.shell(IDELabel.Shell.SHOW_VIEW).activate();
bot.tree().expandNode(type.getGroupLabel()).expandNode(
type.getViewLabel()).select();
bot.button(IDELabel.Button.OK).click();
@@ -165,12 +165,15 @@
default:
fail("Unknown perspective to open");
}
-
+ bot.sleep(Timing.time1S());
SWTBotMenu menu1 = bot.menu(IDELabel.Menu.WINDOW);
+ bot.sleep(Timing.time1S());
SWTBotMenu menu2 = menu1.menu(IDELabel.Menu.OPEN_PERSPECTIVE);
+ bot.sleep(Timing.time1S());
menu2.menu(IDELabel.Menu.OTHER).click();
+ bot.sleep(Timing.time1S());
bot.table().select(perspectiveLabel);
-
+ bot.sleep(Timing.time1S());
// Another approach
SWTBotShell openPerpectiveShell = bot.shell("Open Perspective");
openPerpectiveShell.activate();
@@ -818,20 +821,23 @@
/**
* Returns Tree Item with specified label and located on path
- *
+ * @param bot
* @param tree
+ * @param timeOut
* @param treeItemText
* @param path
* @return
*/
- public static SWTBotTreeItem getTreeItemOnPath(SWTBotTree tree,
+ public static SWTBotTreeItem getTreeItemOnPath(SWTBot bot,SWTBotTree tree, int timeOut,
String treeItemText, String[] path) {
SWTBotTreeItem parentTreeItem = null;
SWTBotTreeItem treeItem = null;
if (path != null && path.length > 0) {
parentTreeItem = tree.expandNode(path[0]);
+ bot.sleep(timeOut);
for (int index = 1; index < path.length; index++) {
parentTreeItem = parentTreeItem.expandNode(path[index]);
+ bot.sleep(timeOut);
}
treeItem = parentTreeItem.getNode(treeItemText);
} else {
@@ -839,7 +845,41 @@
}
return treeItem;
}
+ /**
+ * Returns first Tree Item with label starting with treeItemTextStartsWith and located
on path
+ * @param bot
+ * @param tree
+ * @param timeOut
+ * @param treeItemTextStartsWith
+ * @param path
+ * @return
+ */
+ public static SWTBotTreeItem getTreeItemOnPathStartsWith(SWTBot bot,SWTBotTree tree, int
timeOut,
+ String treeItemTextStartsWith, String[] path) {
+ SWTBotTreeItem[] items = null;
+ if (path.length > 0){
+ String[] parentPath = new String[path.length - 1];
+ System.arraycopy(path, 0, parentPath, 0, parentPath.length);
+ SWTBotTreeItem parentTreeItem = getTreeItemOnPath(bot, tree, timeOut,
path[path.length - 1], parentPath);
+ parentTreeItem.expand();
+ bot.sleep(timeOut);
+ items = parentTreeItem.getItems();
+ }else{
+ items = tree.getAllItems();
+ }
+ SWTBotTreeItem treeItem = null;
+ for (int index = 0 ; index < items.length && treeItem == null; index++){
+ if (items[index].getText().trim()
+ .startsWith(treeItemTextStartsWith)){
+ treeItem = items[index];
+ }
+ }
+ if (treeItem == null){
+ throw new WidgetNotFoundException("Unable to find Tree Item with label starting
with " + treeItemTextStartsWith);
+ }
+ return treeItem;
+ }
/**
* Choose Run As Java Application menu for specified Tree Item
*
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2010-05-10
11:56:49 UTC (rev 21986)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2010-05-10
13:17:38 UTC (rev 21987)
@@ -41,6 +41,8 @@
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.parts.SWTBotBrowserExt;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.types.JobLists;
@@ -670,6 +672,31 @@
}
}
/**
+ * Displays all tree items of parentTreeItem node
+ * @param tree
+ * @param parentTreeItem
+ */
+ public static void displayAllTreeItemChildren (SWTBotTree tree,SWTBotTreeItem
parentTreeItem){
+ SWTBotTreeItem[] items = parentTreeItem.getItems();
+ if (items != null){
+ for (int index = 0 ; index < items.length ; index++){
+ StringBuffer columnsText = new StringBuffer("");
+ for (int column = 0;column < tree.columnCount(); column++){
+ if (column > 0){
+ columnsText.append(" ");
+ }
+ columnsText.append(column);
+ columnsText.append("[");
+ columnsText.append(items[index].cell(column));
+ columnsText.append("]");
+ }
+ System.out.println("TreeItem text: " + items[index].getText() +
+ " tooltip: " + items[index].getToolTipText() +
+ " columns: " + columnsText.toString());
+ }
+ }
+ }
+ /**
* Returns Toolbar Button of view with specified toolTip
* @param view
* @param toolTip
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ContextMenuHelper.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ContextMenuHelper.java 2010-05-10
11:56:49 UTC (rev 21986)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ContextMenuHelper.java 2010-05-10
13:17:38 UTC (rev 21987)
@@ -19,6 +19,7 @@
import java.util.List;
import java.util.Vector;
+import org.apache.log4j.Logger;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
@@ -40,7 +41,7 @@
*
*/
public class ContextMenuHelper {
-
+ protected static final Logger log = Logger.getLogger(ContextMenuHelper.class);
/**
* Clicks the context menu matching the text.
*
@@ -235,6 +236,7 @@
UIThreadRunnable.asyncExec(menuItem.getDisplay(), new VoidResult() {
public void run() {
+ log.info("Click on menu item: " + menuItem.getText());
menuItem.notifyListeners(SWT.Selection, event);
}
});
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/DragAndDropHelper.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/DragAndDropHelper.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/DragAndDropHelper.java 2010-05-10
13:17:38 UTC (rev 21987)
@@ -0,0 +1,138 @@
+ /*******************************************************************************
+ * Copyright (c) 2007-2010 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ui.bot.ext.helper;
+
+import static org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.syncExec;
+
+import java.awt.AWTException;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+
+import org.apache.log4j.Logger;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.swtbot.swt.finder.results.Result;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+/**
+ * Adds DnD Bot functionality
+ * @author Vladimir Pakan
+ *
+ */
+public class DragAndDropHelper {
+ private static final Logger log = Logger.getLogger(DragAndDropHelper.class);
+ private static Robot robot = null;
+ /**
+ * Drag&Drop sourceWidget on to targetWidget
+ * @param sourceWidget
+ * @param targetWidget
+ */
+ public static void dragAndDropOnTo(Widget sourceWidget, Widget targetWidget){
+ try {
+ if (DragAndDropHelper.robot == null){
+ DragAndDropHelper.robot = new Robot();
+ }
+ DragAndDropHelper.dragAndDropOnTo(calculateWidgetPositionOn(sourceWidget),
+ calculateWidgetPositionOn(targetWidget));
+ } catch (AWTException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Drag&Drop from sourcePoint on to targetPoint
+ * @param sourcePoint
+ * @param targetPoint
+ */
+ private static void dragAndDropOnTo(final Point sourcePoint,final Point targetPoint){
+ try {
+ if (DragAndDropHelper.robot == null){
+ DragAndDropHelper.robot = new Robot();
+ }
+ // the x+10 motion is needed to let native functions register a drag detect. It did
not work under Windows
+ // otherwise and has been reported to be required for linux, too. But I could not
test that.
+ syncExec(new VoidResult() {
+ public void run() {
+ DragAndDropHelper.robot.mouseMove(sourcePoint.x, sourcePoint.y);
+ DragAndDropHelper.robot.mousePress(InputEvent.BUTTON1_MASK);
+ DragAndDropHelper.robot.mouseMove((sourcePoint.x + 10), sourcePoint.y);
+ }
+ });
+ // now pause the test until all runnables on the Display thread have run this is
necessary for the pick up
+ // to register on linux
+ DragAndDropHelper.waitForIdle(DragAndDropHelper.robot);
+
+ syncExec(new VoidResult() {
+ public void run() {
+ DragAndDropHelper.robot.mouseMove((targetPoint.x + 10), targetPoint.y);
+ DragAndDropHelper.robot.mouseMove(targetPoint.x, targetPoint.y);
+ }
+ });
+
+ DragAndDropHelper.waitForIdle(DragAndDropHelper.robot);
+
+ syncExec(new VoidResult() {
+ public void run() {
+ DragAndDropHelper.robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+ });
+ waitForIdle(DragAndDropHelper.robot);
+ } catch (AWTException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ /**
+ * Needed for linux
+ * @param robot
+ */
+ private static void waitForIdle(final Robot robot) {
+ if (SWT.getPlatform().equals("gtk")) {
+ robot.waitForIdle();
+ }
+ }
+ /**
+ * Calculate position of point above widget to be used as mouse click point for DnD
+ * @param widget
+ * @return
+ */
+ private static Point calculateWidgetPositionOn (final Widget widget){
+ Point result = new Point(0,0);
+ final Rectangle sourceLocation = DragAndDropHelper.absoluteLocation(widget);
+ result.x = sourceLocation.x + 10;
+ result.y = sourceLocation.y + 10;
+ return result;
+ }
+ /**
+ * Gets absolute location of widget
+ * @param widget
+ * @return
+ */
+ private static Rectangle absoluteLocation(final Widget widget) {
+ return syncExec(new Result<Rectangle>() {
+ public Rectangle run() {
+ if (widget instanceof TreeItem){
+ return Display.getDefault().map(((TreeItem)widget).getParent(),
+ null,
+ ((TreeItem)widget).getBounds());
+ }
+ else{
+ return Display.getDefault().map(((Control)widget).getParent(),
+ null,
+ ((Control)widget).getBounds());
+ }
+ }
+ });
+ }
+}
Property changes on:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/DragAndDropHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/EntityType.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/EntityType.java 2010-05-10
11:56:49 UTC (rev 21986)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/EntityType.java 2010-05-10
13:17:38 UTC (rev 21987)
@@ -22,7 +22,7 @@
public enum EntityType {
HIBERNATE_MAPPING_FILE, JAVA_PROJECT, JAVA_CLASS, HIBERNATE_REVERSE_FILE,
HIBERNATE_CONSOLE,
HIBERNATE_CONFIGURATION_FILE, STRUTS_PROJECT, JPA_PROJECT, DROOLS_PROJECT, DROOLS_RULE,
- GUIDED_DROOLS_RULE,DSL_DROOLS_FILE;
+ GUIDED_DROOLS_RULE,DSL_DROOLS_FILE,RESOURCES_FROM_GUVNOR;
public List<String> getGroupsLabels() {
List<String> groupLabel = new LinkedList<String>();
@@ -40,6 +40,7 @@
case DROOLS_RULE: groupLabel.add(IDELabel.EntityGroup.DROOLS);break;
case GUIDED_DROOLS_RULE: groupLabel.add(IDELabel.EntityGroup.DROOLS);break;
case DSL_DROOLS_FILE: groupLabel.add(IDELabel.EntityGroup.DROOLS);break;
+ case RESOURCES_FROM_GUVNOR: groupLabel.add(IDELabel.EntityGroup.GUVNOR);break;
default: fail("Unknown Entity Type");
}
@@ -66,6 +67,7 @@
case DROOLS_RULE: entityLabel = IDELabel.EntityLabel.DROOLS_RULE; break;
case GUIDED_DROOLS_RULE: entityLabel = IDELabel.EntityLabel.GUIDED_DROOLS_RULE;
break;
case DSL_DROOLS_FILE: entityLabel = IDELabel.EntityLabel.DSL_DROOLS_FILE; break;
+ case RESOURCES_FROM_GUVNOR: entityLabel = IDELabel.EntityLabel.RESOURCES_FROM_GUVNOR;
break;
default: fail("Unknown Entity Type");
}
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-05-10
11:56:49 UTC (rev 21986)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-05-10
13:17:38 UTC (rev 21987)
@@ -66,6 +66,12 @@
public static final String DEBUG_AS = "Debug As";
public static final String DEBUG_AS_DROOLS_APPLICATION = "Drools
Application";
public static final String OPEN_GUVNOR_CONSOLE = "Open Guvnor Console";
+ public static final String GUVNOR = "Guvnor";
+ public static final String GUVNOR_UPDATE = "Update";
+ public static final String GUVNOR_COMMIT = "Commit";
+ public static final String GUVNOR_ADD = "Add...";
+ public static final String GUVNOR_DELETE = "Delete...";
+ public static final String GUVNOR_DISCONNECT = "Disconnect";
}
public class Button {
@@ -119,7 +125,9 @@
public static final String RENAME_JAVA_PROJECT = "Rename Java Project";
public static final String CONFIRM_PERSPECTIVE_SWITCH = "Confirm Perspective
Switch";
public static final String NEW_SEAM_RUNTIME = "New Seam Runtime";
- public static final String NEW_ESB_RUNTIME = "New JBoss ESB Runtime";
+ public static final String NEW_ESB_RUNTIME = "New JBoss ESB Runtime";
+ public static final String CONFIRM_DELETE = "Confirm Delete";
+ public static final String SHOW_VIEW = "Show View";
}
public class EntityGroup {
@@ -130,6 +138,7 @@
public static final String JBOSS_TOOLS_WEB = "JBoss Tools Web";
public static final String JPA = "JPA";
public static final String DROOLS = "Drools";
+ public static final String GUVNOR = "Guvnor";
}
public class EntityLabel {
@@ -146,6 +155,7 @@
public static final String DROOLS_RULE = "Rule Resource";
public static final String GUIDED_DROOLS_RULE = "Guided Rule";
public static final String DSL_DROOLS_FILE = "Domain Specific Language";
+ public static final String RESOURCES_FROM_GUVNOR = "Resources from Guvnor";
}
public class JavaProjectWizard {
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java 2010-05-10
11:56:49 UTC (rev 21986)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java 2010-05-10
13:17:38 UTC (rev 21987)
@@ -33,19 +33,33 @@
public void selectProject(String projectName) {
SWTBot viewBot = viewByTitle(viewObject.getName()).bot();
viewBot.tree().expandNode(projectName).select();
- }
- /**
- * Selects Tree Item within Package Explorer
- * @param treeItemText
- * @param path
- * @return
- */
- public SWTBotTreeItem selectTreeItem(String treeItemText, String[] path) {
- show();
- return
SWTEclipseExt.getTreeItemOnPath(viewByTitle(viewObject.getName()).bot().tree(),
- treeItemText, path)
- .select();
- }
+ }
+
+ /**
+ * Selects Tree Item within Package Explorer
+ *
+ * @param timeOut
+ * @param treeItemText
+ * @param path
+ * @return
+ */
+ public SWTBotTreeItem selectTreeItem(int timeOut, String treeItemText,
+ String[] path) {
+ SWTBot viewBot = show().bot();
+ return SWTEclipseExt.getTreeItemOnPath(viewBot, viewBot.tree(), timeOut,
+ treeItemText, path).select();
+ }
+ /**
+ * Selects Tree Item within Package Explorer
+ *
+ * @param treeItemText
+ * @param path
+ * @return
+ */
+ public SWTBotTreeItem selectTreeItem(String treeItemText,
+ String[] path) {
+ return selectTreeItem(0,treeItemText,path);
+ }
/**
* deletes given project from workspace
* @param projectName