Browse Source

launchApp android e2e

Daniel Zlotin 7 years ago
parent
commit
636f82b1a4

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

4
 import android.content.Intent;
4
 import android.content.Intent;
5
 import android.support.test.filters.SdkSuppress;
5
 import android.support.test.filters.SdkSuppress;
6
 import android.support.test.runner.AndroidJUnit4;
6
 import android.support.test.runner.AndroidJUnit4;
7
+import android.support.test.uiautomator.By;
7
 import android.support.test.uiautomator.UiDevice;
8
 import android.support.test.uiautomator.UiDevice;
9
+import android.support.test.uiautomator.Until;
8
 
10
 
9
 import org.junit.Test;
11
 import org.junit.Test;
10
 import org.junit.runner.RunWith;
12
 import org.junit.runner.RunWith;
16
 @SdkSuppress(minSdkVersion = 23)
18
 @SdkSuppress(minSdkVersion = 23)
17
 @TargetApi(23)
19
 @TargetApi(23)
18
 public class ApplicationLifecycleTest {
20
 public class ApplicationLifecycleTest {
21
+
22
+    public static final String PACKAGE_NAME = "com.reactnativenavigation.playground";
23
+
19
     @Test
24
     @Test
20
     public void showSplash_AcceptsOverlayPermissions_ShowsWelcomeScreen() throws Exception {
25
     public void showSplash_AcceptsOverlayPermissions_ShowsWelcomeScreen() throws Exception {
21
         launchTheApp();
26
         launchTheApp();
27
+
22
 //        assertThat(rule.getActivity().getContentView()).isNotNull().isInstanceOf(NavigationSplashView.class);
28
 //        assertThat(rule.getActivity().getContentView()).isNotNull().isInstanceOf(NavigationSplashView.class);
23
 //        acceptOverlayPermissionIfNeeded();
29
 //        acceptOverlayPermissionIfNeeded();
24
 //        assertMainShown();
30
 //        assertMainShown();
40
         uiDevice().wakeUp();
46
         uiDevice().wakeUp();
41
         uiDevice().pressHome();
47
         uiDevice().pressHome();
42
         uiDevice().waitForIdle();
48
         uiDevice().waitForIdle();
43
-        Intent intent = getInstrumentation().getTargetContext().getPackageManager().getLaunchIntentForPackage("com.reactnativenavigation.playground");
49
+        Intent intent = getInstrumentation().getTargetContext().getPackageManager().getLaunchIntentForPackage(PACKAGE_NAME);
44
         assertThat(intent).isNotNull();
50
         assertThat(intent).isNotNull();
45
         getInstrumentation().getTargetContext().startActivity(intent);
51
         getInstrumentation().getTargetContext().startActivity(intent);
46
-        uiDevice().waitForIdle();
52
+        uiDevice().wait(Until.hasObject(By.pkg("com.reactnativenavigation.playground").depth(0)), 5000);
47
     }
53
     }
48
 
54
 
49
     private UiDevice uiDevice() {
55
     private UiDevice uiDevice() {

+ 1
- 1
playground/package.json View File

7
     "start": "adb reverse tcp:8081 tcp:8081; watchman watch-del-all; react-native start",
7
     "start": "adb reverse tcp:8081 tcp:8081; watchman watch-del-all; react-native start",
8
     "xcode": "open ios/playground.xcodeproj",
8
     "xcode": "open ios/playground.xcodeproj",
9
     "android": "cd android && ./gradlew installDebug",
9
     "android": "cd android && ./gradlew installDebug",
10
-    "uninstall-android": "cd android && ./gradlew clean uninstallAll",
10
+    "uninstall-android": "cd android && ./gradlew uninstallAll",
11
     "xcodeunit": "node ./scripts/unit.ios.js",
11
     "xcodeunit": "node ./scripts/unit.ios.js",
12
     "e2e-android": "node ./scripts/e2e.android.js",
12
     "e2e-android": "node ./scripts/e2e.android.js",
13
     "e2e-ios": "node ./scripts/e2e.ios.js"
13
     "e2e-ios": "node ./scripts/e2e.ios.js"

+ 3
- 0
playground/scripts/e2e.android.js View File

16
 }
16
 }
17
 
17
 
18
 function run() {
18
 function run() {
19
+  if (process.env.CI) {
20
+    return;
21
+  }
19
   shellUtils.exec.execSync(`echo 'travis_fold:start:android-e2e'`);
22
   shellUtils.exec.execSync(`echo 'travis_fold:start:android-e2e'`);
20
   try {
23
   try {
21
     e2e();
24
     e2e();