Author: lzoubek(a)redhat.com
Date: 2011-07-15 10:32:10 -0400 (Fri, 15 Jul 2011)
New Revision: 32941
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/ExampleTest.java
Log:
swtbotext: fixed exampleTest to support more than 2 example projects
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/ExampleTest.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/ExampleTest.java 2011-07-15
12:03:51 UTC (rev 32940)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/ExampleTest.java 2011-07-15
14:32:10 UTC (rev 32941)
@@ -2,6 +2,9 @@
import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellCloses;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.jboss.tools.ui.bot.ext.gen.ActionItem;
@@ -15,21 +18,15 @@
*
*/
public class ExampleTest extends SWTTestExt{
+
/**
- * returns example project name (as it is imported to workspace)
+ * returns list of example projects
* @return
*/
- public String getExampleProjectName() {
- return null;
+ public String[] getProjectNames() {
+ return new String[]{"example"};
}
/**
- * returns name of example client project (null if none)
- * @return
- */
- public String getExampleClientProjectName() {
- return null;
- }
- /**
* gets example name (listed in project examples dialog)
* @return
*/
@@ -76,17 +73,34 @@
bot.waitUntil(shellCloses(shell),Timing.time100S());
open.selectTreeNode(wiz,ActionItem.create(getExampleCategory(),getExampleName()));
String hasProjName =
wiz.textWithLabel(JBossToolsProjectExamples.TEXT_PROJECT_NAME).getText();
- assertTrue(String.format("Example project name changed, have '%s',
expected
'%s'",hasProjName,getExampleProjectName()),hasProjName.equals(getExampleProjectName()));
+ assertTrue(String.format("Example project name changed, have '%s',
expected
'%s'",hasProjName,getProjectNames()[0]),hasProjName.equals(getProjectNames()[0]));
+ int projSize =
getProjectSize(wiz.textWithLabel(JBossToolsProjectExamples.TEXT_PROJECT_SIZE).getText());
wiz.checkBox("Show the Quick Fix dialog").deselect();
wiz.button(IDELabel.Button.FINISH).click();
shell = bot.shell("Downloading...");
shell.activate();
- bot.waitUntil(shellCloses(shell),Timing.time100S());
+ bot.waitUntil(shellCloses(shell),Timing.time(projSize*20*1000));
util.waitForNonIgnoredJobs(Timing.time20S());
- assertTrue(String.format("Example project '%s' was not found in project
explorer",getExampleProjectName()),projectExplorer.existsResource(getExampleProjectName()));
- if (getExampleClientProjectName()!=null) {
- assertTrue(String.format("Example project '%s' was not found in project
explorer",getExampleClientProjectName()),projectExplorer.existsResource(getExampleClientProjectName()));
+ for (String project : getProjectNames()) {
+ assertTrue(String.format("Example project '%s' was not found in project
explorer",project),projectExplorer.existsResource(project));
+ }
+ }
+ private int getProjectSize(String size) {
+ Pattern pattern = Pattern.compile("([\\d\\.]+)(M|K)");
+ Matcher m = pattern.matcher(size);
+ if (m.matches()) {
+ try {
+ double s = Double.parseDouble(m.group(1));
+ if ("M".equals(m.group(2))) {
+ return (int)s*1024;
+ }
+ return (int)s;
+ }
+ catch (Exception e) {
+ return 1000;
+ }
}
+ return 1000;
}
}
Show replies by date