Ver código fonte

e2e android initial

Daniel Zlotin 8 anos atrás
pai
commit
5d43e6a9bd

+ 0
- 17
AndroidE2E/app/build.gradle Ver arquivo

24
     androidTestCompile 'com.android.support.test:rules:0.5'
24
     androidTestCompile 'com.android.support.test:rules:0.5'
25
     androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
25
     androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
26
 }
26
 }
27
-
28
-task reinstallNavigation {
29
-    shell("cd ../../playground/ && yarn run uninstall-android && yarn run android");
30
-}
31
-
32
-def shell(cmd) {
33
-    exec {
34
-        executable "sh"
35
-        args "-c", "$cmd"
36
-    }
37
-}
38
-
39
-tasks.whenTaskAdded { task ->
40
-    if (task.name == 'connectedAndroidTest') {
41
-        task.dependsOn reinstallNavigation
42
-    }
43
-}

+ 11
- 14
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ApplicationLifecycleTest.java Ver arquivo

2
 
2
 
3
 import android.annotation.TargetApi;
3
 import android.annotation.TargetApi;
4
 import android.content.Intent;
4
 import android.content.Intent;
5
-import android.provider.Settings;
6
 import android.support.test.filters.SdkSuppress;
5
 import android.support.test.filters.SdkSuppress;
7
 import android.support.test.runner.AndroidJUnit4;
6
 import android.support.test.runner.AndroidJUnit4;
8
 import android.support.test.uiautomator.UiDevice;
7
 import android.support.test.uiautomator.UiDevice;
9
-import android.support.test.uiautomator.UiSelector;
10
 
8
 
11
 import org.junit.Test;
9
 import org.junit.Test;
12
 import org.junit.runner.RunWith;
10
 import org.junit.runner.RunWith;
21
     @Test
19
     @Test
22
     public void showSplash_AcceptsOverlayPermissions_ShowsWelcomeScreen() throws Exception {
20
     public void showSplash_AcceptsOverlayPermissions_ShowsWelcomeScreen() throws Exception {
23
         launchTheApp();
21
         launchTheApp();
24
-        Thread.sleep(2000);
25
 //        assertThat(rule.getActivity().getContentView()).isNotNull().isInstanceOf(NavigationSplashView.class);
22
 //        assertThat(rule.getActivity().getContentView()).isNotNull().isInstanceOf(NavigationSplashView.class);
26
 //        acceptOverlayPermissionIfNeeded();
23
 //        acceptOverlayPermissionIfNeeded();
27
 //        assertMainShown();
24
 //        assertMainShown();
28
     }
25
     }
29
 
26
 
30
-    private void acceptOverlayPermissionIfNeeded() throws Exception {
31
-        if (Settings.canDrawOverlays(getInstrumentation().getTargetContext())) {
32
-            return;
33
-        }
34
-        uiDevice().waitForIdle();
35
-        uiDevice().findObject(new UiSelector().text("Playground")).click();
36
-        uiDevice().findObject(new UiSelector().text("Permit drawing over other apps")).click();
37
-        uiDevice().pressBack();
38
-        uiDevice().pressBack();
39
-    }
27
+//    private void acceptOverlayPermissionIfNeeded() throws Exception {
28
+//        if (Settings.canDrawOverlays(getInstrumentation().getTargetContext())) {
29
+//            return;
30
+//        }
31
+//        uiDevice().waitForIdle();
32
+//        uiDevice().findObject(new UiSelector().text("Playground")).click();
33
+//        uiDevice().findObject(new UiSelector().text("Permit drawing over other apps")).click();
34
+//        uiDevice().pressBack();
35
+//        uiDevice().pressBack();
36
+//    }
37
+//        uiDevice().findObject(new UiSelector().description("Apps")).clickAndWaitForNewWindow();
40
 
38
 
41
     private void launchTheApp() throws Exception {
39
     private void launchTheApp() throws Exception {
42
-//        uiDevice().findObject(new UiSelector().description("Apps")).clickAndWaitForNewWindow();
43
         uiDevice().wakeUp();
40
         uiDevice().wakeUp();
44
         uiDevice().pressHome();
41
         uiDevice().pressHome();
45
         uiDevice().waitForIdle();
42
         uiDevice().waitForIdle();

+ 3
- 5
playground/scripts/e2e.android.js Ver arquivo

10
 }
10
 }
11
 
11
 
12
 function e2e() {
12
 function e2e() {
13
-  shellUtils.exec.execSync(`cd android && ./gradlew uninstallAll`);
14
-  shellUtils.exec.execSync(`cd android && ./gradlew connectedDebugAndroidTest`);
13
+  shellUtils.exec.execSync(`yarn run uninstall-android`);
14
+  shellUtils.exec.execSync(`yarn run android`);
15
+  shellUtils.exec.execSync(`cd ../AndroidE2e/ && ./gradlew connectedDebugAndroidTest`);
15
 }
16
 }
16
 
17
 
17
 function run() {
18
 function run() {
18
   shellUtils.exec.execSync(`echo 'travis_fold:start:android-e2e'`);
19
   shellUtils.exec.execSync(`echo 'travis_fold:start:android-e2e'`);
19
   try {
20
   try {
20
-    if (process.env.CI) {
21
-      runEmulator();
22
-    }
23
     e2e();
21
     e2e();
24
   } finally {
22
   } finally {
25
     shellUtils.exec.execSync(`echo 'travis_fold:end:android-e2e'`);
23
     shellUtils.exec.execSync(`echo 'travis_fold:end:android-e2e'`);

+ 1
- 0
scripts/test.android.js Ver arquivo

4
   if (process.env.CI) {
4
   if (process.env.CI) {
5
     exec.execSync(`./scripts/installAndroidSDK.sh`);
5
     exec.execSync(`./scripts/installAndroidSDK.sh`);
6
   }
6
   }
7
+
7
   exec.execSync(`cd android && ./gradlew clean testDebugUnitTest`);
8
   exec.execSync(`cd android && ./gradlew clean testDebugUnitTest`);
8
 }
9
 }
9
 
10