From 5792bf1a858d66cf2f3b0953e08cae0650f217c4 Mon Sep 17 00:00:00 2001 From: Vladimir Svyatski Date: Sat, 22 Apr 2017 10:02:59 +0300 Subject: [PATCH] Add skeleton for TestDatabase.cpp and test data for unit tests for the "empty recycle bin" functionality --- tests/CMakeLists.txt | 3 ++ tests/TestDatabase.cpp | 50 ++++++++++++++++++++++++ tests/TestDatabase.h | 37 ++++++++++++++++++ tests/data/RecycleBinDisabled.kdbx | Bin 0 -> 2302 bytes tests/data/RecycleBinEmpty.kdbx | Bin 0 -> 2430 bytes tests/data/RecycleBinNotYetCreated.kdbx | Bin 0 -> 2350 bytes tests/data/RecycleBinWithData.kdbx | Bin 0 -> 3854 bytes 7 files changed, 90 insertions(+) create mode 100644 tests/TestDatabase.cpp create mode 100644 tests/TestDatabase.h create mode 100644 tests/data/RecycleBinDisabled.kdbx create mode 100644 tests/data/RecycleBinEmpty.kdbx create mode 100644 tests/data/RecycleBinNotYetCreated.kdbx create mode 100644 tests/data/RecycleBinWithData.kdbx diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2ea50424a..1c9f1c0f5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -177,6 +177,9 @@ add_unit_test(NAME testykchallengeresponsekey SOURCES TestYkChallengeResponseKey.cpp TestYkChallengeResponseKey.h LIBS ${TEST_LIBRARIES}) +add_unit_test(NAME testdatabase SOURCES TestDatabase.cpp + LIBS ${TEST_LIBRARIES}) + if(WITH_GUI_TESTS) add_subdirectory(gui) endif(WITH_GUI_TESTS) diff --git a/tests/TestDatabase.cpp b/tests/TestDatabase.cpp new file mode 100644 index 000000000..584fde434 --- /dev/null +++ b/tests/TestDatabase.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2017 Vladimir Svyatski + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 or (at your option) + * version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "TestDatabase.h" + +#include + +#include "core/Database.h" +#include "crypto/Crypto.h" + +QTEST_GUILESS_MAIN(TestDatabase) + +void TestDatabase::initTestCase() +{ + QVERIFY(Crypto::init()); +} + +void TestDatabase::testEmptyRecycleBinOnDisabled() +{ + +} + +void TestDatabase::testEmptyRecycleBinOnNotCreated() +{ + +} + +void TestDatabase::testEmptyRecycleBinOnEmpty() +{ + +} + +void TestDatabase::testEmptyRecycleBinWithHierarchicalData() +{ + +} diff --git a/tests/TestDatabase.h b/tests/TestDatabase.h new file mode 100644 index 000000000..550155225 --- /dev/null +++ b/tests/TestDatabase.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2017 Vladimir Svyatski + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 or (at your option) + * version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KEEPASSX_TESTDATABASE_H +#define KEEPASSX_TESTDATABASE_H + +#include + +class Database; + +class TestDatabase : public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + void testEmptyRecycleBinOnDisabled(); + void testEmptyRecycleBinOnNotCreated(); + void testEmptyRecycleBinOnEmpty(); + void testEmptyRecycleBinWithHierarchicalData(); +}; + +#endif // KEEPASSX_TESTDATABASE_H diff --git a/tests/data/RecycleBinDisabled.kdbx b/tests/data/RecycleBinDisabled.kdbx new file mode 100644 index 0000000000000000000000000000000000000000..0bbfb3efee2ceecebb86991548b659289d102799 GIT binary patch literal 2302 zcmVXnBdXtDDO1ONg60000401XNa3UL_qM^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