|
@@ -1057,24 +1057,39 @@ public class StackControllerTest extends BaseTest {
|
1057
|
1057
|
verify(presenter).applyChildOptions(any(), eq(component));
|
1058
|
1058
|
}
|
1059
|
1059
|
|
|
1060
|
+ @Test
|
|
1061
|
+ public void onAttachToParent_doesNotCrashWhenCalledAfterDestroy() {
|
|
1062
|
+ Robolectric.getForegroundThreadScheduler().pause();
|
|
1063
|
+ StackController spy = spy(createStack());
|
|
1064
|
+
|
|
1065
|
+ StackLayout view = spy.getView();
|
|
1066
|
+ spy.push(child1, new CommandListenerAdapter());
|
|
1067
|
+ activity.setContentView(view);
|
|
1068
|
+
|
|
1069
|
+ child1.destroy();
|
|
1070
|
+ ShadowLooper.idleMainLooper();
|
|
1071
|
+
|
|
1072
|
+ verify(spy).onAttachToParent();
|
|
1073
|
+ }
|
|
1074
|
+
|
1060
|
1075
|
private void assertContainsOnlyId(String... ids) {
|
1061
|
1076
|
assertThat(uut.size()).isEqualTo(ids.length);
|
1062
|
1077
|
assertThat(uut.getChildControllers()).extracting((Extractor<ViewController, String>) ViewController::getId).containsOnly(ids);
|
1063
|
1078
|
}
|
1064
|
1079
|
|
1065
|
1080
|
private StackController createStack() {
|
1066
|
|
- return createStack("stack", new ArrayList<>());
|
|
1081
|
+ return createStackBuilder("stack", new ArrayList<>()).build();
|
1067
|
1082
|
}
|
1068
|
1083
|
|
1069
|
1084
|
private StackController createStack(String id) {
|
1070
|
|
- return createStack(id, new ArrayList<>());
|
|
1085
|
+ return createStackBuilder(id, new ArrayList<>()).build();
|
1071
|
1086
|
}
|
1072
|
1087
|
|
1073
|
1088
|
private StackController createStack(List<ViewController> children) {
|
1074
|
|
- return createStack("stack", children);
|
|
1089
|
+ return createStackBuilder("stack", children).build();
|
1075
|
1090
|
}
|
1076
|
1091
|
|
1077
|
|
- private StackController createStack(String id, List<ViewController> children) {
|
|
1092
|
+ private StackControllerBuilder createStackBuilder(String id, List<ViewController> children) {
|
1078
|
1093
|
createTopBarController();
|
1079
|
1094
|
return TestUtils.newStackController(activity)
|
1080
|
1095
|
.setChildren(children)
|
|
@@ -1083,8 +1098,7 @@ public class StackControllerTest extends BaseTest {
|
1083
|
1098
|
.setChildRegistry(childRegistry)
|
1084
|
1099
|
.setAnimator(animator)
|
1085
|
1100
|
.setStackPresenter(presenter)
|
1086
|
|
- .setBackButtonHelper(backButtonHelper)
|
1087
|
|
- .build();
|
|
1101
|
+ .setBackButtonHelper(backButtonHelper);
|
1088
|
1102
|
}
|
1089
|
1103
|
|
1090
|
1104
|
private void createTopBarController() {
|