Browse Source

android onAppear

Daniel Zlotin 7 years ago
parent
commit
2814f649ec

+ 10
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java View File

@@ -96,6 +96,16 @@ public class ViewControllerTest extends BaseTest {
96 96
 		verify(spy, times(1)).onAppear();
97 97
 	}
98 98
 
99
+	@Test
100
+	public void onAppear_CalledAtMostOnce() throws Exception {
101
+		ViewController spy = spy(uut);
102
+		Shadows.shadowOf(spy.getView()).setMyParent(mock(ViewParent.class));
103
+		Assertions.assertThat(spy.getView()).isShown();
104
+		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
105
+		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
106
+		spy.getView().getViewTreeObserver().dispatchOnGlobalLayout();
99 107
 
108
+		verify(spy, times(1)).onAppear();
109
+	}
100 110
 }
101 111