Loading services/tests/servicestests/src/com/android/server/net/ConnOnActivityStartTest.java +25 −4 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.server.net; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.android.frameworks.servicestests.R; import com.android.servicestests.aidl.ICmdReceiverService; Loading @@ -42,6 +41,7 @@ import android.support.test.uiautomator.UiDevice; import android.util.Log; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -81,7 +81,7 @@ public class ConnOnActivityStartTest { private static final long NETWORK_CHECK_TIMEOUT_MS = 4000; // 4 sec private static final long SCREEN_ON_DELAY_MS = 500; // 0.5 sec private static final long SCREEN_ON_DELAY_MS = 1000; // 1 sec private static final long BIND_SERVICE_TIMEOUT_SEC = 4; Loading Loading @@ -348,13 +348,17 @@ public class ConnOnActivityStartTest { } private String executeCommand(String cmd) throws IOException { final String result = mUiDevice.executeShellCommand(cmd).trim(); final String result = executeSilentCommand(cmd); Log.d(TAG, String.format("Result for '%s': %s", cmd, result)); return result; } private static String executeSilentCommand(String cmd) throws IOException { return mUiDevice.executeShellCommand(cmd).trim(); } private void assertDelayedCommandResult(String cmd, String expectedResult, int maxTries, int napTimeMs) throws IOException { int maxTries, int napTimeMs) throws Exception { String result = ""; for (int i = 1; i <= maxTries; ++i) { result = executeCommand(cmd); Loading Loading @@ -394,6 +398,23 @@ public class ConnOnActivityStartTest { } } private static void fail(String msg) throws Exception { dumpOnFailure(); Assert.fail(msg); } private static void dumpOnFailure() throws Exception { Log.d(TAG, ">>> Begin network_management dump"); Log.printlns(Log.LOG_ID_MAIN, Log.DEBUG, TAG, executeSilentCommand("dumpsys network_management"), null); Log.d(TAG, "<<< End network_management dump"); Log.d(TAG, ">>> Begin netpolicy dump"); Log.printlns(Log.LOG_ID_MAIN, Log.DEBUG, TAG, executeSilentCommand("dumpsys netpolicy"), null); Log.d(TAG, "<<< End netpolicy dump"); } private void finishActivity() throws Exception { mCmdReceiverService.finishActivity(); } Loading services/tests/servicestests/test-apps/ConnTestApp/src/com/android/servicestests/apps/conntestapp/ConnTestActivity.java +1 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ public class ConnTestActivity extends Activity { Log.i(TAG, "onStop called"); if (finishCommandReceiver != null) { unregisterReceiver(finishCommandReceiver); finishCommandReceiver = null; } super.onStop(); } Loading Loading
services/tests/servicestests/src/com/android/server/net/ConnOnActivityStartTest.java +25 −4 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.server.net; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.android.frameworks.servicestests.R; import com.android.servicestests.aidl.ICmdReceiverService; Loading @@ -42,6 +41,7 @@ import android.support.test.uiautomator.UiDevice; import android.util.Log; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -81,7 +81,7 @@ public class ConnOnActivityStartTest { private static final long NETWORK_CHECK_TIMEOUT_MS = 4000; // 4 sec private static final long SCREEN_ON_DELAY_MS = 500; // 0.5 sec private static final long SCREEN_ON_DELAY_MS = 1000; // 1 sec private static final long BIND_SERVICE_TIMEOUT_SEC = 4; Loading Loading @@ -348,13 +348,17 @@ public class ConnOnActivityStartTest { } private String executeCommand(String cmd) throws IOException { final String result = mUiDevice.executeShellCommand(cmd).trim(); final String result = executeSilentCommand(cmd); Log.d(TAG, String.format("Result for '%s': %s", cmd, result)); return result; } private static String executeSilentCommand(String cmd) throws IOException { return mUiDevice.executeShellCommand(cmd).trim(); } private void assertDelayedCommandResult(String cmd, String expectedResult, int maxTries, int napTimeMs) throws IOException { int maxTries, int napTimeMs) throws Exception { String result = ""; for (int i = 1; i <= maxTries; ++i) { result = executeCommand(cmd); Loading Loading @@ -394,6 +398,23 @@ public class ConnOnActivityStartTest { } } private static void fail(String msg) throws Exception { dumpOnFailure(); Assert.fail(msg); } private static void dumpOnFailure() throws Exception { Log.d(TAG, ">>> Begin network_management dump"); Log.printlns(Log.LOG_ID_MAIN, Log.DEBUG, TAG, executeSilentCommand("dumpsys network_management"), null); Log.d(TAG, "<<< End network_management dump"); Log.d(TAG, ">>> Begin netpolicy dump"); Log.printlns(Log.LOG_ID_MAIN, Log.DEBUG, TAG, executeSilentCommand("dumpsys netpolicy"), null); Log.d(TAG, "<<< End netpolicy dump"); } private void finishActivity() throws Exception { mCmdReceiverService.finishActivity(); } Loading
services/tests/servicestests/test-apps/ConnTestApp/src/com/android/servicestests/apps/conntestapp/ConnTestActivity.java +1 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ public class ConnTestActivity extends Activity { Log.i(TAG, "onStop called"); if (finishCommandReceiver != null) { unregisterReceiver(finishCommandReceiver); finishCommandReceiver = null; } super.onStop(); } Loading