Search in sources :

Example 1 with SearchDbHelper

use of com.keepassdroid.search.SearchDbHelper 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 SearchDbHelper

use of com.keepassdroid.search.SearchDbHelper in project KeePassDX by Kunzisoft.

the class Database method LoadData.

public void LoadData(Context ctx, PwDatabase pm, String password, InputStream keyInputStream, UpdateStatus status) {
    if (pm != null) {
        passwordEncodingError = !pm.validatePasswordEncoding(password);
    }
    searchHelper = new SearchDbHelper(ctx);
    loaded = true;
}
Also used : SearchDbHelper(com.keepassdroid.search.SearchDbHelper)

Aggregations

SearchDbHelper (com.keepassdroid.search.SearchDbHelper)2 Context (android.content.Context)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 DeleteGroup (com.keepassdroid.database.edit.DeleteGroup)1