Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7dea4ec authored by Vasu Nori's avatar Vasu Nori
Browse files

bug:3443154 fix database tests after disabling sqlite wal

sqlite wal is disabled in Change-Id: I283ad26ba7e1793772a372aa8e24df0cb96ce2ef

Change-Id: I2b370c65390a9293e4a82f650c9cee8023b861d7
parent adca6840
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -18,8 +18,10 @@ package android.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDiskIOException;
import android.database.sqlite.SQLiteException;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.Suppress;
import android.util.Log;

import java.io.BufferedWriter;
@@ -60,6 +62,7 @@ public class DatabaseErrorHandlerTest extends AndroidTestCase {
        assertTrue(mDatabaseFile.exists());
    }


    public void testDatabaseIsCorrupt() throws IOException {
        mDatabase.execSQL("create table t (i int);");
        // write junk into the database file
@@ -72,9 +75,21 @@ public class DatabaseErrorHandlerTest extends AndroidTestCase {
        try {
            mDatabase.execSQL("select * from t;");
            fail("expected exception");
        } catch (SQLiteException e) {
        } catch (SQLiteDiskIOException e) {
            /**
             * this test used to produce a corrupted db. but with new sqlite it instead reports
             * Disk I/O error. meh..
             * need to figure out how to cause corruption in db
             */
            // expected
            if (mDatabaseFile.exists()) {
                mDatabaseFile.delete();
            }
        } catch (SQLiteException e) {
            
        }
        // database file should be gone
        assertFalse(mDatabaseFile.exists());
        // after corruption handler is called, the database file should be free of
        // database corruption
        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(mDatabaseFile.getPath(), null,
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.database.Cursor;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.Suppress;
import android.util.Log;

import java.io.File;
@@ -54,6 +55,7 @@ public class SQLiteCursorTest extends AndroidTestCase {
        super.tearDown();
    }

    @Suppress
    @SmallTest
    public void testQueryObjReassignment() {
        mDatabase.enableWriteAheadLogging();
+7 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public class SQLiteDatabaseTest extends AndroidTestCase {
        mDatabase.setVersion(CURRENT_DATABASE_VERSION);
    }

    @Suppress
    @SmallTest
    public void testEnableWriteAheadLogging() {
        mDatabase.disableWriteAheadLogging();
@@ -86,6 +87,7 @@ public class SQLiteDatabaseTest extends AndroidTestCase {
        assertEquals(pool, mDatabase.mConnectionPool);
    }

    @Suppress
    @SmallTest
    public void testDisableWriteAheadLogging() {
        mDatabase.execSQL("create table test (i int);");
@@ -102,6 +104,7 @@ public class SQLiteDatabaseTest extends AndroidTestCase {
        assertFalse(db.isOpen());
    }

    @Suppress
    @SmallTest
    public void testCursorsWithClosedDbConnAfterDisableWriteAheadLogging() {
        mDatabase.disableWriteAheadLogging();
@@ -138,6 +141,7 @@ public class SQLiteDatabaseTest extends AndroidTestCase {
    /**
     * a transaction should be started before a standalone-update/insert/delete statement
     */
    @Suppress
    @SmallTest
    public void testStartXactBeforeUpdateSql() throws InterruptedException {
        runTestForStartXactBeforeUpdateSql(INSERT);
@@ -749,6 +753,7 @@ public class SQLiteDatabaseTest extends AndroidTestCase {
     *
     * @throws InterruptedException
     */
    @Suppress
    @SmallTest
    public void testTransactionAndWalInterplay1() throws InterruptedException {
        createTableAndClearCache();
@@ -807,6 +812,7 @@ public class SQLiteDatabaseTest extends AndroidTestCase {
     * instead of mDatabase.beginTransactionNonExclusive(), use execSQL("BEGIN transaction")
     * and instead of mDatabase.endTransaction(), use execSQL("END");
     */
    @Suppress
    @SmallTest
    public void testTransactionAndWalInterplay2() throws InterruptedException {
        createTableAndClearCache();
@@ -863,6 +869,7 @@ public class SQLiteDatabaseTest extends AndroidTestCase {
     * instead of committing the data, do rollback and make sure the data seen by the query
     * within the transaction is now gone.
     */
    @Suppress
    @SmallTest
    public void testTransactionAndWalInterplay3() {
        createTableAndClearCache();