From 9b0ba46b3147b3c28d9f0e214b1a8c62351775ce Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sat, 14 Aug 2010 14:26:25 +0200 Subject: [PATCH] Add more tests. --- tests/CMakeLists.txt | 6 ++-- tests/NewDatabase.xml | 82 +------------------------------------------ tests/TestGroup.cpp | 6 +++- tests/TestParser.cpp | 18 ++++++++-- 4 files changed, 25 insertions(+), 87 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index df232213d..bbb9a0566 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -63,8 +63,8 @@ macro (ADD_UNIT_TEST _test_NAME) endmacro (ADD_UNIT_TEST) -add_unit_test( testparser TestParser.cpp ) -target_link_libraries( testparser keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ) - add_unit_test( testgroup TestGroup.cpp ) target_link_libraries( testgroup keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ) + +add_unit_test( testparser TestParser.cpp ) +target_link_libraries( testparser keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} ) diff --git a/tests/NewDatabase.xml b/tests/NewDatabase.xml index 52c1b91af..af631970f 100644 --- a/tests/NewDatabase.xml +++ b/tests/NewDatabase.xml @@ -34,7 +34,7 @@ 49 2010-08-08T17:24:27Z - 2010-08-08T17:24:27Z + 2010-08-07T17:24:27Z 2010-08-09T09:09:44Z 2010-08-08T17:24:17Z False @@ -140,86 +140,6 @@ null AAAAAAAAAAAAAAAAAAAAAA== - - bFe1/LfewEuvlTsT8nJRRg== - Network - - 3 - - 2010-08-08T17:24:53Z - 2010-08-08T17:24:53Z - 2010-08-08T17:24:53Z - 2010-08-08T17:24:17Z - False - 0 - 2010-08-08T17:24:53Z - - True - - null - null - AAAAAAAAAAAAAAAAAAAAAA== - - - wHmj/+6vTkOpG/eeVp3yjg== - Internet - - 1 - - 2010-08-08T17:24:53Z - 2010-08-08T17:24:53Z - 2010-08-08T17:24:53Z - 2010-08-08T17:24:17Z - False - 0 - 2010-08-08T17:24:53Z - - True - - null - null - AAAAAAAAAAAAAAAAAAAAAA== - - - 9QLqqFgc5EC7ptm2TI1hDA== - eMail - - 19 - - 2010-08-08T17:24:53Z - 2010-08-08T17:24:53Z - 2010-08-08T17:24:53Z - 2010-08-08T17:24:17Z - False - 0 - 2010-08-08T17:24:53Z - - True - - null - null - AAAAAAAAAAAAAAAAAAAAAA== - - - wQru0ArOaEOy0uUio3subA== - Homebanking - - 37 - - 2010-08-08T17:24:53Z - 2010-08-08T17:24:53Z - 2010-08-08T17:24:53Z - 2010-08-08T17:24:17Z - False - 0 - 2010-08-08T17:24:53Z - - True - - null - null - AAAAAAAAAAAAAAAAAAAAAA== - 7PAwxNhPaE2klutz45i2xg== Recycle Bin diff --git a/tests/TestGroup.cpp b/tests/TestGroup.cpp index 585bac825..f1ee2d71c 100644 --- a/tests/TestGroup.cpp +++ b/tests/TestGroup.cpp @@ -31,7 +31,6 @@ void TestGroup::testParenting() { Database* db = new Database(); Group* tmpRoot = new Group(); - tmpRoot->setParent(db); Group* g1 = new Group(); Group* g2 = new Group(); @@ -52,6 +51,11 @@ void TestGroup::testParenting() QVERIFY(g3->parent() == g1); QVERIFY(g4->parent() == g3); + QVERIFY(g1->database() == db); + QVERIFY(g2->database() == db); + QVERIFY(g3->database() == db); + QVERIFY(g4->database() == db); + QVERIFY(tmpRoot->children().size() == 0); QVERIFY(g1->children().size() == 2); QVERIFY(g2->children().size() == 0); diff --git a/tests/TestParser.cpp b/tests/TestParser.cpp index b263fa2f4..3bb2dcbd1 100644 --- a/tests/TestParser.cpp +++ b/tests/TestParser.cpp @@ -76,15 +76,29 @@ void TestParser::testMetadata() QCOMPARE(m_db->metadata()->entryTemplatesGroupChanged(), genDT(2010, 8, 8, 17, 24, 19)); QVERIFY(m_db->metadata()->lastSelectedGroup() != 0); QCOMPARE(m_db->metadata()->lastSelectedGroup()->name(), QLatin1String("NewDatabase")); - QVERIFY(m_db->metadata()->lastTopVisibleGroup() != 0); - QCOMPARE(m_db->metadata()->lastTopVisibleGroup()->name(), QLatin1String("NewDatabase")); + QVERIFY(m_db->metadata()->lastTopVisibleGroup() == m_db->metadata()->lastSelectedGroup()); } void TestParser::testGroups() { + QVERIFY(m_db->rootGroup() != 0); QVERIFY(m_db->rootGroup()->name() == QLatin1String("NewDatabase")); QVERIFY(m_db->rootGroup()->uuid().toBase64() == QLatin1String("zKuE27EWr0mlU75b2SRkTQ==")); QVERIFY(m_db->rootGroup()->isExpanded() == true); + TimeInfo ti = m_db->rootGroup()->timeInfo(); + QVERIFY(ti.lastModificationTime() == genDT(2010, 8, 8, 17, 24, 27)); + QVERIFY(ti.creationTime() == genDT(2010, 8, 7, 17, 24, 27)); + QVERIFY(ti.lastAccessTime() == genDT(2010, 8, 9, 9, 9, 44)); + QVERIFY(ti.expiryTime() == genDT(2010, 8, 8, 17, 24, 17)); + QVERIFY(ti.expires() == false); + QVERIFY(ti.usageCount() == 2); + QVERIFY(ti.locationChanged() == genDT(2010, 8, 8, 17, 24, 27)); + + QVERIFY(m_db->rootGroup()->children().size() == 3); + QVERIFY(m_db->rootGroup()->children().at(0)->uuid().toBase64() == "abLbFtNUfEi5TmbaxiW6yg=="); + QVERIFY(m_db->rootGroup()->children().at(1)->uuid().toBase64() == "u1lTRAICOkWv5QSl2xyU8w=="); + QVERIFY(m_db->rootGroup()->children().at(2)->uuid().toBase64() == "7PAwxNhPaE2klutz45i2xg=="); + QVERIFY(m_db->metadata()->recycleBin() == m_db->rootGroup()->children().at(2)); } QTEST_MAIN(TestParser);