mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-23 07:59:54 -05:00
Add recycle bin test cases body
This commit is contained in:
parent
5792bf1a85
commit
583f60a3f3
@ -18,9 +18,12 @@
|
|||||||
#include "TestDatabase.h"
|
#include "TestDatabase.h"
|
||||||
|
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
|
#include <QSignalSpy>
|
||||||
|
|
||||||
|
#include "config-keepassx-tests.h"
|
||||||
#include "core/Database.h"
|
#include "core/Database.h"
|
||||||
#include "crypto/Crypto.h"
|
#include "crypto/Crypto.h"
|
||||||
|
#include "keys/PasswordKey.h"
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN(TestDatabase)
|
QTEST_GUILESS_MAIN(TestDatabase)
|
||||||
|
|
||||||
@ -31,20 +34,56 @@ void TestDatabase::initTestCase()
|
|||||||
|
|
||||||
void TestDatabase::testEmptyRecycleBinOnDisabled()
|
void TestDatabase::testEmptyRecycleBinOnDisabled()
|
||||||
{
|
{
|
||||||
|
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/RecycleBinDisabled.kdbx");
|
||||||
|
CompositeKey key;
|
||||||
|
key.addKey(PasswordKey("123"));
|
||||||
|
Database* db = Database::openDatabaseFile(filename, key);
|
||||||
|
QVERIFY(db);
|
||||||
|
|
||||||
|
QSignalSpy spyModified(db, SIGNAL(modifiedImmediate()));
|
||||||
|
|
||||||
|
db->emptyRecycleBin();
|
||||||
|
//The database must be unmodified in this test after emptying the recycle bin.
|
||||||
|
QCOMPARE(spyModified.count(), 0);
|
||||||
|
|
||||||
|
delete db;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestDatabase::testEmptyRecycleBinOnNotCreated()
|
void TestDatabase::testEmptyRecycleBinOnNotCreated()
|
||||||
{
|
{
|
||||||
|
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/RecycleBinNotYetCreated.kdbx");
|
||||||
|
CompositeKey key;
|
||||||
|
key.addKey(PasswordKey("123"));
|
||||||
|
Database* db = Database::openDatabaseFile(filename, key);
|
||||||
|
QVERIFY(db);
|
||||||
|
|
||||||
|
QSignalSpy spyModified(db, SIGNAL(modifiedImmediate()));
|
||||||
|
|
||||||
|
db->emptyRecycleBin();
|
||||||
|
//The database must be unmodified in this test after emptying the recycle bin.
|
||||||
|
QCOMPARE(spyModified.count(), 0);
|
||||||
|
|
||||||
|
delete db;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestDatabase::testEmptyRecycleBinOnEmpty()
|
void TestDatabase::testEmptyRecycleBinOnEmpty()
|
||||||
{
|
{
|
||||||
|
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/RecycleBinEmpty.kdbx");
|
||||||
|
CompositeKey key;
|
||||||
|
key.addKey(PasswordKey("123"));
|
||||||
|
Database* db = Database::openDatabaseFile(filename, key);
|
||||||
|
QVERIFY(db);
|
||||||
|
|
||||||
|
QSignalSpy spyModified(db, SIGNAL(modifiedImmediate()));
|
||||||
|
|
||||||
|
db->emptyRecycleBin();
|
||||||
|
//The database must be unmodified in this test after emptying the recycle bin.
|
||||||
|
QCOMPARE(spyModified.count(), 0);
|
||||||
|
|
||||||
|
delete db;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestDatabase::testEmptyRecycleBinWithHierarchicalData()
|
void TestDatabase::testEmptyRecycleBinWithHierarchicalData()
|
||||||
{
|
{
|
||||||
|
//TODO: implement
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class Database;
|
|
||||||
|
|
||||||
class TestDatabase : public QObject
|
class TestDatabase : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user