Search in sources :

Example 16 with LargeTest

use of android.test.suitebuilder.annotation.LargeTest in project android_frameworks_base by ParanoidAndroid.

the class ConnectivityManagerMobileTest method testDisconnectWifi.

// Test case 4:  test disconnect Wifi
@LargeTest
public void testDisconnectWifi() {
    assertNotNull("SSID is null", mTestAccessPoint);
    // connect to Wifi
    assertTrue("failed to connect to " + mTestAccessPoint, cmActivity.connectToWifi(mTestAccessPoint));
    assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED, ConnectivityManagerTestActivity.WIFI_CONNECTION_TIMEOUT));
    // Wait for a few seconds to avoid the state that both Mobile and Wifi is connected
    sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
    NetworkInfo networkInfo;
    if (!mWifiOnlyFlag) {
        networkInfo = cmActivity.mCM.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
        cmActivity.setStateTransitionCriteria(ConnectivityManager.TYPE_MOBILE, networkInfo.getState(), NetworkState.TO_CONNECTION, State.CONNECTED);
    }
    networkInfo = cmActivity.mCM.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    cmActivity.setStateTransitionCriteria(ConnectivityManager.TYPE_WIFI, networkInfo.getState(), NetworkState.TO_DISCONNECTION, State.DISCONNECTED);
    // clear Wifi
    cmActivity.removeConfiguredNetworksAndDisableWifi();
    assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.DISCONNECTED, ConnectivityManagerTestActivity.LONG_TIMEOUT));
    if (!mWifiOnlyFlag) {
        assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_MOBILE, State.CONNECTED, ConnectivityManagerTestActivity.LONG_TIMEOUT));
    }
    // validate states
    if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_WIFI)) {
        log("Wifi state transition validation failed.");
        log("reason: " + cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_WIFI));
        assertTrue(false);
    }
    if (!mWifiOnlyFlag) {
        if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_MOBILE)) {
            log("Mobile state transition validation failed.");
            log("reason: " + cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_MOBILE));
            assertTrue(false);
        }
    }
}
Also used : NetworkInfo(android.net.NetworkInfo) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 17 with LargeTest

use of android.test.suitebuilder.annotation.LargeTest in project android_frameworks_base by ParanoidAndroid.

the class WifiAssociationTest method testWifiAssociation.

