File tree 1 file changed +8
-2
lines changed
core/src/androidTest/java/com/amplifyframework/devmenu
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 29
29
import org .junit .Before ;
30
30
import org .junit .Test ;
31
31
32
+ import java .util .concurrent .CountDownLatch ;
33
+
32
34
import static androidx .test .espresso .Espresso .onView ;
33
35
import static org .junit .Assert .assertEquals ;
34
36
import static org .junit .Assert .assertNotNull ;
38
40
*/
39
41
public final class DevMenuMainViewInstrumentationTest {
40
42
// A navigation host controller for testing.
41
- private TestNavHostController navHostController ;
43
+ private volatile TestNavHostController navHostController ;
42
44
43
45
/**
44
46
* Go to the main screen of the developer menu.
47
+ * @throws Exception if fragment doesn't attach
45
48
*/
46
49
@ Before
47
- public void resetView () {
50
+ public void resetView () throws Exception {
51
+ CountDownLatch latch = new CountDownLatch (1 );
48
52
FragmentScenario <DevMenuMainFragment > mainMenuScenario =
49
53
FragmentScenario .launchInContainer (DevMenuMainFragment .class );
50
54
mainMenuScenario .onFragment (fragment -> {
51
55
navHostController = new TestNavHostController (ApplicationProvider .getApplicationContext ());
52
56
navHostController .setGraph (R .navigation .dev_menu_nav_graph );
53
57
Navigation .setViewNavController (fragment .requireView (), navHostController );
58
+ latch .countDown ();
54
59
});
60
+ latch .await ();
55
61
}
56
62
57
63
You can’t perform that action at this time.
0 commit comments