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:
authorAndrew Meyer <apmeyer@bgsu.edu>2020-05-09 06:48:03 +0300
committerJonathan White <support@dmapps.us>2020-05-16 18:00:27 +0300
commit45848c3f611b88015c8227be197baac07a284b3d (patch)
tree04f2706254702c443a01cd09308acfbd1473338f /tests
parent2237cf0188af38898e1492f5d7ce2c0f087c8f35 (diff)
Implement 'Save Database Backup' option
Add an option in the 'Database' menu to save a backup of the current database. Add unit test for saving database copy * Open a test database, mark it as modified, and save a copy * Fail if the copy is not a valid database * Fail if the original database is saved * Fail if the original database is no longer marked as modified
Diffstat (limited to 'tests')
-rw-r--r--tests/gui/TestGui.cpp29
-rw-r--r--tests/gui/TestGui.h1
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp
index e167b9a30..5ca7ccdbe 100644
--- a/tests/gui/TestGui.cpp
+++ b/tests/gui/TestGui.cpp
@@ -1212,6 +1212,35 @@ void TestGui::testSaveAs()
tmpFile.remove();
}
+void TestGui::testSaveBackup()
+{
+ m_db->metadata()->setName("testSaveBackup");
+
+ QFileInfo fileInfo(m_dbFilePath);
+ QDateTime lastModified = fileInfo.lastModified();
+
+ // open temporary file so it creates a filename
+ TemporaryFile tmpFile;
+ QVERIFY(tmpFile.open());
+ QString tmpFileName = tmpFile.fileName();
+ tmpFile.remove();
+
+ // wait for modified timer
+ QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("testSaveBackup*"));
+
+ fileDialog()->setNextFileName(tmpFileName);
+
+ triggerAction("actionDatabaseSaveBackup");
+
+ QCOMPARE(m_tabWidget->tabName(m_tabWidget->currentIndex()), QString("testSaveBackup*"));
+
+ checkDatabase(tmpFileName);
+
+ fileInfo.refresh();
+ QCOMPARE(fileInfo.lastModified(), lastModified);
+ tmpFile.remove();
+}
+
void TestGui::testSave()
{
m_db->metadata()->setName("testSave");
diff --git a/tests/gui/TestGui.h b/tests/gui/TestGui.h
index cd329dd06..8d82e021e 100644
--- a/tests/gui/TestGui.h
+++ b/tests/gui/TestGui.h
@@ -61,6 +61,7 @@ private slots:
void testDragAndDropEntry();
void testDragAndDropGroup();
void testSaveAs();
+ void testSaveBackup();
void testSave();
void testDatabaseSettings();
void testKeePass1Import();