| 
				
			 | 
			
			
				@@ -16,8 +16,6 @@ import org.junit.Test; 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				16
			 | 
			
			
				 import org.junit.runner.RunWith; 
			 | 
		
	
		
			
			| 
				17
			 | 
			
				17
			 | 
			
			
				 import org.junit.runners.MethodSorters; 
			 | 
		
	
		
			
			| 
				18
			 | 
			
				18
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				19
			 | 
			
				
			 | 
			
			
				-import java.io.IOException; 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				19
			 | 
			
			
				 import static android.support.test.InstrumentationRegistry.getInstrumentation; 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				20
			 | 
			
			
				 import static org.assertj.core.api.Java6Assertions.assertThat; 
			 | 
		
	
		
			
			| 
				23
			 | 
			
				21
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -29,12 +27,13 @@ public class ApplicationLifecycleTest { 
			 | 
		
	
		
			
			| 
				29
			 | 
			
				27
			 | 
			
			
				     private static final long TIMEOUT = 3000; 
			 | 
		
	
		
			
			| 
				30
			 | 
			
				28
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				31
			 | 
			
				29
			 | 
			
			
				     @Before 
			 | 
		
	
		
			
			| 
				32
			 | 
			
				
			 | 
			
			
				-    public void beforeEach() { 
			 | 
		
	
		
			
			| 
				33
			 | 
			
				
			 | 
			
			
				-        // 
			 | 
		
	
		
			
			| 
				
			 | 
			
				30
			 | 
			
			
				+    public void beforeEach() throws Exception { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				31
			 | 
			
			
				+        uiDevice().wakeUp(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				32
			 | 
			
			
				+        uiDevice().setOrientationNatural(); 
			 | 
		
	
		
			
			| 
				34
			 | 
			
				33
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				35
			 | 
			
				34
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				36
			 | 
			
				35
			 | 
			
			
				     @After 
			 | 
		
	
		
			
			| 
				37
			 | 
			
				
			 | 
			
			
				-    public void afterEach() throws IOException { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				36
			 | 
			
			
				+    public void afterEach() throws Exception { 
			 | 
		
	
		
			
			| 
				38
			 | 
			
				37
			 | 
			
			
				         uiDevice().executeShellCommand("am force-stop " + PACKAGE_NAME); 
			 | 
		
	
		
			
			| 
				39
			 | 
			
				38
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				39
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -53,6 +52,7 @@ public class ApplicationLifecycleTest { 
			 | 
		
	
		
			
			| 
				53
			 | 
			
				52
			 | 
			
			
				         uiDevice().pressHome(); 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				53
			 | 
			
			
				         uiDevice().pressRecentApps(); 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				54
			 | 
			
			
				         elementByText("Playground").click(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				55
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				56
			 | 
			
			
				         assertMainShown(); 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				57
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				58
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -71,7 +71,6 @@ public class ApplicationLifecycleTest { 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				71
			 | 
			
			
				     public void _4_deviceOrientationDoesNotDestroyActivity() throws Exception { 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				72
			 | 
			
			
				         launchTheApp(); 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				73
			 | 
			
			
				         assertMainShown(); 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				74
			 | 
			
			
				         elementByText("PUSH").click(); 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				75
			 | 
			
			
				         assertExists(By.text("Pushed screen")); 
			 | 
		
	
		
			
			| 
				77
			 | 
			
				76
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -81,6 +80,19 @@ public class ApplicationLifecycleTest { 
			 | 
		
	
		
			
			| 
				81
			 | 
			
				80
			 | 
			
			
				         assertExists(By.text("Pushed screen")); 
			 | 
		
	
		
			
			| 
				82
			 | 
			
				81
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				83
			 | 
			
				82
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				83
			 | 
			
			
				+    @Test 
			 | 
		
	
		
			
			| 
				
			 | 
			
				84
			 | 
			
			
				+    public void _5_relaunchAfterActivityKilledBySystem() throws Exception { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				+        launchTheApp(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				86
			 | 
			
			
				+        assertMainShown(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				87
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				88
			 | 
			
			
				+        uiDevice().pressHome(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				89
			 | 
			
			
				+        uiDevice().executeShellCommand("am kill " + PACKAGE_NAME); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				90
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				91
			 | 
			
			
				+        uiDevice().pressRecentApps(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				92
			 | 
			
			
				+        elementByText("Playground").click(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				93
			 | 
			
			
				+        assertMainShown(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				94
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				95
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				84
			 | 
			
				96
			 | 
			
			
				     private void assertMainShown() { 
			 | 
		
	
		
			
			| 
				85
			 | 
			
				97
			 | 
			
			
				         assertExists(By.text("React Native Navigation!")); 
			 | 
		
	
		
			
			| 
				86
			 | 
			
				98
			 | 
			
			
				     } 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -98,11 +110,8 @@ public class ApplicationLifecycleTest { 
			 | 
		
	
		
			
			| 
				98
			 | 
			
				110
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				99
			 | 
			
				111
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				100
			 | 
			
				112
			 | 
			
			
				     private void launchTheApp() throws Exception { 
			 | 
		
	
		
			
			| 
				101
			 | 
			
				
			 | 
			
			
				-        uiDevice().wakeUp(); 
			 | 
		
	
		
			
			| 
				102
			 | 
			
				
			 | 
			
			
				-        uiDevice().pressHome(); 
			 | 
		
	
		
			
			| 
				103
			 | 
			
				
			 | 
			
			
				-        elementByDesc("Apps").clickAndWaitForNewWindow(); 
			 | 
		
	
		
			
			| 
				104
			 | 
			
				
			 | 
			
			
				-        scrollToText("Playground"); 
			 | 
		
	
		
			
			| 
				105
			 | 
			
				
			 | 
			
			
				-        elementByText("Playground").clickAndWaitForNewWindow(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				113
			 | 
			
			
				+        uiDevice().executeShellCommand("am start -n " + PACKAGE_NAME + "/.MainActivity"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				114
			 | 
			
			
				+        uiDevice().waitForIdle(); 
			 | 
		
	
		
			
			| 
				106
			 | 
			
				115
			 | 
			
			
				         acceptOverlayPermissionIfNeeded(); 
			 | 
		
	
		
			
			| 
				107
			 | 
			
				116
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				108
			 | 
			
				117
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -114,10 +123,6 @@ public class ApplicationLifecycleTest { 
			 | 
		
	
		
			
			| 
				114
			 | 
			
				123
			 | 
			
			
				         return uiDevice().findObject(new UiSelector().text(text)); 
			 | 
		
	
		
			
			| 
				115
			 | 
			
				124
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				116
			 | 
			
				125
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				117
			 | 
			
				
			 | 
			
			
				-    private UiObject elementByDesc(String text) { 
			 | 
		
	
		
			
			| 
				118
			 | 
			
				
			 | 
			
			
				-        return uiDevice().findObject(new UiSelector().description(text)); 
			 | 
		
	
		
			
			| 
				119
			 | 
			
				
			 | 
			
			
				-    } 
			 | 
		
	
		
			
			| 
				120
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				121
			 | 
			
				126
			 | 
			
			
				     private void scrollToText(String txt) throws Exception { 
			 | 
		
	
		
			
			| 
				122
			 | 
			
				127
			 | 
			
			
				         new UiScrollable(new UiSelector().scrollable(true)).scrollTextIntoView(txt); 
			 | 
		
	
		
			
			| 
				123
			 | 
			
				128
			 | 
			
			
				     } 
			 |