diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index 1886e594f..7d3ce873b 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -17,6 +17,7 @@ #include "TestGui.h" +#include #include #include #include @@ -276,10 +277,12 @@ void TestGui::testSaveAs() m_db->metadata()->setName("SaveAs"); + QTemporaryFile* tmpFile = new QTemporaryFile(); // open temporary file so it creates a filename - QVERIFY(m_tmpFile.open()); - m_tmpFile.close(); - fileDialog()->setNextFileName(m_tmpFile.fileName()); + QVERIFY(tmpFile->open()); + m_tmpFileName = tmpFile->fileName(); + delete tmpFile; + fileDialog()->setNextFileName(m_tmpFileName); triggerAction("actionDatabaseSaveAs"); @@ -357,6 +360,7 @@ void TestGui::testDatabaseLocking() void TestGui::cleanupTestCase() { delete m_mainWindow; + QFile::remove(m_tmpFileName); } void TestGui::checkDatabase() @@ -364,7 +368,7 @@ void TestGui::checkDatabase() CompositeKey key; key.addKey(PasswordKey("a")); KeePass2Reader reader; - QScopedPointer dbSaved(reader.readDatabase(m_tmpFile.fileName(), key)); + QScopedPointer dbSaved(reader.readDatabase(m_tmpFileName, key)); QVERIFY(dbSaved); QVERIFY(!reader.hasError()); QCOMPARE(dbSaved->metadata()->name(), m_db->metadata()->name()); diff --git a/tests/gui/TestGui.h b/tests/gui/TestGui.h index dbf733daa..7e823708d 100644 --- a/tests/gui/TestGui.h +++ b/tests/gui/TestGui.h @@ -20,7 +20,6 @@ #include #include -#include class Database; class DatabaseTabWidget; @@ -57,7 +56,7 @@ private: MainWindow* m_mainWindow; DatabaseTabWidget* m_tabWidget; DatabaseWidget* m_dbWidget; - QTemporaryFile m_tmpFile; + QString m_tmpFileName; Database* m_db; };