Author: jlukas(a)redhat.com
Date: 2010-07-28 09:28:38 -0400 (Wed, 28 Jul 2010)
New Revision: 23777
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java
Log:
minor improvements in cdi wizards tests
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java 2010-07-28
12:37:49 UTC (rev 23776)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java 2010-07-28
13:28:38 UTC (rev 23777)
@@ -11,8 +11,13 @@
package org.jboss.tools.cdi.bot.test.uiutils.actions;
import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
public abstract class Action<T> {
@@ -20,13 +25,13 @@
private final String[] path;
public Action(String... path) {
+ assert path.length > 0;
this.path = path;
}
public abstract T run();
protected SWTBot performMenu() {
- assert path.length > 0;
SWTBotMenu m = bot.menu(path[0]);
for (int i = 1; i < path.length; i++) {
m = m.menu(path[i]);
@@ -34,4 +39,20 @@
m.click();
return new SWTBot();
}
+
+ protected SWTBot pepformPopup(final SWTBotTree tree, SWTBotTreeItem item) {
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree, item);
+ UIThreadRunnable.syncExec(new Result<SWTBotMenu>() {
+
+ public SWTBotMenu run() {
+ SWTBotMenu m = new SWTBotMenu(ContextMenuHelper.getContextMenu(
+ tree, path[0], false));
+ for (int i = 1; i < path.length; i++) {
+ m = m.menu(path[i]);
+ }
+ return m;
+ }
+ }).click();
+ return new SWTBot();
+ }
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java 2010-07-28
12:37:49 UTC (rev 23776)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java 2010-07-28
13:28:38 UTC (rev 23777)
@@ -4,7 +4,7 @@
* 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
- *
+ *
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
@@ -16,6 +16,7 @@
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
public class CDIWizard extends Wizard {
@@ -166,6 +167,44 @@
return Arrays.asList(bot().comboBoxWithLabel("Scope:").items());
}
+ public CDIWizard addIBinding(String ib) {
+ switch (type) {
+ case INTERCEPTOR_BINDING:
+ case STEREOTYPE:
+ bot().button("Add", 0).click();
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().text().setText(ib);
+ sh.bot().button("OK").click();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public List<String> getIBindings() {
+ return Arrays.asList(bot().listWithLabel("Interceptor
Bindings:").getItems());
+ }
+
+ public CDIWizard addStereotype(String stereotype) {
+ switch (type) {
+ case STEREOTYPE:
+ bot().button("Add", 1).click();
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().text().setText(stereotype);
+ sh.bot().button("OK").click();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public List<String> getStereotypes() {
+ return Arrays.asList(bot().listWithLabel("Stereotypes:").getItems());
+ }
+
+
private void setCheckbox(String label, boolean set) {
SWTBotCheckBox c = bot().checkBox(label);
if (c.isChecked() != set) {
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java 2010-07-28
12:37:49 UTC (rev 23776)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java 2010-07-28
13:28:38 UTC (rev 23777)
@@ -4,7 +4,7 @@
* 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
- *
+ *
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
@@ -108,18 +108,21 @@
String code = ed.toTextEditor().getText();
L.fine(code);
assertTrue(code.contains("@NormalScope"));
+ assertFalse(code.contains("@Scope"));
+ assertFalse(code.contains("passivating"));
assertTrue(code.contains("@Retention(RUNTIME)"));
assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
assertTrue(code.contains("@Inherited"));
assertFalse(code.startsWith("/**"));
- scope("cdi", "Scope2", false, true, true, false).finish();
+ scope("cdi", "Scope2", false, true, true, true).finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("Scope2.java").equals(ed.getTitle()));
code = ed.toTextEditor().getText();
L.fine(code);
- assertTrue(code.contains("@NormalScope"));
+ assertTrue(code.contains("@NormalScope(passivating = true)"));
+ assertFalse(code.contains("@Scope"));
assertTrue(code.contains("@Retention(RUNTIME)"));
assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
assertFalse(code.contains("@Inherited"));
@@ -132,6 +135,7 @@
code = ed.toTextEditor().getText();
L.fine(code);
assertTrue(code.contains("@Scope"));
+ assertFalse(code.contains("@NormalScope"));
assertTrue(code.contains("@Retention(RUNTIME)"));
assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
assertFalse(code.contains("@Inherited"));
@@ -165,6 +169,33 @@
assertTrue(code.contains("@Target({ TYPE })"));
assertFalse(code.contains("@Inherited"));
assertTrue(code.startsWith("/**"));
+
+ binding("cdi", "B3", "TYPE", false, true).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("B3.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@InterceptorBinding"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE })"));
+ assertFalse(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+
+ w = binding("cdi", "B4", "TYPE", true, false);
+ w.addIBinding("cdi.B2");
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("B4.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.info(code);
+ assertTrue(code.contains("@InterceptorBinding"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE })"));
+ assertTrue(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+ assertTrue(code.contains("@B2"));
}
@Test
@@ -182,6 +213,8 @@
assertTrue(code.contains("@Stereotype"));
assertTrue(code.contains("@Retention(RUNTIME)"));
assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
+ assertFalse(code.contains("@Named"));
+ assertFalse(code.contains("@Alternative"));
assertFalse(code.contains("@Inherited"));
assertFalse(code.startsWith("/**"));
@@ -191,12 +224,35 @@
ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("S2.java").equals(ed.getTitle()));
code = ed.toTextEditor().getText();
- L.fine(code);
+ L.info(code);
assertTrue(code.contains("@Stereotype"));
+ assertTrue(code.contains("@Scope3"));
+ assertTrue(code.contains("@Named"));
+ assertTrue(code.contains("@Alternative"));
+ assertTrue(code.contains("@Inherited"));
assertTrue(code.contains("@Retention(RUNTIME)"));
assertTrue(code.contains("@Target({ FIELD })"));
- assertTrue(code.contains("@Inherited"));
assertTrue(code.startsWith("/**"));
+
+ w = stereotype("cdi", "S3", null, null, false, false, true,
false);
+ w.addIBinding("cdi.B1");
+ w.addStereotype("cdi.S1");
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("S3.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.info(code);
+ assertTrue(code.contains("@Stereotype"));
+ assertFalse(code.contains("@Scope3"));
+ assertFalse(code.contains("@Named"));
+ assertTrue(code.contains("@Alternative"));
+ assertTrue(code.contains("@B1"));
+ assertTrue(code.contains("@S1"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE })"));
+ assertFalse(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
}
private static SWTBotMenu nodeContextMenu(final SWTBotTree tree,