|
@@ -122,5 +122,18 @@ public class ViewControllerTest extends BaseTest {
|
122
|
122
|
Assertions.assertThat(spy.getView()).isNotShown();
|
123
|
123
|
verify(spy, times(1)).onDisappear();
|
124
|
124
|
}
|
|
125
|
+
|
|
126
|
+ @Test
|
|
127
|
+ public void onDisappear_CalledAtMostOnce() throws Exception {
|
|
128
|
+ ViewController spy = spy(uut);
|
|
129
|
+ Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
|
|
130
|
+ Assertions.assertThat(spy.getView()).isShown();
|
|
131
|
+ spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
|
|
132
|
+ spy.getView().setVisibility(View.GONE);
|
|
133
|
+ spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
|
|
134
|
+ spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
|
|
135
|
+ spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
|
|
136
|
+ verify(spy, times(1)).onDisappear();
|
|
137
|
+ }
|
125
|
138
|
}
|
126
|
139
|
|