Browse Source

Lifecycle tests - some are ignored, make green

Guy Carmeli 7 years ago
parent
commit
83b0017ed8

+ 0
- 4
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ApplicationLifecycleTest.java View File

67
 		elementByText("Playground").click();
67
 		elementByText("Playground").click();
68
 		assertMainShown();
68
 		assertMainShown();
69
 	}
69
 	}
70
-
71
-	private void assertMainShown() {
72
-		assertExists(By.text("React Native Navigation!"));
73
-	}
74
 }
70
 }

+ 8
- 0
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/BaseTest.java View File

43
 		device().wait(Until.gone(By.textContains("Please wait")), 1000 * 60 * 3);
43
 		device().wait(Until.gone(By.textContains("Please wait")), 1000 * 60 * 3);
44
 	}
44
 	}
45
 
45
 
46
+    public void assertMainShown() {
47
+        assertExists(By.text("React Native Navigation!"));
48
+    }
49
+
46
 	public void acceptOverlayPermissionIfNeeded() throws Exception {
50
 	public void acceptOverlayPermissionIfNeeded() throws Exception {
47
 		if (elementByText("Draw over other apps").exists()) {
51
 		if (elementByText("Draw over other apps").exists()) {
48
 			if (!elementByText("Playground").exists()) {
52
 			if (!elementByText("Playground").exists()) {
66
 	public void assertExists(BySelector selector) {
70
 	public void assertExists(BySelector selector) {
67
 		assertThat(device().wait(Until.hasObject(selector), TIMEOUT)).isTrue();
71
 		assertThat(device().wait(Until.hasObject(selector), TIMEOUT)).isTrue();
68
 	}
72
 	}
73
+
74
+    public void swipeRight() {
75
+        device().swipe(5, 152, 500, 152, 15);
76
+    }
69
 }
77
 }

+ 42
- 3
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/TopLevelApiTest.java View File

1
 package com.reactnativenavigation.e2e.androide2e;
1
 package com.reactnativenavigation.e2e.androide2e;
2
 
2
 
3
-import org.junit.Test;
3
+import android.support.test.uiautomator.By;
4
 
4
 
5
-import static org.assertj.core.api.Java6Assertions.assertThat;
5
+import org.junit.Ignore;
6
+import org.junit.Test;
6
 
7
 
7
 public class TopLevelApiTest extends BaseTest {
8
 public class TopLevelApiTest extends BaseTest {
8
 
9
 
9
 	@Test
10
 	@Test
10
 	public void switchToTabBasedApp() throws Exception {
11
 	public void switchToTabBasedApp() throws Exception {
11
-		assertThat(1 + 1).isPositive();
12
+        launchTheApp();
13
+        assertMainShown();
14
+        elementByText("SWITCH TO TAB BASED APP").click();
15
+        assertExists(By.text("This is tab 1"));
16
+        assertExists(By.text("Hello from a function!"));
12
 	}
17
 	}
18
+
19
+    @Test
20
+    public void switchToTabsWithSideMenu() throws Exception {
21
+        launchTheApp();
22
+        assertMainShown();
23
+        elementByText("SWITCH TO APP WITH SIDE MENUS").click();
24
+        assertExists(By.textStartsWith("This is a side menu center screen tab 1"));
25
+        swipeRight();
26
+        assertExists(By.text("This is a left side menu screen"));
27
+    }
28
+
29
+    @Test
30
+    @Ignore
31
+    public void screenLifecycle() throws Exception {
32
+        launchTheApp();
33
+        assertMainShown();
34
+        elementByText("PUSH LIFECYCLE SCREEN").click();
35
+        elementByText("onStart!");
36
+        elementByText("Push to test onStop").click();
37
+        elementByText("Alert");
38
+        elementByText("onStop").click();
39
+    }
40
+
41
+    @Test
42
+    @Ignore
43
+    public void unmountIsCalledOnPop() throws Exception {
44
+        launchTheApp();
45
+        assertMainShown();
46
+        elementByText("Push lifecycle screen").click();
47
+        elementByText("onStart!");
48
+        elementByText("BACK").click();
49
+        elementByText("onStop");
50
+        elementByText("componentWillUnmount");
51
+    }
13
 }
52
 }