|
@@ -1,11 +1,16 @@
|
1
|
1
|
package com.reactnativenavigation.e2e.androide2e;
|
2
|
2
|
|
|
3
|
+import android.content.Intent;
|
|
4
|
+import android.net.Uri;
|
|
5
|
+import android.provider.Settings;
|
3
|
6
|
import android.support.test.uiautomator.By;
|
4
|
7
|
|
5
|
8
|
import org.junit.FixMethodOrder;
|
6
|
9
|
import org.junit.Test;
|
7
|
10
|
import org.junit.runners.MethodSorters;
|
8
|
11
|
|
|
12
|
+import static android.support.test.InstrumentationRegistry.getInstrumentation;
|
|
13
|
+
|
9
|
14
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
10
|
15
|
public class ApplicationLifecycleTest extends BaseTest {
|
11
|
16
|
|
|
@@ -59,12 +64,37 @@ public class ApplicationLifecycleTest extends BaseTest {
|
59
|
64
|
elementByText("PUSH").click();
|
60
|
65
|
assertExists(By.text("Pushed Screen"));
|
61
|
66
|
|
62
|
|
- device().pressHome();
|
63
|
|
- device().waitForIdle();
|
64
|
|
- device().executeShellCommand("am kill " + PACKAGE_NAME);
|
|
67
|
+ killAppSaveInstanceState_ByTogglingPermissions();
|
65
|
68
|
|
66
|
69
|
device().pressRecentApps();
|
67
|
70
|
elementByText("Playground").click();
|
68
|
71
|
assertMainShown();
|
69
|
72
|
}
|
|
73
|
+
|
|
74
|
+ private void killAppSaveInstanceState_ByTogglingPermissions() throws Exception {
|
|
75
|
+ device().pressHome();
|
|
76
|
+
|
|
77
|
+ device().waitForIdle();
|
|
78
|
+ launchAppInfoSettings();
|
|
79
|
+ device().waitForIdle();
|
|
80
|
+
|
|
81
|
+ elementByText("Permissions").click();
|
|
82
|
+ elementByText("Storage").click();
|
|
83
|
+ elementByText("Storage").click();
|
|
84
|
+ device().pressBack();
|
|
85
|
+ device().pressBack();
|
|
86
|
+ device().pressHome();
|
|
87
|
+ device().waitForIdle();
|
|
88
|
+ }
|
|
89
|
+
|
|
90
|
+ private void launchAppInfoSettings() {
|
|
91
|
+ Intent intent = new Intent();
|
|
92
|
+ intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
|
93
|
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
94
|
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
95
|
+ intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
96
|
+ Uri uri = Uri.fromParts("package", PACKAGE_NAME, null);
|
|
97
|
+ intent.setData(uri);
|
|
98
|
+ getInstrumentation().getTargetContext().startActivity(intent);
|
|
99
|
+ }
|
70
|
100
|
}
|