Search in sources :

Example 21 with BackupDataOutput

use of android.app.backup.BackupDataOutput in project android_frameworks_base by AOSPA.

the class BackupDataTest method testDelete.

public void testDelete() throws IOException {
    mFile = new File(mDirectory, "backup_delete_test.dat");
    openForWriting();
    BackupDataOutput bdo = new BackupDataOutput(mDataFile.getFileDescriptor());
    for (int i = 0; i < KEYS.length; i++) {
        deleteEntity(bdo, KEYS[i]);
    }
    mDataFile.close();
    openForReading();
    BackupDataInput bdi = new BackupDataInput(mDataFile.getFileDescriptor());
    int count = 0;
    while (bdi.readNextHeader()) {
        readAndVerifyDeletedEntity(bdi, KEYS[count]);
        count++;
    }
    assertEquals("four deletes in this stream", KEYS.length, count);
}
Also used : BackupDataInput(android.app.backup.BackupDataInput) File(java.io.File) BackupDataOutput(android.app.backup.BackupDataOutput)

Example 22 with BackupDataOutput

use of android.app.backup.BackupDataOutput in project android_frameworks_base by AOSPA.

the class BackupDataTest method testMultiple.

public void testMultiple() throws IOException {
    mFile = new File(mDirectory, "backup_multiple_test.dat");
    openForWriting();
    BackupDataOutput bdo = new BackupDataOutput(mDataFile.getFileDescriptor());
    for (int i = 0; i < KEYS.length; i++) {
        writeEntity(bdo, KEYS[i], DATA[i].getBytes());
    }
    mDataFile.close();
    openForReading();
    BackupDataInput bdi = new BackupDataInput(mDataFile.getFileDescriptor());
    int count = 0;
    while (bdi.readNextHeader()) {
        readAndVerifyEntity(bdi, KEYS[count], DATA[count].getBytes());
        count++;
    }
    assertEquals("four entities in this stream", KEYS.length, count);
}
Also used : BackupDataInput(android.app.backup.BackupDataInput) File(java.io.File) BackupDataOutput(android.app.backup.BackupDataOutput)

Example 23 with BackupDataOutput

use of android.app.backup.BackupDataOutput in project android_frameworks_base by ResurrectionRemix.

the class BackupDataTest method testDelete.

public void testDelete() throws IOException {
    mFile = new File(mDirectory, "backup_delete_test.dat");
    openForWriting();
    BackupDataOutput bdo = new BackupDataOutput(mDataFile.getFileDescriptor());
    for (int i = 0; i < KEYS.length; i++) {
        deleteEntity(bdo, KEYS[i]);
    }
    mDataFile.close();
    openForReading();
    BackupDataInput bdi = new BackupDataInput(mDataFile.getFileDescriptor());
    int count = 0;
    while (bdi.readNextHeader()) {
        readAndVerifyDeletedEntity(bdi, KEYS[count]);
        count++;
    }
    assertEquals("four deletes in this stream", KEYS.length, count);
}
Also used : BackupDataInput(android.app.backup.BackupDataInput) File(java.io.File) BackupDataOutput(android.app.backup.BackupDataOutput)

Example 24 with BackupDataOutput

use of android.app.backup.BackupDataOutput in project android_frameworks_base by crdroidandroid.

the class BackupDataTest method testMultiple.

public void testMultiple() throws IOException {
    mFile = new File(mDirectory, "backup_multiple_test.dat");
    openForWriting();
    BackupDataOutput bdo = new BackupDataOutput(mDataFile.getFileDescriptor());
    for (int i = 0; i < KEYS.length; i++) {
        writeEntity(bdo, KEYS[i], DATA[i].getBytes());
    }
    mDataFile.close();
    openForReading();
    BackupDataInput bdi = new BackupDataInput(mDataFile.getFileDescriptor());
    int count = 0;
    while (bdi.readNextHeader()) {
        readAndVerifyEntity(bdi, KEYS[count], DATA[count].getBytes());
        count++;
    }
    assertEquals("four entities in this stream", KEYS.length, count);
}
Also used : BackupDataInput(android.app.backup.BackupDataInput) File(java.io.File) BackupDataOutput(android.app.backup.BackupDataOutput)

Example 25 with BackupDataOutput

use of android.app.backup.BackupDataOutput in project android_frameworks_base by crdroidandroid.

the class BackupDataTest method testSingle.

public void testSingle() throws IOException {
    mFile = new File(mDirectory, "backup_mixed_sinlge.dat");
    openForWriting();
    BackupDataOutput bdo = new BackupDataOutput(mDataFile.getFileDescriptor());
    writeEntity(bdo, KEY1, DATA1.getBytes());
    mDataFile.close();
    openForReading();
    BackupDataInput bdi = new BackupDataInput(mDataFile.getFileDescriptor());
    int count = 0;
    while (bdi.readNextHeader()) {
        readAndVerifyEntity(bdi, KEY1, DATA1.getBytes());
        count++;
    }
    assertEquals("only one entity in this stream", 1, count);
}
Also used : BackupDataInput(android.app.backup.BackupDataInput) File(java.io.File) BackupDataOutput(android.app.backup.BackupDataOutput)

Aggregations

BackupDataOutput (android.app.backup.BackupDataOutput)27 File (java.io.File)27 BackupDataInput (android.app.backup.BackupDataInput)20 FileInputStream (java.io.FileInputStream)7 IOException (java.io.IOException)7