mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Create test that verifies ReactHost.destroy() works as expected (#37983)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37983 Create test ReactHostTest.testDestroy() that verifies ReactHost.destroy() works as expected changelog: [internal] internal Reviewed By: cortinico Differential Revision: D46813611 fbshipit-source-id: 65432dae1b69412af3dec23265f57f73d49cca68
This commit is contained in:
committed by
Facebook GitHub Bot
parent
93ec2206e3
commit
de786cddbc
+13
@@ -124,6 +124,10 @@ public class ReactHostTest {
|
||||
|
||||
@Test
|
||||
public void testStart() throws Exception {
|
||||
statAndTestReactHost();
|
||||
}
|
||||
|
||||
private void statAndTestReactHost() throws Exception {
|
||||
TaskCompletionSource<Boolean> taskCompletionSource = new TaskCompletionSource<>();
|
||||
taskCompletionSource.setResult(true);
|
||||
whenNew(TaskCompletionSource.class).withAnyArguments().thenReturn(taskCompletionSource);
|
||||
@@ -137,6 +141,15 @@ public class ReactHostTest {
|
||||
verify(mMemoryPressureRouter).addMemoryPressureListener((MemoryPressureListener) any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDestroy() throws Exception {
|
||||
statAndTestReactHost();
|
||||
|
||||
waitForTaskUIThread(mReactHost.destroy("Destroying from testing infra", null));
|
||||
assertThat(mReactHost.isInstanceInitialized()).isFalse();
|
||||
assertThat(mReactHost.getCurrentReactContext()).isNull();
|
||||
}
|
||||
|
||||
private static <T> void waitForTaskUIThread(Task<T> task) throws InterruptedException {
|
||||
boolean isTaskCompleted = false;
|
||||
while (!isTaskCompleted) {
|
||||
|
||||
Reference in New Issue
Block a user