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();
}
}
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();
}
}
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);
}
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();
}
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();
}
}
Aggregations