From f25c23c051a9c1a55e22d0e453f35105081821b4 Mon Sep 17 00:00:00 2001 From: Louis-Bertrand Varin Date: Tue, 21 Nov 2017 14:24:24 -0500 Subject: [PATCH] Adding tests for Group::clone --- tests/TestGroup.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/TestGroup.cpp b/tests/TestGroup.cpp index 5a809670..2d478bd1 100644 --- a/tests/TestGroup.cpp +++ b/tests/TestGroup.cpp @@ -391,6 +391,22 @@ void TestGroup::testClone() QCOMPARE(clonedGroupKeepUuid->entries().at(0)->uuid(), originalGroupEntry->uuid()); QCOMPARE(clonedGroupKeepUuid->children().at(0)->entries().at(0)->uuid(), subGroupEntry->uuid()); + Group* clonedGroupNoFlags = originalGroup->clone(Entry::CloneNoFlags, Group::CloneNoFlags); + QCOMPARE(clonedGroupNoFlags->entries().size(), 0); + QVERIFY(clonedGroupNoFlags->uuid() == originalGroup->uuid()); + + Group* clonedGroupNewUuid = originalGroup->clone(Entry::CloneNoFlags, Group::CloneNewUuid); + QCOMPARE(clonedGroupNewUuid->entries().size(), 0); + QVERIFY(clonedGroupNewUuid->uuid() != originalGroup->uuid()); + + // Making sure the new modification date is not the same. + QTest::qSleep(1); + + Group* clonedGroupResetTimeInfo = originalGroup->clone(Entry::CloneNoFlags, Group::CloneNewUuid | Group::CloneResetTimeInfo); + QCOMPARE(clonedGroupResetTimeInfo->entries().size(), 0); + QVERIFY(clonedGroupResetTimeInfo->uuid() != originalGroup->uuid()); + QVERIFY(clonedGroupResetTimeInfo->timeInfo().lastModificationTime() != originalGroup->timeInfo().lastModificationTime()); + delete clonedGroup; delete clonedGroupKeepUuid; delete db;