Author: jpeterka
Date: 2009-11-10 09:29:25 -0500 (Tue, 10 Nov 2009)
New Revision: 18568
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/.classpath
trunk/jst/tests/org.jboss.tools.ui.bot.ext/.project
trunk/jst/tests/org.jboss.tools.ui.bot.ext/.settings/
trunk/jst/tests/org.jboss.tools.ui.bot.ext/.settings/org.eclipse.jdt.core.prefs
trunk/jst/tests/org.jboss.tools.ui.bot.ext/META-INF/
trunk/jst/tests/org.jboss.tools.ui.bot.ext/META-INF/MANIFEST.MF
trunk/jst/tests/org.jboss.tools.ui.bot.ext/build.properties
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/log4j.xml
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/Activator.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/SWTTestExt.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/entity/
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/JavaClassEntity.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/JavaProjectEntity.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/
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/
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/JobLists.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/JobState.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/Label.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/PerspectiveType.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ProjectType.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java
Log:
Initial commit of swtbot related support
Added: trunk/jst/tests/org.jboss.tools.ui.bot.ext/.classpath
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/.classpath (rev 0)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/.classpath 2009-11-10 14:29:25 UTC (rev
18568)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/jst/tests/org.jboss.tools.ui.bot.ext/.project
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/.project (rev 0)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/.project 2009-11-10 14:29:25 UTC (rev
18568)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.ui.bot.ext</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/jst/tests/org.jboss.tools.ui.bot.ext/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/.settings/org.eclipse.jdt.core.prefs 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,8 @@
+#Fri Sep 25 09:46:34 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: trunk/jst/tests/org.jboss.tools.ui.bot.ext/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/META-INF/MANIFEST.MF 2009-11-10 14:29:25
UTC (rev 18568)
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBoss Tools SWTBot Extensions
+Bundle-SymbolicName: org.jboss.tools.ui.bot.ext
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.jboss.tools.ui.bot.ext.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.swtbot.eclipse.core;bundle-version="2.0.0",
+ org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.0",
+ org.eclipse.swtbot.eclipse.spy;bundle-version="2.0.0",
+ org.eclipse.swtbot.eclipse.ui;bundle-version="2.0.0",
+ org.eclipse.swtbot.junit4_x;bundle-version="2.0.0",
+ org.eclipse.swtbot.swt.finder;bundle-version="2.0.0",
+ org.hamcrest;bundle-version="1.1.0",
+ org.junit4;bundle-version="4.5.0",
+ org.apache.log4j;bundle-version="1.2.13"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Eclipse-RegisterBuddy: org.apache.log4j
+Export-Package: org.jboss.tools.ui.bot.ext,
+ org.jboss.tools.ui.bot.ext.entity,
+ org.jboss.tools.ui.bot.ext.types
+
Added: trunk/jst/tests/org.jboss.tools.ui.bot.ext/build.properties
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/build.properties
(rev 0)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/build.properties 2009-11-10 14:29:25 UTC
(rev 18568)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/log4j.xml
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/log4j.xml (rev
0)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/log4j.xml 2009-11-10 14:29:25 UTC (rev
18568)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration
xmlns:log4j="http://jakarta.apache.org/log4j/"
+ debug="false">
+
+ <appender name="consoleAppender"
class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) -
%m%n" />
+ </layout>
+ </appender>
+
+ <appender name="fileAppender"
class="org.apache.log4j.FileAppender">
+ <param name="File" value="/tmp/debug.log" />
+ <param name="Append" value="false" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) -
%m%n" />
+ </layout>
+ </appender>
+
+ <appender name="asyncAppender"
class="org.apache.log4j.AsyncAppender">
+ <!-- appender-ref ref="consoleAppender" / -->
+ <appender-ref ref="fileAppender" />
+ </appender>
+
+ <!-- don't log matchers, this is very high amount of chatter -->
+ <category name="org.eclipse.swtbot.swt.finder.matchers">
+ <priority value="OFF" />
+ </category>
+
+ <!--
+ don't log widget notification events, this is moderately high chatter
+ -->
+ <category name="org.eclipse.swtbot.swt.finder.widgets">
+ <priority value="OFF" />
+ </category>
+
+ <!-- don't log finders, this is moderate chatter -->
+ <category name="org.eclipse.swtbot.swt.finder.finders">
+ <priority value="DEBUG" />
+ </category>
+
+ <category name="org.eclipse.swtbot.swt.finder.keyboard">
+ <!-- set to a value higher than debug to turn on. -->
+ <priority value="DEBUG" />
+ </category>
+
+ <category name="org.eclipse.swtbot">
+ <priority value="ALL" />
+ </category>
+
+ <root>
+ <priority value="INFO" />
+ <appender-ref ref="consoleAppender" />
+ <appender-ref ref="fileAppender" />
+ </root>
+
+</log4j:configuration>
\ No newline at end of file
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/Activator.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/Activator.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/Activator.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,66 @@
+ /*******************************************************************************
+ * 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;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.ui.bot.ext";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+ * )
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+ * )
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTBotExt.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,72 @@
+ /*******************************************************************************
+ * 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;
+
+import static org.junit.Assert.fail;
+
+import org.apache.log4j.Logger;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+
+/**
+ * Extended version of SWTWorkbenchBot, logging added
+ *
+ * @author jpeterka
+ *
+ */
+public class SWTBotExt extends SWTWorkbenchBot {
+
+ private Logger log = Logger.getLogger(SWTBotExt.class);
+
+ public void logAndFail(String msg) {
+ log.error(msg);
+ fail(msg);
+ }
+
+ // ------------------------------------------------------------
+ // SWTBot method wrapper ( for better logging mainly )
+ // ------------------------------------------------------------
+
+ @Override
+ public SWTBotMenu menu(String text) {
+ log.info("Menu \"" + text + "\" secleted");
+ return super.menu(text);
+ }
+
+ @Override
+ public SWTBotButton button(String text) {
+ log.info("Button \"" + text + "\" selected");
+ return super.button(text);
+ }
+
+ @Override
+ public SWTBotTree tree() {
+ log.info("Tree selected");
+ return super.tree();
+ }
+
+ @Override
+ public SWTBotCCombo ccomboBox(String text) {
+ log.info("Combobox \"" + text + "\" selected");
+ return super.ccomboBox(text);
+ }
+
+ @Override
+ public SWTBotTable table() {
+ log.info("Table selected");
+ return super.table();
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,254 @@
+ /*******************************************************************************
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.util.logging.Logger;
+
+import org.eclipse.swt.widgets.Shell;
+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.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.hamcrest.Matcher;
+import org.jboss.tools.ui.bot.ext.entity.JavaClassEntity;
+import org.jboss.tools.ui.bot.ext.entity.JavaProjectEntity;
+import org.jboss.tools.ui.bot.ext.types.EntityType;
+import org.jboss.tools.ui.bot.ext.types.Label;
+import org.jboss.tools.ui.bot.ext.types.PerspectiveType;
+import org.jboss.tools.ui.bot.ext.types.ViewType;
+
+/**
+ * Provieds Eclipse common operation based on SWTBot element operations
+ * @author jpeterka
+ *
+ */
+public class SWTEclipseExt {
+
+ SWTBotExt bot = new SWTBotExt();
+ SWTUtilExt util = new SWTUtilExt();
+ Logger log = Logger.getLogger(SWTEclipseExt.class.getName());
+
+ // ------------------------------------------------------------
+ // Additional missing or more advance methods
+ // ------------------------------------------------------------
+ /**
+ * Close view by text
+ */
+ public void closeView(String view) {
+ bot.viewByTitle(view).close();
+ }
+
+ /**
+ * Show view
+ *
+ * @param type
+ */
+ public void showView(ViewType type) {
+ bot.menu(Label.Menu.WINDOW).menu(Label.Menu.SHOW_VIEW).menu(
+ Label.Menu.OTHER).click();
+ bot.tree().expandNode(type.getGroupLabel()).expandNode(type.getViewLabel()).select();
+ bot.button(Label.Button.OK).click();
+
+
+ }
+
+ /**
+ * Open Perspective
+ *
+ * @param type
+ */
+ public void openPerspective(PerspectiveType type) {
+ String perspectiveLabel = "";
+
+ if (type == PerspectiveType.JAVA) {
+ perspectiveLabel = Label.SelectPerspectiveDialog.JAVA;
+ }
+
+ bot.menu(Label.Menu.WINDOW).menu(Label.Menu.OPEN_PERSPECTIVE).menu(
+ Label.Menu.OTHER).click();
+ bot.table().select(perspectiveLabel);
+
+ // Another approach
+ // SWTBotShell openPerpectiveShell = bot.shell("Open Perspective");
+ // openPerpectiveShell.activate();
+
+ bot.button(Label.Button.OK).click();
+ }
+
+ /**
+ * Create Java Project desribed with propriate entity
+ * @param entity
+ */
+ public void createJavaProject(JavaProjectEntity entity) {
+ // NewWizard
+ createNew(EntityType.JAVA_PROJECT);
+ waitForShell(Label.Shell.NEW_JAVA_PROJECT);
+
+ // JavaProjectWizard
+ bot.textWithLabel(Label.JavaProjectWizard.PROJECT_NAME).setText(
+ entity.getProjectName());
+ bot.button(Label.Button.FINISH).click();
+
+ // Wait for shell closing JavaProjectWizard
+ waitForClosedShell(Label.Shell.NEW_JAVA_PROJECT);
+ util.waitForNonIgnoredJobs();
+ }
+
+ /**
+ * Create new Java Class described with JavaClassEntity
+ * @param entity
+ */
+ public void createJavaClass(JavaClassEntity entity) {
+ createNew(EntityType.JAVA_CLASS);
+ waitForShell(Label.Shell.NEW_JAVA_CLASS);
+
+ bot.textWithLabel(Label.NewClassCreationWizard.PACKAGE_NAME).setText(entity.getPackageName());
+ bot.textWithLabel(Label.NewClassCreationWizard.CLASS_NAME).setText(entity.getClassName());
+ bot.button(Label.Button.FINISH).click();
+
+ waitForClosedShell(Label.Shell.NEW_JAVA_CLASS);
+ util.waitForNonIgnoredJobs();
+ }
+
+ /**
+ * Remove entity from package explorer
+ * @param projectName
+ * @param path
+ */
+ public void removeFile(String projectName, String... path) {
+ // Open Package Explorer and aim the Project
+ SWTBot viewBot = bot.viewByTitle(Label.View.PACKAGE_EXPLORER).bot();
+ SWTBotTreeItem item = viewBot.tree().expandNode(projectName);
+
+ // Go through path
+ for ( String nodeName: path ) {
+ item = item.expandNode(nodeName);
+ }
+
+ // Delete File
+ item.select().contextMenu("Delete").click();
+ bot.button(Label.Button.OK).click();
+ }
+
+
+ /**
+ * Open File in Package Explorer
+ * @param projectName
+ * @param path
+ */
+ public void openFile(String projectName, String... path) {
+ SWTBot viewBot = bot.viewByTitle(Label.View.PACKAGE_EXPLORER).bot();
+ SWTBotTreeItem item = viewBot.tree().expandNode(projectName);
+ StringBuilder builder = new StringBuilder(projectName);
+
+ // Go through path
+ for ( String nodeName: path ) {
+ item = item.expandNode(nodeName);
+ builder.append("/" + nodeName);
+ }
+
+ item.select().doubleClick();
+ log.info("File Opened:" + builder.toString());
+ }
+
+
+ // ------------------------------------------------------------
+ // Subroutines
+ // ------------------------------------------------------------
+
+ /**
+ * Invoke Create new entity dialog (it means File -> New -> EntityType -> Next
)
+ */
+ public void createNew(EntityType entityType) {
+
+ String groupLabel = entityType.getGroupLabel();
+ String entityLabel = entityType.getEntityLabel();
+
+ bot.menu(Label.Menu.FILE).menu(Label.Menu.NEW).menu(Label.Menu.OTHER).click();
+ waitForShell(Label.Shell.NEW);
+
+ bot.tree().expandNode(groupLabel).select(entityLabel);
+ bot.button(Label.Button.NEXT).click();
+ }
+
+ /**
+ * Wait for appereance shell of given name
+ * @param 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) {
+ bot.waitWhile(Conditions.shellIsActive(shellName));
+ }
+
+ /**
+ * 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 = util.getResourceFile(pluginId, path);
+ String resourceContent = util.readTextFile(file);
+
+ openAsText(projectName, path);
+ SWTBotEclipseEditor editor = bot.editorByTitle(path[path.length - 1]).toTextEditor();
+ String fileContent = editor.getText();
+
+ 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(Label.View.PACKAGE_EXPLORER).bot();
+ SWTBotTreeItem item = viewBot.tree().expandNode(projectName);
+
+ // Go through path
+ for ( String nodeName: path ) {
+ log.info(nodeName);
+ item = item.expandNode(nodeName);
+ }
+
+ item.select();
+ }
+
+ /**
+ * Replace class content from content of class from resource
+ * @param pluginId
+ * @param path
+ */
+ public void setClassContentFromResource(String pluginId, String... path) {
+ SWTBotEclipseEditor editor;
+ editor = bot.editorByTitle(path[path.length - 1]).toTextEditor();
+ editor.selectRange(0, 0, editor.getLineCount());
+ File file = util.getResourceFile(pluginId, path);
+ String content = util.readTextFile(file);
+ editor.setText(content);
+ editor.save();
+ }
+}
Added:
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
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTTestExt.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,43 @@
+ /*******************************************************************************
+ * 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;
+
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Base class for SWTBot Tests using SWTBotExt
+ * @author jpeterka
+ *
+ */
+public class SWTTestExt {
+
+ public static Logger log = Logger.getLogger(SWTTestExt.class);
+ public static SWTBotExt bot = new SWTBotExt();
+ public static SWTUtilExt util = new SWTUtilExt();
+ public static SWTEclipseExt eclipse = new SWTEclipseExt();
+ private static Properties properties;
+
+ /**
+ * Get properties for hibernate tests
+ * @param key
+ */
+ public static String getProperty(String key) {
+ return util.getValue(properties,key);
+ }
+
+ // Wait Constants
+ public static int TIME_1S = 1000;
+ public static int TIME_5S = 5000;
+ public static int TIME_10S = 10000;
+ public static int TIME_20S = 20000;
+}
Added:
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
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,305 @@
+ /*******************************************************************************
+ * 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;
+
+import static org.junit.Assert.fail;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
+import org.jboss.tools.ui.bot.ext.types.JobLists;
+import org.jboss.tools.ui.bot.ext.types.JobState;
+import org.osgi.framework.Bundle;
+
+/**
+ * Base class for all classes using SWTBot
+ *
+ * @author jpeterka
+ *
+ */
+public class SWTUtilExt extends SWTUtils {
+
+ private Logger log = Logger.getLogger(SWTUtilExt.class);
+ protected SWTBotExt bot = new SWTBotExt();
+
+ // ------------------------------------------------------------
+ // Waiting methods
+ // ------------------------------------------------------------
+
+ // Constants
+ final int TIMEOUT = 20000; // 10s
+ final int SLEEPTIME = 1000; // 0.5s
+
+ /**
+ * Wait for named running jobs with defined TIMEOUT
+ */
+ public void waitForJobs(String... jobNames) {
+ waitForJobs(TIMEOUT, jobNames);
+ }
+
+ /**
+ * Wait for all running jobs not named in JobList.ignoredJobs
+ */
+ public void waitForNonIgnoredJobs() {
+ waitForAllExcept(JobLists.ignoredJobs);
+ }
+
+ /**
+ * Wait for all running jobs
+ */
+ public void waitForAll() {
+ waitForAllExcept(new String[0]);
+ }
+
+ /**
+ * Wait for all running jobs except named jobs
+ * @param jobNames
+ */
+ public void waitForAllExcept(String... jobNames) {
+
+ // Find all jobs
+ Job[] jobs = Job.getJobManager().find(null);
+ List<String> listNames = new ArrayList<String>();
+
+ for (Job job : jobs) {
+ listNames.add(job.getName());
+ }
+
+ // Remove ignored jobs
+ for (String jobName : jobNames) {
+ if (listNames.contains(jobName))
+ listNames.remove(jobName);
+ }
+
+ // Create rest job list
+ String[] names = new String[listNames.size()];
+ for (int i = 0; i < listNames.size(); i++) {
+ names[i] = listNames.get(i);
+ }
+
+ waitForJobs(names);
+ }
+
+ /**
+ * Waits for selected job
+ * @param timeOut
+ * @param jobNames
+ */
+ public void waitForJobs(long timeOut, String... jobNames) {
+
+ // DEBUG
+ printRunningJobs();
+
+ // No Jobs
+ if (jobNames == null || jobNames.length == 0) {
+ log.info("No jobs prescribed as blocking");
+ delay();
+ return;
+ }
+
+ // Jobs prescribed
+ long startTime = System.currentTimeMillis();
+ List<String> blockingJobs = new ArrayList<String>();
+
+ // Go through jobs and wait for completion
+ for (String jobName : jobNames) {
+ if (isJobRunning(jobName)) {
+ log.info("Blocking job " + jobName + " found");
+ blockingJobs.add(jobName);
+ }
+ }
+
+ // Wait until all blocking jobs aren't finished or timeout
+ for (String jobName : blockingJobs) {
+ while (true) {
+ if (!isJobRunning(jobName)) {
+ log.info("Job " + jobName + " is finished");
+ break;
+ }
+
+ long waitTime = System.currentTimeMillis() - startTime;
+ if ((System.currentTimeMillis() - startTime) > TIMEOUT) {
+ log.info("Waiting for job " + jobName + " TIMEOUT");
+ break;
+ }
+ log.info("Job \"" + jobName + "\" is running for " +
waitTime
+ / 1000 + "s");
+ bot.sleep(SLEEPTIME);
+ }
+ }
+
+ log.info("All blocking jobs finished or skipped");
+ }
+
+ /**
+ * Search for jobname in JobManager job list
+ *
+ * @param jobName
+ * name of the job
+ * @return true if job with corresponding name found, else false
+ */
+ private boolean isJobRunning(String jobName) {
+ Job[] jobs = Job.getJobManager().find(null);
+ for (Job job : jobs) {
+ if ((jobName.equalsIgnoreCase(job.getName()))
+ && ((job.getState() == JobState.RUNNING) || (job.getState() ==
JobState.WAITING)))
+ return true;
+ }
+ return false;
+ }
+
+ private void printRunningJobs() {
+ Job[] jobs = Job.getJobManager().find(null);
+ for (Job job : jobs) {
+
+ String jobStateName = JobState.getStateName(job.getState());
+
+ log.info("Active Job: P:" + job.getPriority() + "\" S:"
+ + jobStateName + "\" R:" + job.getResult() + "\"
N:\""
+ + job.getName() + "\"");
+ }
+ }
+
+ public void delay() {
+ bot.sleep(500);
+ }
+
+ // ------------------------------------------------------------
+ // Resource methods
+ // ------------------------------------------------------------
+
+ /**
+ * Get resource file
+ */
+ public File getResourceFile(String pluginId, String... path) {
+
+ // Construct path
+ StringBuilder builder = new StringBuilder();
+ for (String fragment: path) {
+ builder.append("/" + fragment);
+ }
+
+ String filePath = "";
+ try {
+ filePath = FileLocator.toFileURL(
+ Platform.getBundle(pluginId).getEntry("/"))
+ .getFile() + "resources" + builder.toString();
+ File file = new File(filePath);
+ if (!file.isFile()) {
+ filePath = FileLocator.toFileURL(
+ Platform.getBundle(pluginId).getEntry("/"))
+ .getFile() + builder.toString();
+ }
+ } catch (IOException ex) {
+ String message = filePath + " resource file not found";
+ log.error(message);
+ fail(message);
+ }
+
+ File file = new File(filePath);
+ return file;
+ }
+
+ /**
+ * Reads text file
+ *
+ * @param file
+ * @return
+ */
+ public String readTextFile(File file) {
+
+ StringBuilder contents = new StringBuilder();
+
+ try {
+ BufferedReader input = new BufferedReader(new FileReader(file));
+ try {
+ String line = null; //not declared within while loop
+ while (( line = input.readLine()) != null){
+ contents.append(line);
+ contents.append(System.getProperty("line.separator"));
+ }
+ }
+ finally {
+ input.close();
+ }
+ }
+ catch (IOException ex){
+ ex.printStackTrace();
+ }
+
+ return contents.toString();
+ }
+
+ /**
+ * Loads project property file for particular test plugin
+ * @param pluginId
+ * @return
+ */
+ public Properties loadProperties(String pluginId) {
+ Properties properties = new Properties();
+ try {
+ log.info("Loading properties for " + pluginId);
+ // Read project properties
+ Bundle bundle = Platform.getBundle(pluginId);
+ InputStream is = bundle.getResource("project.properties").openStream();
+ properties.load(is);
+ log.info("Properties for " + pluginId + " loaded:");
+
+ } catch (Exception ex) {
+ logAndFail("Problem with loading properties file");
+ }
+ return properties;
+ }
+
+ /**
+ * Get value from property file with error logging
+ * @param properties
+ * @param key
+ * @return
+ */
+ public String getValue(Properties properties, String key) {
+ String value = properties.getProperty(key);
+ if ((value == null) || value.equalsIgnoreCase("")) {
+ logAndFail("Missing property value for key \"" + key
+ + "\"");
+ }
+ return value;
+ }
+
+ /**
+ * Check Property values
+ * @param properties
+ * @param key
+ */
+ public void checkAndLogValue(Properties properties, String key) {
+ log.info(key + "=" + getValue(properties, key));
+ }
+
+ /**
+ * Log and fail
+ * @param msg
+ */
+ public void logAndFail(String msg) {
+ log.error(msg);
+ fail(msg);
+ }
+}
\ No newline at end of file
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/JavaClassEntity.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/JavaClassEntity.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/JavaClassEntity.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,40 @@
+ /*******************************************************************************
+ * 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.entity;
+
+/**
+ * Java Class Entity describing needed attributes of Java class for bot test purposes
+ * @author jpeterka
+ *
+ */
+public class JavaClassEntity {
+
+ private String className = "";
+ private String packageName = "";
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+
+}
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/JavaProjectEntity.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/JavaProjectEntity.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/JavaProjectEntity.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,30 @@
+ /*******************************************************************************
+ * 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.entity;
+
+/**
+ * This class is describing needed Java Project parameters used as input parameter for
other methods
+ * @author jpeterka
+ *
+ */
+public class JavaProjectEntity {
+
+ String projectName;
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/ContextMenuHelper.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,131 @@
+ /*******************************************************************************
+ * 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.helper;
+
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.instanceOf;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Widget;
+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.results.WidgetResult;
+import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
+import org.hamcrest.Matcher;
+
+/**
+ * Helper to find context menu of widget
+ * @author Vladimir Pakan
+ *
+ */
+public class ContextMenuHelper {
+
+ /**
+ * Clicks the context menu matching the text.
+ *
+ * @param bot bot containing context menu.
+ * @param text the text on the context menu.
+ * @param hideAfterwards hide menu when method is finished.
+ * @throws WidgetNotFoundException if the widget is not found.
+ */
+ public static MenuItem getContextMenu(final AbstractSWTBot<?> bot,
+ final String text, final boolean hideAfterwards) {
+ final MenuItem menuItem = UIThreadRunnable
+ .syncExec(new WidgetResult<MenuItem>() {
+ @SuppressWarnings("unchecked")
+ public MenuItem run() {
+ MenuItem menuItem = null;
+ Menu menu = getWidgetMenu(bot.widget);
+ Matcher<?> matcher =
allOf(instanceOf(MenuItem.class),withMnemonic(text));
+ menuItem = show(menu, matcher, hideAfterwards);
+ if (menuItem != null) {
+ menu = menuItem.getMenu();
+ } else {
+ hide(menu);
+ }
+ return menuItem;
+ }
+ });
+ if (menuItem == null) {
+ throw new WidgetNotFoundException("Could not find menu: " + text);
+ }
+ else{
+ if (hideAfterwards){
+ // hide
+ UIThreadRunnable.syncExec(new VoidResult() {
+ public void run() {
+ hide(menuItem.getParent());
+ }
+ });
+ }
+
+ return menuItem;
+ }
+ }
+ /**
+ * Simulate Show event to menu and returns MenuItem matching to matcher
+ * @param menu
+ * @param matcher
+ * @param hideAfterwards
+ * @return
+ */
+ private static MenuItem show(final Menu menu, final Matcher<?> matcher, final
boolean hideAfterwards) {
+ if (menu != null) {
+ menu.notifyListeners(SWT.Show, new Event());
+ MenuItem[] items = menu.getItems();
+ for (final MenuItem menuItem : items) {
+ if (matcher.matches(menuItem)) {
+ return menuItem;
+ }
+ }
+ if (hideAfterwards){
+ menu.notifyListeners(SWT.Hide, new Event());
+ }
+ }
+ return null;
+ }
+ /**
+ * Recursively hide menus
+ * @param menu bottom menu to start hiding from
+ */
+ private static void hide(final Menu menu) {
+ menu.notifyListeners(SWT.Hide, new Event());
+ if (menu.getParentMenu() != null) {
+ hide(menu.getParentMenu());
+ }
+ }
+ /**
+ * Returns menu of input widget
+ * @param widget
+ * @return
+ */
+ private static Menu getWidgetMenu (Widget widget){
+
+ Menu result = null;
+
+ if (widget instanceof MenuItem){
+ result = ((MenuItem)widget).getMenu();
+ }
+ else{
+ result = ((Control)widget).getMenu();
+ }
+
+ return result;
+
+ }
+}
Added:
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
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/EntityType.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,52 @@
+ /*******************************************************************************
+ * 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.types;
+
+import static org.junit.Assert.fail;
+
+/**
+ * Provides functionality for evaluation particular entity location like projects types,
file types, etc.
+ * @author jpeterka
+ */
+public enum EntityType {
+ HIBERNATE_MAPPING_FILE, JAVA_PROJECT, JAVA_CLASS;
+
+ public String getGroupLabel() {
+ String groupLabel = "";
+
+
+ switch (this) {
+ case HIBERNATE_MAPPING_FILE: groupLabel = Label.EntityGroup.HIBERNATE; break;
+ case JAVA_PROJECT: groupLabel = Label.EntityGroup.JAVA; break;
+ case JAVA_CLASS: groupLabel = Label.EntityGroup.JAVA; break;
+ default: fail("Unknown Entity Type");
+ }
+
+ return groupLabel;
+ }
+
+ /**
+ * Return entity label acc
+ * @return
+ */
+ public String getEntityLabel() {
+ String entityLabel = "";
+
+ switch (this) {
+ case HIBERNATE_MAPPING_FILE: entityLabel = Label.EntityLabel.HIBERNATE_MAPPING_FILE;
break;
+ case JAVA_PROJECT: entityLabel = Label.EntityLabel.JAVA_PROJECT; break;
+ case JAVA_CLASS: entityLabel = Label.EntityLabel.JAVA_CLASS; break;
+ default: fail("Unknown Entity Type");
+ }
+
+ return entityLabel;
+ }
+}
\ No newline at end of file
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/JobLists.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/JobLists.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/JobLists.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,20 @@
+ /*******************************************************************************
+ * 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.types;
+
+/**
+ * Class provides job lists like list of jobs which should be ignored for wait methods
+ **/
+public class JobLists {
+
+ public static String[] ignoredJobs = { "Usage Data Event consumer",
+ "Updating indexes" };
+}
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/JobState.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/JobState.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/JobState.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,39 @@
+ /*******************************************************************************
+ * 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.types;
+
+/**
+ * Support class for JobState evaluation
+ * @author jpeterka
+ */
+public class JobState {
+ public static final int NONE = 0;
+ public static final int SLEEPING = 1;
+ public static final int WAITING = 2;
+ public static final int RUNNING = 4;
+
+ public static String getStateName(int jobState) {
+ String jobStateName = "";
+
+ if (jobState == JobState.NONE)
+ jobStateName = "None";
+ else if (jobState == JobState.SLEEPING)
+ jobStateName = "Sleeping";
+ else if (jobState == 2)
+ jobStateName = "Waiting";
+ else if (jobState == 4)
+ jobStateName = "Running";
+ else
+ throw new IllegalArgumentException("Unknown JobState");
+
+ return jobStateName;
+ }
+}
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/Label.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/Label.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/Label.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,94 @@
+ /*******************************************************************************
+ * 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.types;
+
+/**
+ * Base label constants for all widgets. Naming convention is (except buttons
+ * and menus) based on Eclipse platform class names of each part (e.g.
+ * NewJavaProjectWizardPageOne)
+ *
+ * @author jpeterka
+ */
+public class Label {
+ public class Menu {
+ public static final String FILE = "File";
+ public static final String NEW = "New";
+ public static final String PROJECT = "Project";
+ public static final String OTHER = "Other...";
+ public static final String WINDOW = "Window";
+ public static final String SHOW_VIEW = "Show View";
+ public static final String OPEN_PERSPECTIVE = "Open Perspective";
+ public static final String OPEN_WITH = "Open With";
+ public static final String TEXT_EDITOR = "Text Editor";
+ public static final String EDIT = "Edit";
+ public static final String SELECT_ALL = "Select All";
+ }
+
+ public class Button {
+ public static final String NEXT = "Next >";
+ public static final String BACK = "< Back";
+ public static final String CANCEL = "Cancel";
+ public static final String FINISH = "Finish";
+ public static final String OK = "OK";
+ }
+
+ public class Shell {
+ public static final String NEW_JAVA_PROJECT = "New Java Project";
+ public static final String NEW_JAVA_CLASS = "New Java Class";
+ public static final String NEW_HIBERNATE_MAPPING_FILE = "New Hibernate XML Mapping
file (hbm.xml)";
+ public static final String NEW = "New";
+ }
+
+ public class EntityGroup {
+ public static final String HIBERNATE = "Hibernate";
+ public static final String JAVA = "Java";
+ public static final String SEAM = "Seam";
+ }
+
+ public class EntityLabel {
+ public static final String HIBERNATE_MAPPING_FILE = "Hibernate XML Mapping file
(hbm.xml)";
+ public static final String JAVA_CLASS = "Class";
+ public static final String JAVA_PROJECT = "Java Project";
+ public static final String SEAM_PROJECT = "Seam Web Project";
+ }
+
+ public class JavaProjectWizard {
+ public static final String PROJECT_NAME = "Project name:";
+ }
+
+ public class NewClassCreationWizard {
+ public static final String CLASS_NAME = "Name:";
+ public static final String PACKAGE_NAME = "Package:";
+ }
+
+ public class ShowViewDialog {
+ public static final String JAVA_GROUP = "Java";
+ public static final String PROJECT_EXPLORER = "Project Explorer";
+
+ }
+
+ public class View {
+ public static final String WELCOME = "Welcome";
+ public static final String PROJECT_EXPLORER = "Project Explorer";
+ public static final String PACKAGE_EXPLORER = "Package Explorer";
+ }
+
+ public class ViewGroup {
+ public static final String GENERAL = "General";
+ public static final String JAVA = "Java";
+ }
+
+ public class SelectPerspectiveDialog {
+ public static final String JAVA = "Java";
+ public static final String HIBERNATE = "Hibernate";
+
+ }
+}
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/PerspectiveType.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/PerspectiveType.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/PerspectiveType.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,20 @@
+ /*******************************************************************************
+ * 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.types;
+
+/**
+ * Eclipse perspective type enum
+ * @author jpeterka
+ *
+ */
+public enum PerspectiveType {
+ SEAM, JAVA, WEB_DEVELOPMENT;
+}
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ProjectType.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ProjectType.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ProjectType.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,20 @@
+ /*******************************************************************************
+ * 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.types;
+
+/**
+ * Eclipse project type enum
+ * @author jpeterka
+ *
+ */
+public enum ProjectType {
+ JAVA, SEAM
+}
Added:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java
(rev 0)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/ViewType.java 2009-11-10
14:29:25 UTC (rev 18568)
@@ -0,0 +1,41 @@
+ /*******************************************************************************
+ * 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.types;
+
+import static org.junit.Assert.fail;
+
+/**
+ * Provides functionality to locate appropriate view type
+ * @author jpeterka
+ *
+ */
+public enum ViewType {
+ PROJECT_EXPLORER, WELCOME;
+
+
+ public String getGroupLabel() {
+ String viewLabel = "";
+ switch (this) {
+ case PROJECT_EXPLORER: viewLabel = Label.ViewGroup.GENERAL; break;
+ default: fail("Unknown View Type");
+ }
+ return viewLabel;
+ }
+
+ public String getViewLabel() {
+ String viewLabel = "";
+ switch (this) {
+ case PROJECT_EXPLORER: viewLabel = Label.View.PROJECT_EXPLORER; break;
+ default: fail("Unknown View Type");
+ }
+ return viewLabel;
+ }
+}