Search in sources :

Example 21 with LargeTest

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

the class DownloadManagerFunctionalTest method testSetTitle.

/**
     * Tests that we can set the title of a download.
     */
@LargeTest
public void testSetTitle() throws Exception {
    int fileSize = 1024;
    byte[] blobData = generateData(fileSize, DataType.BINARY);
    enqueueResponse(buildResponse(HTTP_OK, blobData));
    // An arbitrary unicode string title
    final String title = "¥123;\"ŒŽ Ջ ਇ 쳠 栠Ψ尴" + "ඩ샅솨  #\'";
    Uri uri = getServerUri(DEFAULT_FILENAME);
    Request request = new Request(uri);
    request.setTitle(title);
    long dlRequest = mDownloadManager.enqueue(request);
    waitForDownloadOrTimeout(dlRequest);
    Cursor cursor = getCursor(dlRequest);
    try {
        verifyString(cursor, DownloadManager.COLUMN_TITLE, title);
    } finally {
        cursor.close();
    }
}
Also used : Request(android.app.DownloadManager.Request) Cursor(android.database.Cursor) Uri(android.net.Uri) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 22 with LargeTest

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

the class DownloadManagerStressTest method testDownloadLargeFile.

/**
     * Tests trying to download a large file (50M bytes).
     */
@LargeTest
public void testDownloadLargeFile() throws Exception {
    // note: kept relatively small to not exceed /cache dir size
    long fileSize = 50000000L;
    Log.i(TAG, "creating a file of size: " + fileSize);
    File largeFile = createFileOnSD(null, fileSize, DataType.TEXT, null);
    Log.i(TAG, "DONE creating a file of size: " + fileSize);
    MultipleDownloadsCompletedReceiver receiver = registerNewMultipleDownloadsReceiver();
    try {
        long dlRequest = doStandardEnqueue(largeFile);
        // wait for the download to complete
        waitForDownloadOrTimeout(dlRequest);
        ParcelFileDescriptor pfd = mDownloadManager.openDownloadedFile(dlRequest);
        verifyFileContents(pfd, largeFile);
        verifyFileSize(pfd, largeFile.length());
        assertEquals(1, receiver.numDownloadsCompleted());
        mContext.unregisterReceiver(receiver);
    } catch (Exception e) {
        throw e;
    } finally {
        largeFile.delete();
    }
}
Also used : ParcelFileDescriptor(android.os.ParcelFileDescriptor) File(java.io.File) IOException(java.io.IOException) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 23 with LargeTest

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

the class SearchManagerTest method testSearchManagerAvailable.

/**
     * The goal of this test is to confirm that we can obtain
     * a search manager at any time, and that for any given context,
     * it is a singleton.
     */
@LargeTest
public void testSearchManagerAvailable() {
    SearchManager searchManager1 = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
    assertNotNull(searchManager1);
    SearchManager searchManager2 = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
    assertNotNull(searchManager2);
    assertSame(searchManager1, searchManager2);
}
Also used : ISearchManager(android.app.ISearchManager) SearchManager(android.app.SearchManager) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 24 with LargeTest

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

the class DatabaseCursorTest method testManyRowsLong.

@LargeTest
public void testManyRowsLong() throws Exception {
    mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data INT);");
    final int count = 36799;
    mDatabase.execSQL("BEGIN Transaction;");
    for (int i = 0; i < count; i++) {
        mDatabase.execSQL("INSERT INTO test (data) VALUES (" + i + ");");
    }
    mDatabase.execSQL("COMMIT;");
    Cursor c = mDatabase.query("test", new String[] { "data" }, null, null, null, null, null);
    assertNotNull(c);
    int i = 0;
    while (c.moveToNext()) {
        assertEquals(i, c.getInt(0));
        i++;
    }
    assertEquals(count, i);
    assertEquals(count, c.getCount());
    Log.d("testManyRows", "count " + Integer.toString(i));
    c.close();
}
Also used : SQLiteCursor(android.database.sqlite.SQLiteCursor) Cursor(android.database.Cursor) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 25 with LargeTest

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

the class DatabaseCursorTest method testCursorWindowFailureWhenTooManyCursorWindowsLeftOpen.

/**
     * sometimes CursorWindow creation fails due to non-availability of memory create
     * another CursorWindow object. One of the scenarios of its occurrence is when
     * there are too many CursorWindow objects already opened by the process.
     * This test is for that scenario.
     */
@LargeTest
public void testCursorWindowFailureWhenTooManyCursorWindowsLeftOpen() {
    mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data TEXT);");
    mDatabase.execSQL("INSERT INTO test values(1, 'test');");
    int N = 1024;
    ArrayList<Cursor> cursorList = new ArrayList<Cursor>();
    // open many cursors until a failure occurs
    for (int i = 0; i < N; i++) {
        try {
            Cursor cursor = mDatabase.rawQuery("select * from test", null);
            cursor.getCount();
            cursorList.add(cursor);
        } catch (CursorWindowAllocationException e) {
            // got the exception we wanted
            break;
        } catch (Exception e) {
            fail("unexpected exception: " + e.getMessage());
            e.printStackTrace();
            break;
        }
    }
    for (Cursor c : cursorList) {
        c.close();
    }
}
Also used : ArrayList(java.util.ArrayList) SQLiteCursor(android.database.sqlite.SQLiteCursor) Cursor(android.database.Cursor) CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException) 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