Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests/gui
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2020-12-12 17:46:23 +0300
committerJonathan White <support@dmapps.us>2020-12-21 06:57:42 +0300
commita74e2391e858667dce9d7ea412f409393fbbec6a (patch)
treea9a0e2b93c4172fdb4bc93ced87d2baedd421396 /tests/gui
parent4b5248ee989ec889294a05ed2895768acefdf562 (diff)
Copy history when drag/drop entries and groups
* Fix #5809
Diffstat (limited to 'tests/gui')
-rw-r--r--tests/gui/TestGui.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp
index 7c24b0fc2..2463f13f6 100644
--- a/tests/gui/TestGui.cpp
+++ b/tests/gui/TestGui.cpp
@@ -1155,24 +1155,45 @@ void TestGui::testEntryPlaceholders()
void TestGui::testDragAndDropEntry()
{
- auto* entryView = m_dbWidget->findChild<EntryView*>("entryView");
- auto* groupView = m_dbWidget->findChild<GroupView*>("groupView");
- QAbstractItemModel* groupModel = groupView->model();
+ auto entryView = m_dbWidget->findChild<EntryView*>("entryView");
+ auto groupView = m_dbWidget->findChild<GroupView*>("groupView");
+ auto groupModel = qobject_cast<GroupModel*>(groupView->model());
QModelIndex sourceIndex = entryView->model()->index(0, 1);
QModelIndex targetIndex = groupModel->index(0, 0, groupModel->index(0, 0));
QVERIFY(sourceIndex.isValid());
QVERIFY(targetIndex.isValid());
+ auto targetGroup = groupModel->groupFromIndex(targetIndex);
QMimeData mimeData;
QByteArray encoded;
QDataStream stream(&encoded, QIODevice::WriteOnly);
- Entry* entry = entryView->entryFromIndex(sourceIndex);
+
+ auto entry = entryView->entryFromIndex(sourceIndex);
+ stream << entry->group()->database()->uuid() << entry->uuid();
+ mimeData.setData("application/x-keepassx-entry", encoded);
+
+ // Test Copy, UUID should change, history remain
+ QVERIFY(groupModel->dropMimeData(&mimeData, Qt::CopyAction, -1, 0, targetIndex));
+ // Find the copied entry
+ auto newEntry = targetGroup->findEntryByPath(entry->title());
+ QVERIFY(newEntry);
+ QVERIFY(entry->uuid() != newEntry->uuid());
+ QCOMPARE(entry->historyItems().count(), newEntry->historyItems().count());
+
+ encoded.clear();
+ entry = entryView->entryFromIndex(sourceIndex);
+ auto history = entry->historyItems().count();
+ auto uuid = entry->uuid();
stream << entry->group()->database()->uuid() << entry->uuid();
mimeData.setData("application/x-keepassx-entry", encoded);
+ // Test Move, entry pointer should remain the same
+ QCOMPARE(entry->group()->name(), QString("NewDatabase"));
QVERIFY(groupModel->dropMimeData(&mimeData, Qt::MoveAction, -1, 0, targetIndex));
QCOMPARE(entry->group()->name(), QString("General"));
+ QCOMPARE(entry->uuid(), uuid);
+ QCOMPARE(entry->historyItems().count(), history);
}
void TestGui::testDragAndDropGroup()