aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJiri Vanek <[email protected]>2013-05-02 16:05:57 +0200
committerJiri Vanek <[email protected]>2013-05-02 16:05:57 +0200
commit5292af48b536e2b73660a2d893b8f14a7e13fd2d (patch)
treefba358124646659e25aa12f9ce26033b5cad8d1b /tests
parentc01de86b76ad014e30534ba879478c579e748fa9 (diff)
parent551363d32582a6b79894e394352e6a2aa4062646 (diff)
Merge with: Fix for portalbank.no (trying get after failed head requests) and tests
Diffstat (limited to 'tests')
-rw-r--r--tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java45
1 files changed, 32 insertions, 13 deletions
diff --git a/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java b/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java
index e33d35c..91e1ad5 100644
--- a/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java
+++ b/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java
@@ -60,7 +60,7 @@ import net.sourceforge.jnlp.closinglisteners.RulesFolowingClosingListener;
public abstract class AWTHelper extends RulesFolowingClosingListener implements Runnable{
//attributes possibly set by user
- private String initStr = "";
+ private String initStr = null;
private Color appletColor;
private BufferedImage marker;
private Point markerPosition;
@@ -75,7 +75,6 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
private BufferedImage screenshot;
private Robot robot;
private boolean appletFound = false;
- private boolean initStrGiven = false; //impossible to find in the output if not given
private boolean appletColorGiven = false; //impossible to search for color difference if not given
private boolean markerGiven = false; //impossible to find the applet if marker not given
private boolean appletDimensionGiven = false;
@@ -117,7 +116,6 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
this();
this.initStr = initStr;
- this.initStrGiven = true;
}
/**
@@ -148,7 +146,6 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
this(icon, iconPosition, appletWidth, appletHeight);
this.initStr = initString;
- this.initStrGiven = true;
}
/**
@@ -176,7 +173,6 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
public AWTHelper(String initString, int appletWidth, int appletHeight){
this(appletWidth, appletHeight);
this.initStr = initString;
- this.initStrGiven = true;
}
/**
@@ -194,6 +190,8 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
* override of method charReaded (from RulesFolowingClosingListener)
*
* waiting for the applet, when applet is ready run action thread
+ * (if initStr==null, do not check and do not call run)
+ *
* when all the wanted strings are in the stdout, applet can be closed
*
* @param ch
@@ -202,7 +200,8 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
public void charReaded(char ch) {
sb.append(ch);
//is applet ready to start clicking?
- if (initStrGiven && !actionStarted && appletIsReady(sb.toString())) {
+ //check and run applet only if initStr is not null
+ if ((initStr != null) && !actionStarted && appletIsReady(sb.toString())) {
try{
actionStarted = true;
this.findAndActivateApplet();
@@ -241,22 +240,43 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
* @return
*/
public Rule getInitStrAsRule(){
- return new ContainsRule(this.initStr);
+ if( initStr != null ){
+ return new ContainsRule(this.initStr);
+ }else{
+ return new Rule(){
+
+ @Override
+ public void setRule(Object rule) {
+ }
+
+ @Override
+ public boolean evaluate(Object upon) {
+ return true;
+ }
+
+ @Override
+ public String toPassingString() {
+ return "nothing to check, initStr is null";
+ }
+
+ @Override
+ public String toFailingString() {
+ return "nothing to check, initStr is null";
+ }
+
+ } ;
+ }
}
//boolean controls getters
protected boolean appletIsReady(String content) {
- return (content.contains(initStr));
+ return this.getInitStrAsRule().evaluate(content);
}
public boolean isActionStarted() {
return actionStarted;
}
- public boolean isInitStrGiven(){
- return initStrGiven;
- }
-
public boolean isAppletColorGiven(){
return appletColorGiven;
}
@@ -292,7 +312,6 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
public void setInitStr(String initStr) {
this.initStr = initStr;
- this.initStrGiven = true;
}
public void setMarker(BufferedImage marker, Point markerPosition) {