summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorLorenzo Bettini2013-02-25 05:14:39 (EST)
committer Lorenzo Bettini2013-02-25 05:14:39 (EST)
commit2a136a8633d704f12dc1da851235861b87127347 (patch)
tree855d1fcbf5cf9d2eaad76ae74b72072e4025fa30
parent7354b19c7da2c69eab6588a6573c2e893889bcdd (diff)
downloadorg.eclipse.swtbot-2a136a8633d704f12dc1da851235861b87127347.zip
org.eclipse.swtbot-2a136a8633d704f12dc1da851235861b87127347.tar.gz
org.eclipse.swtbot-2a136a8633d704f12dc1da851235861b87127347.tar.bz2
handle custom timeouts in tests with hardcoded timeout valuesrefs/changes/07/10607/2
-rw-r--r--org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/SWTBotTest.java17
-rw-r--r--org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotExpandBarTest.java9
2 files changed, 26 insertions, 0 deletions
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/SWTBotTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/SWTBotTest.java
index 469e13f..a87c253 100644
--- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/SWTBotTest.java
+++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/SWTBotTest.java
@@ -19,6 +19,7 @@ import static org.junit.Assert.fail;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.test.AbstractMenuExampleTest;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
@@ -35,6 +36,11 @@ public class SWTBotTest extends AbstractMenuExampleTest {
@Test
public void waits5SecondsAndFailsForFailingCondition() throws Exception {
+ // a custom timeout could have been specified so we save it...
+ long currentTimeout = SWTBotPreferences.TIMEOUT;
+ // ...and we set it to the expected 5 seconds
+ SWTBotPreferences.TIMEOUT = 5000;
+
final long begin = System.currentTimeMillis();
try {
bot.waitUntil(new DefaultCondition() {
@@ -54,6 +60,9 @@ public class SWTBotTest extends AbstractMenuExampleTest {
assertTrue(timeout <= 6000);
assertEquals("Timeout after: 5000 ms.: timed out", expected.getMessage());
}
+
+ // and we reset the possible custom timeout
+ SWTBotPreferences.TIMEOUT = currentTimeout;
}
@Test
@@ -125,6 +134,11 @@ public class SWTBotTest extends AbstractMenuExampleTest {
@Test
public void waitsMoreThan5sWhenConditionDoesNotSwitchToFailing() {
+ // a custom timeout could have been specified so we save it...
+ long currentTimeout = SWTBotPreferences.TIMEOUT;
+ // ...and we set it to the expected 5 seconds
+ SWTBotPreferences.TIMEOUT = 5000;
+
final long begin = System.currentTimeMillis();
try {
bot.waitWhile(new DefaultCondition() {
@@ -147,6 +161,9 @@ public class SWTBotTest extends AbstractMenuExampleTest {
assertTrue(timeout <= 6000);
assertEquals("Timeout after: 5000 ms.: time out", expected.getMessage());
}
+
+ // and we reset the possible custom timeout
+ SWTBotPreferences.TIMEOUT = currentTimeout;
}
public void setUp() throws Exception {
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotExpandBarTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotExpandBarTest.java
index f664d90..2f78e28 100644
--- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotExpandBarTest.java
+++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotExpandBarTest.java
@@ -20,6 +20,7 @@ import java.util.List;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.test.AbstractControlExampleTest;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.junit.Before;
import org.junit.Test;
@@ -80,6 +81,11 @@ public class SWTBotExpandBarTest extends AbstractControlExampleTest {
@Test
public void shouldThrowExceptionWhenItemIsNotFound() throws Exception {
+ // a custom timeout could have been specified so we save it...
+ long currentTimeout = SWTBotPreferences.TIMEOUT;
+ // ...and we set it to the expected 5 seconds
+ SWTBotPreferences.TIMEOUT = 5000;
+
try {
bot.expandBar().getExpandItem(withText("some text"));
fail("Expected WNFE");
@@ -88,6 +94,9 @@ public class SWTBotExpandBarTest extends AbstractControlExampleTest {
assertEquals("Timeout after: 5000 ms.: Could not find widget matching: (of type 'ExpandItem' and with text 'some text')", e
.getCause().getMessage());
}
+
+ // and we reset the possible custom timeout
+ SWTBotPreferences.TIMEOUT = currentTimeout;
}
@Before