소스 검색

android onAppear

Daniel Zlotin 7 년 전
부모
커밋
2814f649ec
1개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  1. 10
    0
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java

+ 10
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java 파일 보기

@@ -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