@LargeTest
public void testWifiAssociation() {
    assertNotNull("no test ssid", mSsid);
    WifiConfiguration config = new WifiConfiguration();
    config.SSID = mSsid;
    SECURITY_TYPE security = SECURITY_TYPE.valueOf(mSecurityType);
    log("Security type is " + security.toString());
    switch(security) {
        // set network configurations
        case OPEN:
            config.allowedKeyManagement.set(KeyMgmt.NONE);
            break;
        case WEP64:
            // always use hex pair for WEP-40
            assertTrue("not a WEP64 security type?", mPassword.length() == 10);
            config.allowedKeyManagement.set(KeyMgmt.NONE);
            config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
            config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
            config.allowedGroupCiphers.set(GroupCipher.WEP40);
            if (mPassword != null) {
                int length = mPassword.length();
                // WEP-40
                if (mPassword.matches("[0-9A-Fa-f]*")) {
                    config.wepKeys[0] = mPassword;
                } else {
                    fail("Please type hex pair for the password");
                }
            }
            break;
        case WEP128:
            assertNotNull("password is empty", mPassword);
            // always use hex pair for WEP-104
            assertTrue("not a WEP128 security type?", mPassword.length() == 26);
            config.allowedKeyManagement.set(KeyMgmt.NONE);
            config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
            config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
            config.allowedGroupCiphers.set(GroupCipher.WEP104);
            if (mPassword != null) {
                int length = mPassword.length();
                // WEP-40
                if (mPassword.matches("[0-9A-Fa-f]*")) {
                    config.wepKeys[0] = mPassword;
                } else {
                    fail("Please type hex pair for the password");
                }
            }
            break;
        case WPA_TKIP:
            assertNotNull("missing password", mPassword);
            config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
            config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
            config.allowedProtocols.set(Protocol.WPA);
            config.allowedPairwiseCiphers.set(PairwiseCipher.TKIP);
            config.allowedGroupCiphers.set(GroupCipher.TKIP);
            if (mPassword.matches("[0-9A-Fa-f]{64}")) {
                config.preSharedKey = mPassword;
            } else {
                config.preSharedKey = '"' + mPassword + '"';
            }
            break;
        case WPA2_AES:
            assertNotNull("missing password", mPassword);
            config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
            config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
            config.allowedProtocols.set(Protocol.RSN);
            config.allowedPairwiseCiphers.set(PairwiseCipher.CCMP);
            config.allowedGroupCiphers.set(GroupCipher.CCMP);
            config.allowedProtocols.set(Protocol.RSN);
            if (mPassword.matches("[0-9A-Fa-f]{64}")) {
                config.preSharedKey = mPassword;
            } else {
                config.preSharedKey = '"' + mPassword + '"';
            }
            break;
        default:
            fail("Not a valid security type: " + mSecurityType);
            break;
    }
    Log.v(TAG, "network config: " + config.toString());
    connectToWifi(config);
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 18 with LargeTest

use of android.test.suitebuilder.annotation.LargeTest in project android_frameworks_base by ParanoidAndroid.

the class DownloadManagerFunctionalTest method testDownloadNoWifi.

/**
     * Tests that a download set for Wifi does not progress while Wifi is disabled, but resumes
     * once Wifi is re-enabled.
     */
@LargeTest
public void testDownloadNoWifi() throws Exception {
    // wait only 60 seconds before giving up
    long timeout = 60 * 1000;
    // 140k
    int fileSize = 1024;
    byte[] blobData = generateData(fileSize, DataType.TEXT);
    setWiFiStateOn(false);
    enqueueResponse(buildResponse(HTTP_OK, blobData));
    try {
        Uri uri = getServerUri(DEFAULT_FILENAME);
        Request request = new Request(uri);
        request.setAllowedNetworkTypes(Request.NETWORK_WIFI);
        long dlRequest = mDownloadManager.enqueue(request);
        // wait for the download to complete
        boolean success = waitForDownloadOrTimeoutNoThrow(dlRequest, WAIT_FOR_DOWNLOAD_POLL_TIME, timeout);
        assertFalse("Download proceeded without Wifi connection!", success);
        setWiFiStateOn(true);
        waitForDownloadOrTimeout(dlRequest);
        assertEquals(1, mReceiver.numDownloadsCompleted());
    } finally {
        setWiFiStateOn(true);
    }
}
Also used : Request(android.app.DownloadManager.Request) Uri(android.net.Uri) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 19 with LargeTest

use of android.test.suitebuilder.annotation.LargeTest in project android_frameworks_base by ParanoidAndroid.

the class DownloadManagerFunctionalTest method testErrorHttpDataError_invalidRedirect.

/**
     * Tests the download failure error from an unhandled HTTP status code
     */
@LargeTest
public void testErrorHttpDataError_invalidRedirect() throws Exception {
    Uri uri = getServerUri(DEFAULT_FILENAME);
    final MockResponse resp = buildResponse(HTTP_REDIRECT);
    resp.setHeader("Location", "://blah.blah.blah.com");
    enqueueResponse(resp);
    doErrorTest(uri, DownloadManager.ERROR_HTTP_DATA_ERROR);
}
Also used : MockResponse(com.google.mockwebserver.MockResponse) Uri(android.net.Uri) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 20 with LargeTest

use of android.test.suitebuilder.annotation.LargeTest in project android_frameworks_base by ParanoidAndroid.

the class DownloadManagerFunctionalTest method testDownloadToExternal_fileExists.

/**
     * Tests trying to download to SD card when the file with same name already exists.
     */
@LargeTest
public void testDownloadToExternal_fileExists() throws Exception {
    File existentFile = createFileOnSD(null, 1, DataType.TEXT, null);
    byte[] blobData = generateData(DEFAULT_FILE_SIZE, DataType.TEXT);
    // Prepare the mock server with a standard response
    enqueueResponse(buildResponse(HTTP_OK, blobData));
    try {
        Uri uri = getServerUri(DEFAULT_FILENAME);
        Request request = new Request(uri);
        Uri localUri = Uri.fromFile(existentFile);
        request.setDestinationUri(localUri);
        long dlRequest = mDownloadManager.enqueue(request);
        // wait for the download to complete
        waitForDownloadOrTimeout(dlRequest);
        Cursor cursor = getCursor(dlRequest);
        try {
            verifyInt(cursor, DownloadManager.COLUMN_STATUS, DownloadManager.STATUS_SUCCESSFUL);
        } finally {
            cursor.close();
        }
    } finally {
        existentFile.delete();
    }
}
Also used : Request(android.app.DownloadManager.Request) Cursor(android.database.Cursor) File(java.io.File) Uri(android.net.Uri) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

LargeTest (android.test.suitebuilder.annotation.LargeTest)1579 AudioEffect (android.media.audiofx.AudioEffect)234 AudioTrack (android.media.AudioTrack)222 View (android.view.View)147 File (java.io.File)144 MediaVideoItem (android.media.videoeditor.MediaVideoItem)115 Uri (android.net.Uri)99 ListView (android.widget.ListView)72 Cursor (android.database.Cursor)69 Bitmap (android.graphics.Bitmap)62 Instrumentation (android.app.Instrumentation)61 MediaPlayer (android.media.MediaPlayer)60 WifiConfiguration (android.net.wifi.WifiConfiguration)53 SurfaceHolder (android.view.SurfaceHolder)50 MediaImageItem (android.media.videoeditor.MediaImageItem)49 IOException (java.io.IOException)48 AudioManager (android.media.AudioManager)42 LegacyVpnInfo (com.android.internal.net.LegacyVpnInfo)42 VpnProfile (com.android.internal.net.VpnProfile)42 Request (android.app.DownloadManager.Request)41