Author: jpeterka
Date: 2010-01-26 10:31:05 -0500 (Tue, 26 Jan 2010)
New Revision: 19932
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/META-INF/MANIFEST.MF
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CodeGenerationLauncherTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConfigurationFileTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingFileTest.java
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateAllTests.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTBotExt.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/SWTJBTExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java
Log:
Fixed minor bot issues of SWTBotExt and HibernateTest
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/META-INF/MANIFEST.MF 2010-01-26
14:47:50 UTC (rev 19931)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/META-INF/MANIFEST.MF 2010-01-26
15:31:05 UTC (rev 19932)
@@ -18,7 +18,6 @@
org.eclipse.swtbot.swt.finder;bundle-version="2.0.0",
org.jboss.tools.ui.bot.ext;bundle-version="1.0.0",
org.eclipse.jdt.ui,
- org.jboss.tools.jst.ui.bot.test;bundle-version="1.0.0",
org.jboss.tools.hibernate.ui;bundle-version="3.3.0",
org.jboss.tools.hibernate.xml.ui;bundle-version="3.1.0",
org.jboss.tools.common.model.ui;bundle-version="3.1.0",
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CodeGenerationLauncherTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CodeGenerationLauncherTest.java 2010-01-26
14:47:50 UTC (rev 19931)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/CodeGenerationLauncherTest.java 2010-01-26
15:31:05 UTC (rev 19932)
@@ -43,6 +43,7 @@
prepareProject();
prepareConsole();
prepareDatabase();
+ util.waitForNonIgnoredJobs();
}
/**
@@ -53,8 +54,10 @@
if (generationDone) return;
log.info("HB Code Generation STARTED");
+ log.info("Active Shell: " + bot.activeShell().getText());
+
eclipse.openPerspective(PerspectiveType.HIBERNATE);
-
+
createNewHibernateCodeGenerationConfiguration();
fillMainTab();
@@ -66,8 +69,10 @@
log.info("HB Code Generation FINISHED");
util.waitForNonIgnoredJobs();
+ log.info("Active Shell: " + bot.activeShell().getText());
+
checkGeneratedFiles();
-
+
generationDone = true;
}
/**
@@ -75,6 +80,13 @@
*/
private void checkGeneratedFiles() {
+ log.info("Active Shell: " + bot.activeShell().getText());
+ SWTBotShell[] shells = bot.shells();
+ for (SWTBotShell shell : shells) {
+ log.info("Possible shell: " + shell.getText());
+ }
+
+ bot.sleep(TIME_20S);
SWTBot viewBot = eclipse.showView(ViewType.PROJECT_EXPLORER);
SWTBotTreeItem item;
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConfigurationFileTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConfigurationFileTest.java 2010-01-26
14:47:50 UTC (rev 19931)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConfigurationFileTest.java 2010-01-26
15:31:05 UTC (rev 19932)
@@ -78,9 +78,11 @@
if (!cb.isChecked())
cb.click();
- SWTBotShell shell = bot.activeShell();
+ SWTBotShell shell = bot.activeShell();
+ log.info("Active shell:" + shell.getText());
bot.button(IDELabel.Button.FINISH).click();
- eclipse.waitForClosedShell(shell);
+ eclipse.waitForClosedShell(shell);
+ log.info("Active Shell: " + bot.activeShell().getText());
}
/**
@@ -96,8 +98,7 @@
*/
public void editFile() throws ParserConfigurationException, SAXException, IOException,
XPathExpressionException {
- eclipse.openFile(Project.PROJECT_NAME, "src", Project.CONF_FILE_NAME2);
- SWTBotEditor editor = bot.editorByTitle(Project.CONF_FILE_NAME2);
+ SWTBotEditor editor = eclipse.openFile(Project.PROJECT_NAME, "src",
Project.CONF_FILE_NAME2);
ObjectMultiPageEditorBot multiBot = new
ObjectMultiPageEditorBot(Project.CONF_FILE_NAME2);
// 1. Tabs availability
@@ -177,7 +178,6 @@
editor.saveAndClose();
assertTrue("Security element not found in xml", found);
- bot.sleep(TIME_10S);
}
}
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java 2010-01-26
14:47:50 UTC (rev 19931)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/ConsoleTest.java 2010-01-26
15:31:05 UTC (rev 19932)
@@ -59,6 +59,7 @@
createCommonTab();
bot.button(IDELabel.Button.FINISH).click();
+ util.waitForNonIgnoredJobs();
log.info("HB Console creation FINISHED");
done = true;
@@ -84,6 +85,7 @@
SWTBotShell shell = bot.activeShell();
bot.button(IDELabel.Button.FINISH).click();
eclipse.waitForClosedShell(shell);
+
log.info("HB Console Main tab DONE");
bot.sleep(TIME_1S);
}
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingFileTest.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingFileTest.java 2010-01-26
14:47:50 UTC (rev 19931)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testcase/MappingFileTest.java 2010-01-26
15:31:05 UTC (rev 19932)
@@ -17,8 +17,8 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.hibernate.ui.bot.testsuite.HibernateTest;
import org.jboss.tools.hibernate.ui.bot.testsuite.Project;
+import org.jboss.tools.ui.bot.ext.parts.ObjectMultiPageEditorBot;
import org.jboss.tools.ui.bot.ext.parts.SWTBotEditorExt;
-import org.jboss.tools.ui.bot.ext.parts.ObjectMultiPageEditorBot;
import org.jboss.tools.ui.bot.ext.types.EntityType;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.junit.AfterClass;
@@ -70,7 +70,7 @@
// Create mapping files
eclipse.createNew(EntityType.HIBERNATE_MAPPING_FILE);
- eclipse.waitForShell(IDELabel.Shell.NEW_HIBERNATE_MAPPING_FILE);
+
bot.button(IDELabel.Button.NEXT).click();
bot.button(IDELabel.Button.FINISH).click();
util.waitForNonIgnoredJobs();
@@ -86,12 +86,13 @@
private void createFilesFromPackage() {
// Select Package file
SWTBot viewBot = bot.viewByTitle(IDELabel.View.PACKAGE_EXPLORER).bot();
+ bot.viewByTitle(IDELabel.View.PACKAGE_EXPLORER).show();
+ bot.viewByTitle(IDELabel.View.PACKAGE_EXPLORER).setFocus();
SWTBotTreeItem item =
viewBot.tree().expandNode(Project.PROJECT_NAME).expandNode("src");
item = item.expandNode(Project.PACKAGE_NAME).select();
// Create mapping files
eclipse.createNew(EntityType.HIBERNATE_MAPPING_FILE);
- eclipse.waitForShell(IDELabel.Shell.NEW_HIBERNATE_MAPPING_FILE);
bot.button(IDELabel.Button.FINISH).click();
util.waitForNonIgnoredJobs();
Modified:
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateAllTests.java
===================================================================
---
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateAllTests.java 2010-01-26
14:47:50 UTC (rev 19931)
+++
trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hibernate/ui/bot/testsuite/HibernateAllTests.java 2010-01-26
15:31:05 UTC (rev 19932)
@@ -33,10 +33,10 @@
MappingsDiagramTest.class,
ReverseEngineerFileTest.class, ViewsTest.class */
-@SuiteClasses( { ConfigurationFileTest.class,
- ConsoleTest.class,
+@SuiteClasses( { ConfigurationFileTest.class,
MappingFileTest.class,
- CodeGenerationLauncherTest.class})
+ CodeGenerationLauncherTest.class,
+ ConsoleTest.class})
public class HibernateAllTests extends HibernateTest {
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTBotExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTBotExt.java 2010-01-26
14:47:50 UTC (rev 19931)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTBotExt.java 2010-01-26
15:31:05 UTC (rev 19932)
@@ -36,7 +36,7 @@
log.error(msg);
fail(msg);
}
-
+
// ------------------------------------------------------------
// SWTBot method wrapper ( for better logging mainly )
// ------------------------------------------------------------
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-01-26
14:47:50 UTC (rev 19931)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2010-01-26
15:31:05 UTC (rev 19932)
@@ -1,13 +1,13 @@
- /*******************************************************************************
- * Copyright (c) 2007-2009 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
- ******************************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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;
@@ -23,8 +23,10 @@
import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
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.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.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
@@ -40,32 +42,34 @@
/**
* Provides Eclipse common operation based on SWTBot element operations
+ *
* @author jpeterka
- *
+ *
*/
public class SWTEclipseExt {
- private SWTWorkbenchBot bot;
- private SWTUtilExt swtUtilExt;
- private Logger log = Logger.getLogger(SWTEclipseExt.class);
-
+ private SWTUtilExt util;
+ private SWTBotExt bot;
+ // private SWTUtilExt swtUtilExt;
+ private Logger log = Logger.getLogger(SWTEclipseExt.class);
+
public SWTWorkbenchBot getBot() {
- return bot;
- }
+ return bot;
+ }
- public SWTUtilExt getSwtUtilExt() {
- return swtUtilExt;
- }
+ public Logger getLog() {
+ return log;
+ }
- public Logger getLog() {
- return log;
- }
-
- public SWTEclipseExt(SWTWorkbenchBot bot) {
+ public SWTEclipseExt(SWTBotExt bot) {
this.bot = bot;
- swtUtilExt = new SWTUtilExt(bot);
+ this.util = new SWTUtilExt(bot);
}
-
+ public SWTEclipseExt() {
+ this.bot = new SWTBotExt();
+ this.util = new SWTUtilExt(bot);
+ }
+
// ------------------------------------------------------------
// View related methods
// ------------------------------------------------------------
@@ -81,15 +85,19 @@
*
* @param type
*/
- public SWTBot showView(ViewType type) {
- bot.menu(IDELabel.Menu.WINDOW).menu(IDELabel.Menu.SHOW_VIEW).menu(
- IDELabel.Menu.OTHER).click();
- bot.tree().expandNode(type.getGroupLabel()).expandNode(type.getViewLabel()).select();
+ public SWTBot showView(ViewType type) {
+ SWTBotMenu menu1 = bot.menu(IDELabel.Menu.WINDOW);
+ SWTBotMenu menu2 = menu1.menu(IDELabel.Menu.SHOW_VIEW);
+ menu2.menu(IDELabel.Menu.OTHER).click();
+
+ bot.tree().expandNode(type.getGroupLabel()).expandNode(
+ type.getViewLabel()).select();
bot.button(IDELabel.Button.OK).click();
-
+
SWTBot viewBot = bot.viewByTitle(type.getViewLabel()).bot();
- return viewBot;
+ return viewBot;
}
+
// ------------------------------------------------------------
// Perspective related methods
// ------------------------------------------------------------
@@ -102,30 +110,43 @@
String perspectiveLabel = "";
switch (type) {
- case JAVA: perspectiveLabel = IDELabel.SelectPerspectiveDialog.JAVA; break;
- case HIBERNATE: perspectiveLabel = IDELabel.SelectPerspectiveDialog.HIBERNATE;break;
- case SEAM: perspectiveLabel = IDELabel.SelectPerspectiveDialog.SEAM;break;
- case WEB_DEVELOPMENT:perspectiveLabel =
IDELabel.SelectPerspectiveDialog.WEB_DEVELOPMENT; break;
- case DB_DEVELOPMENT: perspectiveLabel =
IDELabel.SelectPerspectiveDialog.DB_DEVELOPMENT; break;
- default: fail("Unknown perspective to open");
+ case JAVA:
+ perspectiveLabel = IDELabel.SelectPerspectiveDialog.JAVA;
+ break;
+ case HIBERNATE:
+ perspectiveLabel = IDELabel.SelectPerspectiveDialog.HIBERNATE;
+ break;
+ case SEAM:
+ perspectiveLabel = IDELabel.SelectPerspectiveDialog.SEAM;
+ break;
+ case WEB_DEVELOPMENT:
+ perspectiveLabel = IDELabel.SelectPerspectiveDialog.WEB_DEVELOPMENT;
+ break;
+ case DB_DEVELOPMENT:
+ perspectiveLabel = IDELabel.SelectPerspectiveDialog.DB_DEVELOPMENT;
+ break;
+ default:
+ fail("Unknown perspective to open");
}
-
- bot.menu(IDELabel.Menu.WINDOW).menu(IDELabel.Menu.OPEN_PERSPECTIVE).menu(
- IDELabel.Menu.OTHER).click();
+
+ SWTBotMenu menu1 = bot.menu(IDELabel.Menu.WINDOW);
+ SWTBotMenu menu2 = menu1.menu(IDELabel.Menu.OPEN_PERSPECTIVE);
+ menu2.menu(IDELabel.Menu.OTHER).click();
bot.table().select(perspectiveLabel);
// Another approach
- SWTBotShell openPerpectiveShell = bot.shell("Open Perspective");
- openPerpectiveShell.activate();
+ SWTBotShell openPerpectiveShell = bot.shell("Open Perspective");
+ openPerpectiveShell.activate();
bot.button(IDELabel.Button.OK).click();
}
// ------------------------------------------------------------
// Create related methods
- // ------------------------------------------------------------
+ // ------------------------------------------------------------
/**
* Create Java Project desribed with propriate entity
+ *
* @param entity
*/
public void createJavaProject(JavaProjectEntity entity) {
@@ -140,30 +161,34 @@
// Wait for shell closing JavaProjectWizard
waitForClosedShell(IDELabel.Shell.NEW_JAVA_PROJECT);
- swtUtilExt.waitForNonIgnoredJobs();
+ util.waitForNonIgnoredJobs();
}
-
+
// ------------------------------------------------------------
// Create related methods
- // ------------------------------------------------------------
+ // ------------------------------------------------------------
/**
* Create new Java Class described with JavaClassEntity
+ *
* @param entity
*/
public void createJavaClass(JavaClassEntity entity) {
createNew(EntityType.JAVA_CLASS);
waitForShell(IDELabel.Shell.NEW_JAVA_CLASS);
-
- bot.textWithLabel(IDELabel.NewClassCreationWizard.PACKAGE_NAME).setText(entity.getPackageName());
- bot.textWithLabel(IDELabel.NewClassCreationWizard.CLASS_NAME).setText(entity.getClassName());
+
+ bot.textWithLabel(IDELabel.NewClassCreationWizard.PACKAGE_NAME)
+ .setText(entity.getPackageName());
+ bot.textWithLabel(IDELabel.NewClassCreationWizard.CLASS_NAME).setText(
+ entity.getClassName());
bot.button(IDELabel.Button.FINISH).click();
-
+
waitForClosedShell(IDELabel.Shell.NEW_JAVA_CLASS);
- swtUtilExt.waitForNonIgnoredJobs();
+ util.waitForNonIgnoredJobs();
}
-
+
/**
* Remove entity from package explorer
+ *
* @param projectName
* @param path
*/
@@ -172,110 +197,123 @@
SWTBot viewBot = bot.viewByTitle(IDELabel.View.PACKAGE_EXPLORER).bot();
SWTBotTreeItem item = viewBot.tree().expandNode(projectName);
- // Go through path
- for ( String nodeName: path ) {
+ // Go through path
+ for (String nodeName : path) {
item = item.expandNode(nodeName);
}
// Delete File
- item.select().contextMenu("Delete").click();
- bot.button(IDELabel.Button.OK).click();
+ item.select().contextMenu("Delete").click();
+ bot.button(IDELabel.Button.OK).click();
}
-
/**
* Open File in Package Explorer
+ *
* @param projectName
* @param path
*/
- public void openFile(String projectName, String... path) {
+ public SWTBotEditor openFile(String projectName, String... path) {
SWTBot viewBot = bot.viewByTitle(IDELabel.View.PACKAGE_EXPLORER).bot();
- SWTBotTreeItem item = viewBot.tree().expandNode(projectName);
+ bot.viewByTitle(IDELabel.View.PACKAGE_EXPLORER).show();
+ bot.viewByTitle(IDELabel.View.PACKAGE_EXPLORER).setFocus();
+ SWTBotTree tree = viewBot.tree();
+ SWTBotTreeItem item = tree.expandNode(projectName);
StringBuilder builder = new StringBuilder(projectName);
-
- // Go through path
- for ( String nodeName: path ) {
+
+ // Go through path
+ for (String nodeName : path) {
item = item.expandNode(nodeName);
builder.append("/" + nodeName);
}
-
+
item.select().doubleClick();
log.info("File Opened:" + builder.toString());
+
+ SWTBotEditor editor = bot.activeEditor();
+ return editor;
}
-
+
// ------------------------------------------------------------
// Navigation related
- // ------------------------------------------------------------
+ // ------------------------------------------------------------
/**
* Select element in tree
- * @return
+ *
+ * @return
*/
- public SWTBotTreeItem selectTreeLocation(String... path) {
+ public SWTBotTreeItem selectTreeLocation(String... path) {
return selectTreeLocation(bot, path);
- }
+ }
+
/**
* Select element in tree with given bot
- * @return
- */
+ *
+ * @return
+ */
public SWTBotTreeItem selectTreeLocation(SWTBot bot, String... path) {
SWTBot viewBot = bot;
-
- SWTBotTreeItem item = null;
- // Go through path
- for ( String nodeName: path ) {
- if ( item == null ) {
+
+ SWTBotTreeItem item = null;
+ // Go through path
+ for (String nodeName : path) {
+ if (item == null) {
item = viewBot.tree().expandNode(nodeName);
} else {
- item = item.expandNode(nodeName);
+ item = item.expandNode(nodeName);
}
- log.info(nodeName);
+ log.info(nodeName);
}
return item.select();
}
-
+
// ------------------------------------------------------------
// Subroutines
// ------------------------------------------------------------
/**
- * Invoke Create new entity dialog (it means File -> New -> EntityType -> Next
)
+ * Invoke Create new entity dialog (it means File -> New -> EntityType ->
+ * Next )
*/
public void createNew(EntityType entityType) {
-
- bot.menu(IDELabel.Menu.FILE).menu(IDELabel.Menu.NEW).menu(IDELabel.Menu.OTHER).click();
+
+ bot.menu(IDELabel.Menu.FILE).menu(IDELabel.Menu.NEW).menu(
+ IDELabel.Menu.OTHER).click();
waitForShell(IDELabel.Shell.NEW);
String entityLabel = entityType.getEntityLabel();
SWTBotTree tree = bot.tree();
- Iterator<String> itGroupsNodes = entityType.getGroupsLabels().iterator();
+ Iterator<String> itGroupsNodes = entityType.getGroupsLabels()
+ .iterator();
// if there are group labels defined expand groups nodes
- if (itGroupsNodes.hasNext()){
- SWTBotTreeItem groupTreeItem = tree.expandNode(itGroupsNodes.next());
- while (itGroupsNodes.hasNext()){
- groupTreeItem = groupTreeItem.expandNode(itGroupsNodes.next());
- }
- groupTreeItem.select(entityLabel);
+ if (itGroupsNodes.hasNext()) {
+ SWTBotTreeItem groupTreeItem = tree
+ .expandNode(itGroupsNodes.next());
+ while (itGroupsNodes.hasNext()) {
+ groupTreeItem = groupTreeItem.expandNode(itGroupsNodes.next());
+ }
+ groupTreeItem.select(entityLabel);
+ } else {
+ tree.select(entityLabel);
}
- else{
- tree.select(entityLabel);
- }
bot.button(IDELabel.Button.NEXT).click();
}
-
+
/**
* Wait for appearance shell of given name
+ *
* @param shellName
*/
- public void waitForShell(String shellName) {
- Matcher<Shell> matcher = WidgetMatcherFactory
- .withText(shellName);
+ public void waitForShell(String shellName) {
+ Matcher<Shell> matcher = WidgetMatcherFactory.withText(shellName);
bot.waitUntil(Conditions.waitForShell(matcher));
-
+
}
-
+
/**
* Waits for closed shell with shell name
+ *
* @param shellName
*/
public void waitForClosedShell(String shellName) {
@@ -288,141 +326,166 @@
log.info("Waiting for closing shell...");
}
}
-
+
/**
- * Assert same content of file in project explorer with content of file in resources
+ * Assert same content of file in project explorer with content of file in
+ * resources
+ *
* @param pluginId
* @param projectName
* @param path
*/
- public void assertSameContent(String pluginId, String projectName, String... path) {
- File file = swtUtilExt.getResourceFile(pluginId, path);
- String resourceContent = swtUtilExt.readTextFile(file);
-
+ public void assertSameContent(String pluginId, String projectName,
+ String... path) {
+ File file = util.getResourceFile(pluginId, path);
+ String resourceContent = SWTTestExt.util.readTextFile(file);
+
openAsText(projectName, path);
- SWTBotEclipseEditor editor = bot.editorByTitle(path[path.length - 1]).toTextEditor();
+ SWTBotEclipseEditor editor = bot.editorByTitle(path[path.length - 1])
+ .toTextEditor();
String fileContent = editor.getText();
-
- assertEquals(resourceContent, fileContent );
+
+ assertEquals(resourceContent, fileContent);
}
-
+
/**
* Open file from Package Explorer as text
+ *
* @param projectName
* @param path
*/
public void openAsText(String projectName, String... path) {
SWTBot viewBot = bot.viewByTitle(IDELabel.View.PACKAGE_EXPLORER).bot();
SWTBotTreeItem item = viewBot.tree().expandNode(projectName);
-
- // Go through path
- for ( String nodeName: path ) {
+
+ // Go through path
+ for (String nodeName : path) {
log.info(nodeName);
item = item.expandNode(nodeName);
- }
-
- item.select();
+ }
+
+ item.select();
}
/**
* Replace class content from content of class from resource
+ *
* @param pluginId
* @param path
*/
- public void setClassContentFromResource(boolean save, String pluginId, String... path)
{
+ public void setClassContentFromResource(boolean save, String pluginId,
+ String... path) {
SWTBotEclipseEditor editor;
editor = bot.editorByTitle(path[path.length - 1]).toTextEditor();
editor.selectRange(0, 0, editor.getLineCount());
- File file = swtUtilExt.getResourceFile(pluginId, path);
- String content = swtUtilExt.readTextFile(file);
+ File file = util.getResourceFile(pluginId, path);
+ String content = util.readTextFile(file);
editor.setText(content);
if (save)
- editor.save();
+ editor.save();
}
- /**
- * Define new Server Runtime only if it's not specified yet
- * @param runtimeName
- * @param runtimeGroup
- * @param runtimeType
- * @param runtimeHomeDir
- */
- public void addServerRuntime (String runtimeName, String runtimeGroup,
- String runtimeType, String runtimeHomeDir){
-
- bot.menu(IDELabel.Menu.WINDOW).menu(IDELabel.Menu.PREFERENCES).click();
- bot.shell(IDELabel.Shell.PREFERENCES).activate();
- bot.tree().expandNode(IDELabel.PreferencesDialog.SERVER_GROUP)
- .select(PreferencesDialog.RUNTIME_ENVIRONMENTS);
- SWTBotTable tbRuntimeEnvironments = bot.table();
- boolean createRuntime = true;
- // first check if Environment doesn't exist
- int numRows = tbRuntimeEnvironments.rowCount();
- if (numRows > 0){
- int currentRow = 0;
- while (createRuntime && currentRow < numRows){
- if (tbRuntimeEnvironments.cell(currentRow, 0).equalsIgnoreCase(runtimeName)){
- createRuntime = false;
- }
- else {
- currentRow++;
- }
- }
- }
- // create Server Runtime
- if (createRuntime){
- bot.button(IDELabel.Button.ADD).click();
- bot.shell(IDELabel.Shell.NEW_SERVER_RUNTIME_ENVIRONMENT).activate();
- bot.tree().expandNode(runtimeGroup).select(runtimeType);
- bot.button("Next >").click();
- bot.textWithLabel(IDELabel.JBossServerRuntimeDialog.NAME).setText(runtimeName);
-
bot.textWithLabel(IDELabel.JBossServerRuntimeDialog.HOME_DIRECTORY).setText(runtimeHomeDir);
- bot.button(IDELabel.Button.FINISH).click();
- }
- bot.button(IDELabel.Button.OK).click();
+
+ /**
+ * Define new Server Runtime only if it's not specified yet
+ *
+ * @param runtimeName
+ * @param runtimeGroup
+ * @param runtimeType
+ * @param runtimeHomeDir
+ */
+ public void addServerRuntime(String runtimeName, String runtimeGroup,
+ String runtimeType, String runtimeHomeDir) {
+
+ bot.menu(IDELabel.Menu.WINDOW).menu(IDELabel.Menu.PREFERENCES).click();
+ bot.shell(IDELabel.Shell.PREFERENCES).activate();
+ bot.tree().expandNode(IDELabel.PreferencesDialog.SERVER_GROUP).select(
+ PreferencesDialog.RUNTIME_ENVIRONMENTS);
+ SWTBotTable tbRuntimeEnvironments = bot.table();
+ boolean createRuntime = true;
+ // first check if Environment doesn't exist
+ int numRows = tbRuntimeEnvironments.rowCount();
+ if (numRows > 0) {
+ int currentRow = 0;
+ while (createRuntime && currentRow < numRows) {
+ if (tbRuntimeEnvironments.cell(currentRow, 0).equalsIgnoreCase(
+ runtimeName)) {
+ createRuntime = false;
+ } else {
+ currentRow++;
+ }
+ }
+ }
+ // create Server Runtime
+ if (createRuntime) {
+ bot.button(IDELabel.Button.ADD).click();
+ bot.shell(IDELabel.Shell.NEW_SERVER_RUNTIME_ENVIRONMENT).activate();
+ bot.tree().expandNode(runtimeGroup).select(runtimeType);
+ bot.button("Next >").click();
+ bot.textWithLabel(IDELabel.JBossServerRuntimeDialog.NAME).setText(
+ runtimeName);
+ bot.textWithLabel(IDELabel.JBossServerRuntimeDialog.HOME_DIRECTORY)
+ .setText(runtimeHomeDir);
+ bot.button(IDELabel.Button.FINISH).click();
+ }
+ bot.button(IDELabel.Button.OK).click();
}
+
/**
* Test if tree contains item with itemLabel
+ *
* @param tree
* @param itemLabel
* @return
*/
- public static boolean treeContainsItemWithLabel(SWTBotTree tree, String itemLabel){
- boolean containsItem = false;
- try {
- tree.getTreeItem(itemLabel);
- containsItem = true;
- } catch (WidgetNotFoundException e) {
- }
- return containsItem;
+ public static boolean treeContainsItemWithLabel(SWTBotTree tree,
+ String itemLabel) {
+ boolean containsItem = false;
+ try {
+ tree.getTreeItem(itemLabel);
+ containsItem = true;
+ } catch (WidgetNotFoundException e) {
+ }
+ return containsItem;
}
+
/**
- * if Open Associated Perspective Shell is opened close it
- * and depend on switchPerspective parameter change current perspective
+ * if Open Associated Perspective Shell is opened close it and depend on
+ * switchPerspective parameter change current perspective
+ *
* @param switchPerspective
*/
- public void closeOpenAssociatedPerspectiveShellIfOpened(boolean switchPerspective){
- try{
- bot.shell(IDELabel.Shell.OPEN_ASSOCIATED_PERSPECTIVE).activate();
- bot.button(switchPerspective ? IDELabel.Button.YES : IDELabel.Button.NO).click();
- } catch (WidgetNotFoundException wnfe){
- // do nothing
- }
+ public void closeOpenAssociatedPerspectiveShellIfOpened(
+ boolean switchPerspective) {
+ try {
+ bot.shell(IDELabel.Shell.OPEN_ASSOCIATED_PERSPECTIVE).activate();
+ bot.button(
+ switchPerspective ? IDELabel.Button.YES
+ : IDELabel.Button.NO).click();
+ } catch (WidgetNotFoundException wnfe) {
+ // do nothing
+ }
}
+
/**
- * Close Warning Window if is opened.
- * Press Continue or Cancel button dependent on pressContinueButton
+ * Close Warning Window if is opened. Press Continue or Cancel button
+ * dependent on pressContinueButton
+ *
* @param pressContinueButton
*/
- public void closeWarningWindowIfOpened(boolean pressContinueButton){
- try{
- bot.shell(IDELabel.Shell.WARNING).activate();
- bot.button(pressContinueButton ? IDELabel.Button.CONTINUE :
IDELabel.Button.CANCEL).click();
- } catch (WidgetNotFoundException wnfe){
- // do nothing
- }
- }
- public static void closeWarningWindowIfOpened(SWTWorkbenchBot bot, boolean
pressContinueButton){
- closeWarningWindowIfOpened(bot, pressContinueButton);
+ public void closeWarningWindowIfOpened(boolean pressContinueButton) {
+ try {
+ bot.shell(IDELabel.Shell.WARNING).activate();
+ bot.button(
+ pressContinueButton ? IDELabel.Button.CONTINUE
+ : IDELabel.Button.CANCEL).click();
+ } catch (WidgetNotFoundException wnfe) {
+ // do nothing
+ }
}
-
+
+ public static void closeWarningWindowIfOpened(SWTWorkbenchBot bot,
+ boolean pressContinueButton) {
+ closeWarningWindowIfOpened(bot, pressContinueButton);
+ }
+
}
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java 2010-01-26
14:47:50 UTC (rev 19931)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java 2010-01-26
15:31:05 UTC (rev 19932)
@@ -33,7 +33,7 @@
*/
public class SWTJBTExt {
- SWTWorkbenchBot bot;
+ SWTWorkbenchBot bot;
Logger log = Logger.getLogger(SWTJBTExt.class);
public SWTJBTExt(SWTWorkbenchBot bot) {
@@ -128,7 +128,7 @@
* @param timeOut
*/
public static void chooseServerPopupMenu(SWTWorkbenchBot bot , int index, String
menuLabel, long timeOut){
- SWTEclipseExt swtEclipseExt = new SWTEclipseExt(bot);
+ SWTEclipseExt swtEclipseExt = new SWTEclipseExt();
SWTBot servers = swtEclipseExt.showView(ViewType.SERVERS);
SWTBotTree serverTree = servers.tree();
@@ -136,8 +136,7 @@
new SWTBotMenu(ContextMenuHelper.getContextMenu(serverTree,
menuLabel, false)).click();
- swtEclipseExt.getSwtUtilExt().waitForAll(timeOut);
-
+ SWTTestExt.util.waitForAll(timeOut);
}
/**
* Deletes Application Server in Server View on position specified by index
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java 2010-01-26
14:47:50 UTC (rev 19931)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java 2010-01-26
15:31:05 UTC (rev 19932)
@@ -24,8 +24,9 @@
public static final Logger log = Logger.getLogger(SWTTestExt.class);
public static final SWTBotExt bot = new SWTBotExt();
+ public static final SWTEclipseExt eclipse = new SWTEclipseExt(bot);
public static final SWTUtilExt util = new SWTUtilExt(bot);
- public static final SWTEclipseExt eclipse = new SWTEclipseExt(bot);
+
// Views
public static final PackageExplorer packageExplorer = new PackageExplorer();