Author: dennyxu
Date: 2010-04-21 03:33:06 -0400 (Wed, 21 Apr 2010)
New Revision: 21570
Added:
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/readme.txt
Modified:
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/test/swtbot/GuvnorSWTBotTest.java
Log:
change the swtbot test according the new patch for JBIDE-6165,
Added: workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/readme.txt
===================================================================
--- workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/readme.txt
(rev 0)
+++ workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/readme.txt 2010-04-21
07:33:06 UTC (rev 21570)
@@ -0,0 +1,3 @@
+to run the test, you have to set up "jbosstools.test.jboss.home.4.2" system
property
+or change the default JBOSS_AS_42_HOME system property to an exist JBoss AS 4.2 home
+in your local test environment.
\ No newline at end of file
Modified:
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/test/swtbot/GuvnorSWTBotTest.java
===================================================================
---
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/test/swtbot/GuvnorSWTBotTest.java 2010-04-21
06:06:42 UTC (rev 21569)
+++
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/test/swtbot/GuvnorSWTBotTest.java 2010-04-21
07:33:06 UTC (rev 21570)
@@ -1,6 +1,8 @@
package org.guvnor.tools.test.swtbot;
+import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertEnabled;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -10,6 +12,8 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
@@ -116,14 +120,15 @@
bot.viewByTitle("Servers").show();
// bot.shell("Servers").activate();
- bot.tree().select(0).contextMenu("Start").click();
+ SWTBotTree serverTree = bot.tree();
+ serverTree.select(0).contextMenu("Start").click();
String treeItem = "";
int i = 0;
- while(treeItem.indexOf("Started") < 0 && i < 60){
+ while(treeItem.indexOf("Started") < 0 && i < 120){
bot.sleep(2000);
bot.viewByTitle("Servers").show();
- treeItem = bot.tree().getAllItems()[0].getText();
+ treeItem = serverTree.getAllItems()[0].getText();
// System.out.println(treeItem);
i ++;
@@ -194,25 +199,57 @@
bot.activeShell().activate();
bot.tabItem(1).activate();
- assertTrue("The 'User' text is not enabled",
bot.text(0).isEnabled());
+// assertTrue("The 'User' text is not enabled",
bot.text(0).isEnabled());
- String newUserName = "admin_new";
- String newPwd = "passsword_new";
- bot.text(0).setText(newUserName);
- bot.text(1).setText(newPwd);
+// String newUserName = "admin_new";
+// String newPwd = "passsword_new";
+ bot.getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ assertEquals(bot.getDisplay().getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND),
bot.text(0).backgroundColor());
+ assertEquals(bot.getDisplay().getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND),
bot.text(1).backgroundColor());
+ assertEnabled(bot.text(0));
+ assertEnabled(bot.text(1));
+
+ assertFalse(bot.text(0).widget.getEditable());
+ assertFalse(bot.text(1).widget.getEditable());
+ }
+ });
+
+// assertFalse("The User name text box should be enabled",
bot.text(0).isEnabled());
+// assertFalse("The Password text box should be enabled",
bot.text(1).isEnabled());
+// bot.text(0).setText(newUserName);
+
+// bot.text(1).setText(newPwd);
+
bot.button("OK").click();
- //open properties page to verify the previous changes
+// //open properties page to verify the previous changes
+//
+// tree.select(0).contextMenu("Properties").click();
+// bot.activeShell().activate();
+// bot.tabItem(1).activate();
+// assertEquals("Failed to update User Name", newUserName,
bot.text(0).getText());
+// assertEquals("Failed to update Password", newPwd, bot.text(1).getText());
- tree.select(0).contextMenu("Properties").click();
- bot.activeShell().activate();
- bot.tabItem(1).activate();
- assertEquals("Failed to update User Name", newUserName,
bot.text(0).getText());
- assertEquals("Failed to update Password", newPwd, bot.text(1).getText());
-
bot.sleep(10000);
}
+ private SWTBotTree findTreeByItem(String label){
+ SWTBotTree tree = bot.tree();
+ for( int i = 0; i < 100; i++){
+ tree = bot.tree(i);
+ if(tree.getAllItems().length > 0){
+ SWTBotTreeItem item = tree.getAllItems()[0];
+ if(item.getText() != null && item.getText().indexOf(label) > 0){
+ break;
+ }
+ }
+ }
+
+ return tree;
+ }
}
Show replies by date