Skip to content

Commit c001241

Browse files
author
jmhofer
committed
Tested whether the actions are really executed in the EDT.
1 parent 4fdb947 commit c001241

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

extensions/rxjava-swing/src/main/java/rx/concurrency/SwingScheduler.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package rx.concurrency;
1717

18+
import static org.junit.Assert.assertTrue;
1819
import static org.mockito.Mockito.*;
1920

2021
import java.awt.EventQueue;
@@ -23,6 +24,7 @@
2324
import java.util.concurrent.TimeUnit;
2425
import java.util.concurrent.atomic.AtomicReference;
2526

27+
import javax.swing.SwingUtilities;
2628
import javax.swing.Timer;
2729

2830
import org.junit.Rule;
@@ -187,6 +189,7 @@ public void testPeriodicScheduling() throws Exception {
187189
@Override
188190
public Subscription call() {
189191
innerAction.call();
192+
assertTrue(SwingUtilities.isEventDispatchThread());
190193
return Subscriptions.create(unsubscribe);
191194
}
192195
};
@@ -215,13 +218,15 @@ public void testNestedActions() throws Exception {
215218
final Action0 firstAction = new Action0() {
216219
@Override
217220
public void call() {
221+
assertTrue(SwingUtilities.isEventDispatchThread());
218222
firstStepStart.call();
219223
firstStepEnd.call();
220224
}
221225
};
222226
final Action0 secondAction = new Action0() {
223227
@Override
224228
public void call() {
229+
assertTrue(SwingUtilities.isEventDispatchThread());
225230
secondStepStart.call();
226231
scheduler.schedule(firstAction);
227232
secondStepEnd.call();
@@ -230,6 +235,7 @@ public void call() {
230235
final Action0 thirdAction = new Action0() {
231236
@Override
232237
public void call() {
238+
assertTrue(SwingUtilities.isEventDispatchThread());
233239
thirdStepStart.call();
234240
scheduler.schedule(secondAction);
235241
thirdStepEnd.call();

0 commit comments

Comments
 (0)