Skip to content

Commit bcbadec

Browse files
committed
Hardened some code
1 parent f20a184 commit bcbadec

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

maven/core-unittests/src/test/java/com/codename1/testing/TestCodenameOneImplementation.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
import java.util.function.Consumer;
6464
import java.util.function.Function;
6565

66+
import static org.junit.jupiter.api.Assertions.assertNotNull;
67+
6668
/**
6769
* Lightweight {@link CodenameOneImplementation} used by unit tests. It provides deterministic,
6870
* in-memory implementations for the storage, file system, and networking APIs that are required by
@@ -1697,22 +1699,16 @@ public void tapComponent(Component component) {
16971699

16981700
private void sendPointerEventToCurrentForm(final boolean pressed, final int x, final int y) {
16991701
final Display display = Display.getInstance();
1700-
if (display == null) {
1701-
return;
1702-
}
1702+
assertNotNull(display);
17031703

1704-
Runnable r = new Runnable() {
1705-
public void run() {
1706-
Form current = display.getCurrent();
1707-
if (current == null) {
1708-
return;
1709-
}
1704+
Runnable r = () -> {
1705+
Form current = display.getCurrent();
1706+
assertNotNull(current);
17101707

1711-
if (pressed) {
1712-
current.pointerPressed(x, y);
1713-
} else {
1714-
current.pointerReleased(x, y);
1715-
}
1708+
if (pressed) {
1709+
super.pointerPressed(x, y);
1710+
} else {
1711+
super.pointerReleased(x, y);
17161712
}
17171713
};
17181714

0 commit comments

Comments
 (0)