Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JosefVitu committed Oct 28, 2016
1 parent 82ace81 commit ad36ec4
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/TestCsvExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void TestCsvExporter::initTestCase()
Crypto::init();
}

void TestCsvExporter::cleanUp()
void TestCsvExporter::cleanup()
{
delete m_db;
delete m_csvExporter;
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCsvExporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TestCsvExporter : public QObject
private Q_SLOTS:
void init();
void initTestCase();
void cleanUp();
void cleanup();
void testExport();
void testEmptyDatabase();
void testNestedGroups();
Expand Down
12 changes: 10 additions & 2 deletions tests/TestEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ void TestEntry::testCopyDataFrom()
QCOMPARE(entry2->autoTypeAssociations()->size(), 2);
QCOMPARE(entry2->autoTypeAssociations()->get(0).window, QString("1"));
QCOMPARE(entry2->autoTypeAssociations()->get(1).window, QString("3"));

delete entry2;
}

void TestEntry::testClone()
Expand All @@ -101,24 +103,30 @@ void TestEntry::testClone()
QCOMPARE(entryCloneNone->title(), QString("New Title"));
QCOMPARE(entryCloneNone->historyItems().size(), 0);
QCOMPARE(entryCloneNone->timeInfo().creationTime(), entryOrg->timeInfo().creationTime());
delete entryCloneNone;

Entry* entryCloneNewUuid = entryOrg->clone(Entry::CloneNewUuid);
QVERIFY(entryCloneNewUuid->uuid() != entryOrg->uuid());
QVERIFY(!entryCloneNewUuid->uuid().isNull());
QCOMPARE(entryCloneNewUuid->title(), QString("New Title"));
QCOMPARE(entryCloneNewUuid->historyItems().size(), 0);
QCOMPARE(entryCloneNewUuid->timeInfo().creationTime(), entryOrg->timeInfo().creationTime());
delete entryCloneNewUuid;

Entry* entryCloneResetTime = entryOrg->clone(Entry::CloneResetTimeInfo);
QCOMPARE(entryCloneNone->uuid(), entryOrg->uuid());
QCOMPARE(entryCloneResetTime->uuid(), entryOrg->uuid());
QCOMPARE(entryCloneResetTime->title(), QString("New Title"));
QCOMPARE(entryCloneResetTime->historyItems().size(), 0);
QVERIFY(entryCloneResetTime->timeInfo().creationTime() != entryOrg->timeInfo().creationTime());
delete entryCloneResetTime;

Entry* entryCloneHistory = entryOrg->clone(Entry::CloneIncludeHistory);
QCOMPARE(entryCloneNone->uuid(), entryOrg->uuid());
QCOMPARE(entryCloneHistory->uuid(), entryOrg->uuid());
QCOMPARE(entryCloneHistory->title(), QString("New Title"));
QCOMPARE(entryCloneHistory->historyItems().size(), 1);
QCOMPARE(entryCloneHistory->historyItems().at(0)->title(), QString("Original Title"));
QCOMPARE(entryCloneHistory->timeInfo().creationTime(), entryOrg->timeInfo().creationTime());
delete entryCloneHistory;

delete entryOrg;
}
3 changes: 3 additions & 0 deletions tests/TestGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,4 +445,7 @@ void TestGroup::testCopyCustomIcons()

QCOMPARE(metaTarget->customIcon(group1Icon).pixel(0, 0), qRgb(1, 2, 3));
QCOMPARE(metaTarget->customIcon(group2Icon).pixel(0, 0), qRgb(4, 5, 6));

delete dbTarget;
delete dbSource;
}
6 changes: 6 additions & 0 deletions tests/TestWildcardMatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,19 @@ void TestWildcardMatcher::testMatcher()

initMatcher(text);
verifyMatchResult(pattern, match);
cleanupMatcher();
}

void TestWildcardMatcher::initMatcher(QString text)
{
m_matcher = new WildcardMatcher(text);
}

void TestWildcardMatcher::cleanupMatcher()
{
delete m_matcher;
}

void TestWildcardMatcher::verifyMatchResult(QString pattern, bool expected)
{
if (expected) {
Expand Down
1 change: 1 addition & 0 deletions tests/TestWildcardMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private Q_SLOTS:
static const QString AlternativeText;

void initMatcher(QString text);
void cleanupMatcher();
void verifyMatchResult(QString pattern, bool expected);
void verifyMatch(QString pattern);
void verifyNoMatch(QString pattern);
Expand Down

0 comments on commit ad36ec4

Please sign in to comment.