|
@@ -83,7 +83,7 @@ public class ViewControllerTest extends BaseTest {
|
83
|
83
|
}
|
84
|
84
|
|
85
|
85
|
@Test
|
86
|
|
- public void onAppear_WhenVisibleOnScreen() throws Exception {
|
|
86
|
+ public void onAppear_WhenShown() throws Exception {
|
87
|
87
|
ViewController spy = spy(uut);
|
88
|
88
|
spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
|
89
|
89
|
Assertions.assertThat(spy.getView()).isNotShown();
|
|
@@ -107,5 +107,20 @@ public class ViewControllerTest extends BaseTest {
|
107
|
107
|
|
108
|
108
|
verify(spy, times(1)).onAppear();
|
109
|
109
|
}
|
|
110
|
+
|
|
111
|
+ @Test
|
|
112
|
+ public void onDisappear_WhenNotShown_AfterOnAppearWasCalled() throws Exception {
|
|
113
|
+ ViewController spy = spy(uut);
|
|
114
|
+ Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
|
|
115
|
+ Assertions.assertThat(spy.getView()).isShown();
|
|
116
|
+ spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
|
|
117
|
+ verify(spy, times(1)).onAppear();
|
|
118
|
+ verify(spy, times(0)).onDisappear();
|
|
119
|
+
|
|
120
|
+ spy.getView().setVisibility(View.GONE);
|
|
121
|
+ spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
|
|
122
|
+ Assertions.assertThat(spy.getView()).isNotShown();
|
|
123
|
+ verify(spy, times(1)).onDisappear();
|
|
124
|
+ }
|
110
|
125
|
}
|
111
|
126
|
|