Search in sources :

Example 26 with LargeTest

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

the class DatabaseGeneralTest method testDefaultDatabaseErrorHandler.

@LargeTest
public void testDefaultDatabaseErrorHandler() {
    DefaultDatabaseErrorHandler errorHandler = new DefaultDatabaseErrorHandler();
    // close the database. and call corruption handler.
    // it should delete the database file.
    File dbfile = new File(mDatabase.getPath());
    mDatabase.close();
    assertFalse(mDatabase.isOpen());
    assertTrue(dbfile.exists());
    try {
        errorHandler.onCorruption(mDatabase);
        assertFalse(dbfile.exists());
    } catch (Exception e) {
        fail("unexpected");
    }
    // create an in-memory database. and corruption handler shouldn't try to delete it
    SQLiteDatabase memoryDb = SQLiteDatabase.openOrCreateDatabase(":memory:", null);
    assertNotNull(memoryDb);
    memoryDb.close();
    assertFalse(memoryDb.isOpen());
    try {
        errorHandler.onCorruption(memoryDb);
    } catch (Exception e) {
        fail("unexpected");
    }
    // create a database, keep it open, call corruption handler. database file should be deleted
    SQLiteDatabase dbObj = SQLiteDatabase.openOrCreateDatabase(mDatabase.getPath(), null);
    assertTrue(dbfile.exists());
    assertNotNull(dbObj);
    assertTrue(dbObj.isOpen());
    try {
        errorHandler.onCorruption(dbObj);
        assertFalse(dbfile.exists());
    } catch (Exception e) {
        fail("unexpected");
    }
    // create a database, attach 2 more databases to it
    //    attached database # 1: ":memory:"
    //    attached database # 2: mDatabase.getPath() + "1";
    // call corruption handler. database files including the one for attached database # 2
    // should be deleted
    String attachedDb1File = mDatabase.getPath() + "1";
    dbObj = SQLiteDatabase.openOrCreateDatabase(mDatabase.getPath(), null);
    dbObj.execSQL("ATTACH DATABASE ':memory:' as memoryDb");
    dbObj.execSQL("ATTACH DATABASE '" + attachedDb1File + "' as attachedDb1");
    assertTrue(dbfile.exists());
    assertTrue(new File(attachedDb1File).exists());
    assertNotNull(dbObj);
    assertTrue(dbObj.isOpen());
    List<Pair<String, String>> attachedDbs = dbObj.getAttachedDbs();
    try {
        errorHandler.onCorruption(dbObj);
        assertFalse(dbfile.exists());
        assertFalse(new File(attachedDb1File).exists());
    } catch (Exception e) {
        fail("unexpected");
    }
    // same as above, except this is a bit of stress testing. attach 5 database files
    // and make sure they are all removed.
    int N = 5;
    ArrayList<String> attachedDbFiles = new ArrayList<String>(N);
    for (int i = 0; i < N; i++) {
        attachedDbFiles.add(mDatabase.getPath() + i);
    }
    dbObj = SQLiteDatabase.openOrCreateDatabase(mDatabase.getPath(), null);
    dbObj.execSQL("ATTACH DATABASE ':memory:' as memoryDb");
    for (int i = 0; i < N; i++) {
        dbObj.execSQL("ATTACH DATABASE '" + attachedDbFiles.get(i) + "' as attachedDb" + i);
    }
    assertTrue(dbfile.exists());
    for (int i = 0; i < N; i++) {
        assertTrue(new File(attachedDbFiles.get(i)).exists());
    }
    assertNotNull(dbObj);
    assertTrue(dbObj.isOpen());
    attachedDbs = dbObj.getAttachedDbs();
    try {
        errorHandler.onCorruption(dbObj);
        assertFalse(dbfile.exists());
        for (int i = 0; i < N; i++) {
            assertFalse(new File(attachedDbFiles.get(i)).exists());
        }
    } catch (Exception e) {
        fail("unexpected");
    }
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) File(java.io.File) SQLiteException(android.database.sqlite.SQLiteException) Pair(android.util.Pair) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 27 with LargeTest

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

the class StorageManagerIntegrationTest method testMountMultipleObb.

/**
     * Tests mounting several OBB files and verifies its contents.
     */
