Search in sources :

Example 1 with DeleteGroup

use of com.keepassdroid.database.edit.DeleteGroup in project KeePassDX by Kunzisoft.

the class DeleteEntry method testDelete.

public void testDelete() {
    Database db;
    Context ctx = getContext();
    try {
        db = TestData.GetDb(ctx, ASSET, PASSWORD, KEYFILE, FILENAME);
    } catch (Exception e) {
        assertTrue("Failed to open database: " + e.getMessage(), false);
        return;
    }
    PwDatabaseV3 pm = (PwDatabaseV3) db.pm;
    PwGroup group1 = getGroup(pm, GROUP1_NAME);
    assertNotNull("Could not find group1", group1);
    // Delete the group
    DeleteGroup task = new DeleteGroup(db, group1, null, true);
    task.run();
    // Verify the entries were deleted
    PwEntry entry1 = getEntry(pm, ENTRY1_NAME);
    assertNull("Entry 1 was not removed", entry1);
    PwEntry entry2 = getEntry(pm, ENTRY2_NAME);
    assertNull("Entry 2 was not removed", entry2);
    // Verify the entries were removed from the search index
    SearchDbHelper dbHelp = new SearchDbHelper(ctx);
    PwGroup results1 = dbHelp.search(db, ENTRY1_NAME);
    PwGroup results2 = dbHelp.search(db, ENTRY2_NAME);
    assertEquals("Entry1 was not removed from the search results", 0, results1.numbersOfChildEntries());
    assertEquals("Entry2 was not removed from the search results", 0, results2.numbersOfChildEntries());
    // Verify the group was deleted
    group1 = getGroup(pm, GROUP1_NAME);
    assertNull("Group 1 was not removed.", group1);
}
Also used : Context(android.content.Context) PwDatabaseV3(com.keepassdroid.database.PwDatabaseV3) SearchDbHelper(com.keepassdroid.search.SearchDbHelper) PwDatabase(com.keepassdroid.database.PwDatabase) Database(com.keepassdroid.database.Database) PwEntry(com.keepassdroid.database.PwEntry) PwGroup(com.keepassdroid.database.PwGroup) DeleteGroup(com.keepassdroid.database.edit.DeleteGroup)

Example 2 with DeleteGroup

use of com.keepassdroid.database.edit.DeleteGroup in project KeePassDX by Kunzisoft.

the class GroupActivity method deleteGroup.

private void deleteGroup(PwGroup group) {
    // TODO Verify trash recycle bin
    Handler handler = new Handler();
    DeleteGroup task = new DeleteGroup(this, App.getDB(), group, new AfterDeleteNode(handler, group));
    ProgressTask pt = new ProgressTask(this, task, R.string.saving_database);
    pt.run();
}
Also used : ProgressTask(com.keepassdroid.tasks.ProgressTask) Handler(android.os.Handler) DeleteGroup(com.keepassdroid.database.edit.DeleteGroup)

Aggregations

DeleteGroup (com.keepassdroid.database.edit.DeleteGroup)2 Context (android.content.Context)1 Handler (android.os.Handler)1 Database (com.keepassdroid.database.Database)1 PwDatabase (com.keepassdroid.database.PwDatabase)1 PwDatabaseV3 (com.keepassdroid.database.PwDatabaseV3)1 PwEntry (com.keepassdroid.database.PwEntry)1 PwGroup (com.keepassdroid.database.PwGroup)1 SearchDbHelper (com.keepassdroid.search.SearchDbHelper)1 ProgressTask (com.keepassdroid.tasks.ProgressTask)1