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

+ 1
- 1
playground/package.json View File

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

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

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