@LargeTest
public void testMountMultipleObb() {
    File file1 = null;
    File file2 = null;
    File file3 = null;
    try {
        file1 = createObbFile(OBB_FILE_1, R.raw.obb_file1);
        String filePath1 = file1.getAbsolutePath();
        mountObb(filePath1);
        verifyObb1Contents(filePath1);
        file2 = createObbFile(OBB_FILE_2, R.raw.obb_file2);
        String filePath2 = file2.getAbsolutePath();
        mountObb(filePath2);
        verifyObb2Contents(filePath2);
        file3 = createObbFile(OBB_FILE_3, R.raw.obb_file3);
        String filePath3 = file3.getAbsolutePath();
        mountObb(filePath3);
        verifyObb3Contents(filePath3);
        unmountObb(filePath1, DONT_FORCE);
        unmountObb(filePath2, DONT_FORCE);
        unmountObb(filePath3, DONT_FORCE);
    } finally {
        if (file1 != null) {
            file1.delete();
        }
        if (file2 != null) {
            file2.delete();
        }
        if (file3 != null) {
            file3.delete();
        }
    }
}
Also used : File(java.io.File) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 28 with LargeTest

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

the class StorageManagerIntegrationTest method testMountTwoEncryptedObb.

/**
     * Tests simultaneously mounting 2 encrypted OBBs with different keys and verifies contents.
     */
@LargeTest
public void testMountTwoEncryptedObb() {
    File file3 = null;
    File file1 = null;
    try {
        file3 = createObbFile(OBB_FILE_3_ENCRYPTED, R.raw.obb_enc_file100_orig3);
        String filePath3 = file3.getAbsolutePath();
        mountObb(filePath3, OBB_FILE_3_PASSWORD, OnObbStateChangeListener.MOUNTED);
        verifyObb3Contents(filePath3);
        file1 = createObbFile(OBB_FILE_1_ENCRYPTED, R.raw.obb_enc_file100_orig1);
        String filePath1 = file1.getAbsolutePath();
        mountObb(filePath1, OBB_FILE_1_PASSWORD, OnObbStateChangeListener.MOUNTED);
        verifyObb1Contents(filePath1);
        unmountObb(filePath3, DONT_FORCE);
        unmountObb(filePath1, DONT_FORCE);
    } finally {
        if (file3 != null) {
            file3.delete();
        }
        if (file1 != null) {
            file1.delete();
        }
    }
}
Also used : File(java.io.File) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 29 with LargeTest

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

the class ScrollingThroughListOfFocusablesTest method testNavigatingUpThroughInternalSelection.

@LargeTest
public void testNavigatingUpThroughInternalSelection() throws Exception {
    // get to bottom of second item
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < mNumRowsPerItem; j++) {
            if (i < 1 || j < mNumRowsPerItem - 1) {
                sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
                getInstrumentation().waitForIdleSync();
            }
        }
    }
    // (make sure we are at last row of second item)
    {
        assertEquals(1, mListView.getSelectedItemPosition());
        InternalSelectionView view = mActivity.getSelectedView();
        assertEquals(mNumRowsPerItem - 1, view.getSelectedRow());
    }
    // go back up to the top of the second item
    for (int i = mNumRowsPerItem - 1; i >= 0; i--) {
        assertEquals(1, mListView.getSelectedItemPosition());
        InternalSelectionView view = mActivity.getSelectedView();
        assertInternallySelectedRowOnScreen(view, i);
        // move up to next row
        if (i > 0) {
            sendKeys(KeyEvent.KEYCODE_DPAD_UP);
            getInstrumentation().waitForIdleSync();
        }
    }
    // now we are at top row, should have caused scrolling, and fading edge...
    {
        assertEquals(1, mListView.getSelectedItemPosition());
        InternalSelectionView view = mActivity.getSelectedView();
        assertEquals(0, view.getSelectedRow());
        view.getDrawingRect(mTempRect);
        mListView.offsetDescendantRectToMyCoords(view, mTempRect);
        assertEquals("top of selected row should be just below top vertical fading edge", mListView.getVerticalFadingEdgeLength(), view.getTop());
    }
    // make sure fading edge is the view we expect
    {
        final InternalSelectionView view = (InternalSelectionView) mListView.getChildAt(0);
        assertEquals(mActivity.getLabelForPosition(0), view.getLabel());
    }
}
Also used : InternalSelectionView(android.util.InternalSelectionView) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 30 with LargeTest

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

the class ListHeterogeneousTest method testKeyScrolling.

@LargeTest
public void testKeyScrolling() {
    Instrumentation inst = getInstrumentation();
    int count = mListView.getAdapter().getCount();
    for (int i = 0; i < count - 1; i++) {
        inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_DOWN);
    }
    inst.waitForIdleSync();
    int convertMissesBefore = mActivity.getConvertMisses();
    assertEquals("Unexpected convert misses", 0, convertMissesBefore);
    for (int i = 0; i < count - 1; i++) {
        inst.sendCharacterSync(KeyEvent.KEYCODE_DPAD_UP);
    }
    inst.waitForIdleSync();
    int convertMissesAfter = mActivity.getConvertMisses();
    assertEquals("Unexpected convert misses", 0, convertMissesAfter);
}
Also used : Instrumentation(android.app.Instrumentation) 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