Add more tests.

This commit is contained in:
Felix Geyer 2010-08-14 14:26:25 +02:00
parent a3211872e0
commit 9b0ba46b31
4 changed files with 25 additions and 87 deletions

View File

@ -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} )

View File

@ -34,7 +34,7 @@
<IconID>49</IconID>
<Times>
<LastModificationTime>2010-08-08T17:24:27Z</LastModificationTime>
<CreationTime>2010-08-08T17:24:27Z</CreationTime>
<CreationTime>2010-08-07T17:24:27Z</CreationTime>
<LastAccessTime>2010-08-09T09:09:44Z</LastAccessTime>
<ExpiryTime>2010-08-08T17:24:17Z</ExpiryTime>
<Expires>False</Expires>
@ -140,86 +140,6 @@
<EnableSearching>null</EnableSearching>
<LastTopVisibleEntry>AAAAAAAAAAAAAAAAAAAAAA==</LastTopVisibleEntry>
</Group>
<Group>
<UUID>bFe1/LfewEuvlTsT8nJRRg==</UUID>
<Name>Network</Name>
<Notes />
<IconID>3</IconID>
<Times>
<LastModificationTime>2010-08-08T17:24:53Z</LastModificationTime>
<CreationTime>2010-08-08T17:24:53Z</CreationTime>
<LastAccessTime>2010-08-08T17:24:53Z</LastAccessTime>
<ExpiryTime>2010-08-08T17:24:17Z</ExpiryTime>
<Expires>False</Expires>
<UsageCount>0</UsageCount>
<LocationChanged>2010-08-08T17:24:53Z</LocationChanged>
</Times>
<IsExpanded>True</IsExpanded>
<DefaultAutoTypeSequence />
<EnableAutoType>null</EnableAutoType>
<EnableSearching>null</EnableSearching>
<LastTopVisibleEntry>AAAAAAAAAAAAAAAAAAAAAA==</LastTopVisibleEntry>
</Group>
<Group>
<UUID>wHmj/+6vTkOpG/eeVp3yjg==</UUID>
<Name>Internet</Name>
<Notes />
<IconID>1</IconID>
<Times>
<LastModificationTime>2010-08-08T17:24:53Z</LastModificationTime>
<CreationTime>2010-08-08T17:24:53Z</CreationTime>
<LastAccessTime>2010-08-08T17:24:53Z</LastAccessTime>
<ExpiryTime>2010-08-08T17:24:17Z</ExpiryTime>
<Expires>False</Expires>
<UsageCount>0</UsageCount>
<LocationChanged>2010-08-08T17:24:53Z</LocationChanged>
</Times>
<IsExpanded>True</IsExpanded>
<DefaultAutoTypeSequence />
<EnableAutoType>null</EnableAutoType>
<EnableSearching>null</EnableSearching>
<LastTopVisibleEntry>AAAAAAAAAAAAAAAAAAAAAA==</LastTopVisibleEntry>
</Group>
<Group>
<UUID>9QLqqFgc5EC7ptm2TI1hDA==</UUID>
<Name>eMail</Name>
<Notes />
<IconID>19</IconID>
<Times>
<LastModificationTime>2010-08-08T17:24:53Z</LastModificationTime>
<CreationTime>2010-08-08T17:24:53Z</CreationTime>
<LastAccessTime>2010-08-08T17:24:53Z</LastAccessTime>
<ExpiryTime>2010-08-08T17:24:17Z</ExpiryTime>
<Expires>False</Expires>
<UsageCount>0</UsageCount>
<LocationChanged>2010-08-08T17:24:53Z</LocationChanged>
</Times>
<IsExpanded>True</IsExpanded>
<DefaultAutoTypeSequence />
<EnableAutoType>null</EnableAutoType>
<EnableSearching>null</EnableSearching>
<LastTopVisibleEntry>AAAAAAAAAAAAAAAAAAAAAA==</LastTopVisibleEntry>
</Group>
<Group>
<UUID>wQru0ArOaEOy0uUio3subA==</UUID>
<Name>Homebanking</Name>
<Notes />
<IconID>37</IconID>
<Times>
<LastModificationTime>2010-08-08T17:24:53Z</LastModificationTime>
<CreationTime>2010-08-08T17:24:53Z</CreationTime>
<LastAccessTime>2010-08-08T17:24:53Z</LastAccessTime>
<ExpiryTime>2010-08-08T17:24:17Z</ExpiryTime>
<Expires>False</Expires>
<UsageCount>0</UsageCount>
<LocationChanged>2010-08-08T17:24:53Z</LocationChanged>
</Times>
<IsExpanded>True</IsExpanded>
<DefaultAutoTypeSequence />
<EnableAutoType>null</EnableAutoType>
<EnableSearching>null</EnableSearching>
<LastTopVisibleEntry>AAAAAAAAAAAAAAAAAAAAAA==</LastTopVisibleEntry>
</Group>
<Group>
<UUID>7PAwxNhPaE2klutz45i2xg==</UUID>
<Name>Recycle Bin</Name>

View File

@ -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);

View File

@ -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);