Browse Source

Make sleep in tests throw RuntimeException to avoid try catches

Change-Id: I7ef3cca8271ae9f725d8530793543253c216e6bc
tags/8.0.0.alpha2
Artur Signell 7 years ago
parent
commit
4ee6401208

+ 6
- 3
uitest-common/src/main/java/com/vaadin/tests/tb3/AbstractTB3Test.java View File

@@ -786,12 +786,15 @@ public abstract class AbstractTB3Test extends ParallelTest {
*
* @param timeoutMillis
* Number of ms to wait
* @throws InterruptedException
*/
protected void sleep(int timeoutMillis) throws InterruptedException {
protected void sleep(int timeoutMillis) {
while (timeoutMillis > 0) {
int d = Math.min(BROWSER_TIMEOUT_IN_MS, timeoutMillis);
Thread.sleep(d);
try {
Thread.sleep(d);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
timeoutMillis -= d;

// Do something to keep the connection alive

+ 1
- 4
uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowedTest.java View File

@@ -267,10 +267,7 @@ public class ComboBoxSelectingWithNewItemsAllowedTest extends MultiBrowserTest {

private void assertInitialItemCount() {
// wait for a bit in case the count is updating
try {
sleep(1000);
} catch (InterruptedException ignore) {
}
sleep(1000);
assertThat("Wrong initial item count.", labelElement.getText(),
is("2600"));
}

+ 1
- 4
uitest/src/test/java/com/vaadin/tests/components/panel/PanelRemoveShortcutListenerTest.java View File

@@ -81,10 +81,7 @@ public class PanelRemoveShortcutListenerTest extends MultiBrowserTest {
attemptShortcut("A on");

// add a bit more delay to make sure the caption doesn't change later
try {
sleep(2000);
} catch (InterruptedException ignore) {
}
sleep(2000);

assertThat(panel.findElement(By.className("v-panel-caption"))
.findElement(By.tagName("span")).getText(), is("A on"));

+ 0
- 9
uitest/src/test/java/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceConditionTest.java View File

@@ -49,15 +49,6 @@ public class ExpandingContainerVisibleRowRaceConditionTest
assertScrollPositionIsNotVisible();
}

@Override
protected void sleep(int milliseconds) {
try {
super.sleep(milliseconds);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

private void assertFirstRowIdIs(String expected) {
List<WebElement> cellsOfFirstColumn = getCellsOfFirstColumn();
WebElement first = cellsOfFirstColumn.get(0);

+ 1
- 4
uitest/src/test/java/com/vaadin/tests/components/window/ModalWindowFocusTest.java View File

@@ -93,10 +93,7 @@ public class ModalWindowFocusTest extends MultiBrowserTest {

private void pressEscAndWait() {
new Actions(driver).sendKeys(Keys.ESCAPE).build().perform();
try {
sleep(100);
} catch (InterruptedException e) {
}
sleep(100);
}

}

+ 1
- 5
uitest/src/test/java/com/vaadin/tests/requesthandlers/AppResource404Test.java View File

@@ -48,10 +48,6 @@ public class AppResource404Test extends MultiBrowserTest {

protected void disableWaitingAndWait() {
testBench().disableWaitForVaadin();
try {
sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
sleep(500);
}
}

+ 1
- 4
uitest/src/test/java/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java View File

@@ -87,10 +87,7 @@ public abstract class MultiBrowserTestWithProxy extends MultiBrowserTest {
createProxy(getProxyPort());
break;
} catch (JSchException e) {
try {
sleep(500);
} catch (InterruptedException e1) {
}
sleep(500);
if (i == 9) {
throw new RuntimeException(
"All 10 attempts to connect a proxy failed", e);

Loading…
Cancel
Save