From 6ee781a6088a0dede19c54f5c6b2ac14acf2a3d3 Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Sun, 24 Mar 2013 21:21:06 +0100 Subject: [PATCH] Add regression test for issue #56. --- tests/CMakeLists.txt | 3 +++ tests/TestEntry.cpp | 39 +++++++++++++++++++++++++++++++++++++++ tests/TestEntry.h | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 tests/TestEntry.cpp create mode 100644 tests/TestEntry.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b2e140cd5..38018c837 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -155,6 +155,9 @@ add_unit_test(NAME testwildcardmatcher SOURCES TestWildcardMatcher.cpp MOCS Test add_unit_test(NAME testautotype SOURCES TestAutoType.cpp MOCS TestAutoType.h LIBS ${TEST_LIBRARIES}) +add_unit_test(NAME testentry SOURCES TestEntry.cpp MOCS TestEntry.h + LIBS ${TEST_LIBRARIES}) + if(WITH_GUI_TESTS) add_subdirectory(gui) endif(WITH_GUI_TESTS) diff --git a/tests/TestEntry.cpp b/tests/TestEntry.cpp new file mode 100644 index 000000000..49f5d65a7 --- /dev/null +++ b/tests/TestEntry.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2013 Felix Geyer + * + * 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 "TestEntry.h" + +#include + +#include "tests.h" +#include "core/Entry.h" + +void TestEntry::testHistoryItemDeletion() +{ + Entry* entry = new Entry(); + Entry* historyEntry = new Entry(); + + entry->addHistoryItem(historyEntry); + QCOMPARE(entry->historyItems().size(), 1); + + QList historyEntriesToRemove; + historyEntriesToRemove.append(historyEntry); + entry->removeHistoryItems(historyEntriesToRemove); + QCOMPARE(entry->historyItems().size(), 0); +} + +QTEST_GUILESS_MAIN(TestEntry) diff --git a/tests/TestEntry.h b/tests/TestEntry.h new file mode 100644 index 000000000..aaedb259c --- /dev/null +++ b/tests/TestEntry.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2013 Felix Geyer + * + * 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_TESTENTRY_H +#define KEEPASSX_TESTENTRY_H + +#include + +class Entry; + +class TestEntry : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void testHistoryItemDeletion(); + +}; + +#endif // KEEPASSX_TESTENTRY_H