@@ -7,6 +7,10 @@ import junit.framework.TestCase.assertNotNull
77import junit.framework.TestCase.assertTrue
88import org.junit.Test
99import org.junit.runner.RunWith
10+ import com.facebook.testing.screenshot.ViewHelpers
11+ import com.facebook.testing.screenshot.Screenshot
12+ import org.junit.Assert.*;
13+ import com.facebook.react.interfaces.*
1014
1115@RunWith(AndroidJUnit4 ::class )
1216class IsolatedTest {
@@ -20,7 +24,32 @@ class IsolatedTest {
2024 val context = InstrumentationRegistry .getInstrumentation().targetContext
2125 val app = context.applicationContext as MainApplication
2226 val surface = app.reactHost.createSurface(context, " SimpleTestComponent" , null )
23- surface.start()
27+ assertEquals(" SimpleTestComponent" , surface.moduleName)
28+
29+ // TODO: we aren't 100% sure if prerender() and start() are being called the way we want it to.
30+ // We probably want to create a ReactHost directly instead of taking it from the MainApplication... probably
31+ // Also look up bridge-less mode.
32+ assertGoodTask(surface.prerender())
33+
34+
2435 assertNotNull(surface.view)
36+
37+ ViewHelpers .setupView(surface.view!! )
38+ .setExactHeightPx(1000 )
39+ .setExactWidthPx(1000 )
40+ .layout()
41+
42+
43+ val ti = surface.start()
44+ assertGoodTask(ti)
45+
46+ Screenshot .snap(surface.view!! )
47+ .record()
2548 }
2649}
50+
51+ fun assertGoodTask (ti : TaskInterface <Void >) {
52+ ti.waitForCompletion()
53+ assertFalse(ti.isFaulted())
54+ assertTrue(ti.isCompleted())
55+ }
0 commit comments