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
diff options
context:
space:
mode:
authorfrostasm <frost.asm@gmail.com>2017-12-22 21:05:33 +0300
committerfrostasm <frost.asm@gmail.com>2018-01-03 17:12:05 +0300
commit3720c5ef7900539abb76c7d3925b142d4894c09f (patch)
treee26cc53dc3805f821496292ccf6e14fab887f343 /tests
parent165d664524b375bcba26696fed5e2f942a18d481 (diff)
Add test for drag and drop database files into main window
Diffstat (limited to 'tests')
-rw-r--r--tests/gui/TestGui.cpp37
-rw-r--r--tests/gui/TestGui.h1
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp
index 664bfd654..17b2736cc 100644
--- a/tests/gui/TestGui.cpp
+++ b/tests/gui/TestGui.cpp
@@ -952,6 +952,43 @@ void TestGui::testDatabaseLocking()
QCOMPARE(m_tabWidget->tabText(0).remove('&'), origDbName);
}
+void TestGui::testDragAndDropKdbxFiles()
+{
+ const int openedDatabasesCount = m_tabWidget->count();
+
+ const QString badDatabaseFilePath(QString(KEEPASSX_TEST_DATA_DIR).append("/NotDatabase.notkdbx"));
+ QMimeData badMimeData;
+ badMimeData.setUrls({QUrl::fromLocalFile(badDatabaseFilePath)});
+ QDragEnterEvent badDragEvent(QPoint(1, 1), Qt::LinkAction, &badMimeData, Qt::LeftButton, Qt::NoModifier);
+ qApp->notify(m_mainWindow, &badDragEvent);
+ QCOMPARE(badDragEvent.isAccepted(), false);
+
+ QDropEvent badDropEvent(QPoint(1, 1), Qt::LinkAction, &badMimeData, Qt::LeftButton, Qt::NoModifier);
+ qApp->notify(m_mainWindow, &badDropEvent);
+ QCOMPARE(badDropEvent.isAccepted(), false);
+
+ QCOMPARE(m_tabWidget->count(), openedDatabasesCount);
+
+ const QString goodDatabaseFilePath(QString(KEEPASSX_TEST_DATA_DIR).append("/NewDatabase.kdbx"));
+ QMimeData goodMimeData;
+ goodMimeData.setUrls({QUrl::fromLocalFile(goodDatabaseFilePath)});
+ QDragEnterEvent goodDragEvent(QPoint(1, 1), Qt::LinkAction, &goodMimeData, Qt::LeftButton, Qt::NoModifier);
+ qApp->notify(m_mainWindow, &goodDragEvent);
+ QCOMPARE(goodDragEvent.isAccepted(), true);
+
+ QDropEvent goodDropEvent(QPoint(1, 1), Qt::LinkAction, &goodMimeData, Qt::LeftButton, Qt::NoModifier);
+ qApp->notify(m_mainWindow, &goodDropEvent);
+ QCOMPARE(goodDropEvent.isAccepted(), true);
+
+ QCOMPARE(m_tabWidget->count(), openedDatabasesCount + 1);
+
+ MessageBox::setNextAnswer(QMessageBox::No);
+ triggerAction("actionDatabaseClose");
+ Tools::wait(100);
+
+ QCOMPARE(m_tabWidget->count(), openedDatabasesCount);
+}
+
void TestGui::cleanupTestCase()
{
delete m_mainWindow;
diff --git a/tests/gui/TestGui.h b/tests/gui/TestGui.h
index 5ec8237b3..1a2b24e74 100644
--- a/tests/gui/TestGui.h
+++ b/tests/gui/TestGui.h
@@ -60,6 +60,7 @@ private slots:
void testDatabaseSettings();
void testKeePass1Import();
void testDatabaseLocking();
+ void testDragAndDropKdbxFiles();
private:
int addCannedEntries();