forked from wix/react-native-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UiThreadTest.java
29 lines (24 loc) · 817 Bytes
/
UiThreadTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.reactnativenavigation.utils;
import com.reactnativenavigation.*;
import org.junit.*;
import org.robolectric.shadows.*;
import static org.mockito.Mockito.*;
public class UiThreadTest extends BaseTest {
@Test
public void postOnUiThread() throws Exception {
Runnable task = mock(Runnable.class);
ShadowLooper.pauseMainLooper();
UiThread.post(task);
verifyNoInteractions(task);
ShadowLooper.runUiThreadTasks();
verify(task, times(1)).run();
}
@Test
public void postDelayedOnUiThread() throws Exception {
Runnable task = mock(Runnable.class);
UiThread.postDelayed(task, 1000);
verifyNoInteractions(task);
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
verify(task, times(1)).run();
}
}