mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Core tests instantiate QCoreApplication instead of QApplication.
This way they can be used without a running X server.
This commit is contained in:
parent
17d0fb9963
commit
a61057d7f6
@ -14,7 +14,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src)
|
||||
|
||||
add_definitions(-DQT_TEST_LIB)
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include "tests.h"
|
||||
#include "crypto/Crypto.h"
|
||||
#include "crypto/CryptoHash.h"
|
||||
|
||||
@ -47,4 +48,4 @@ void TestCryptoHash::test()
|
||||
QByteArray::fromHex("0b56e5f65263e747af4a833bd7dd7ad26a64d7a4de7c68e52364893dca0766b4"));
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestCryptoHash);
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestCryptoHash)
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include "modeltest.h"
|
||||
#include "tests.h"
|
||||
#include "core/Entry.h"
|
||||
#include "core/Group.h"
|
||||
#include "gui/EntryModel.h"
|
||||
@ -92,4 +93,4 @@ void TestEntryModel::test()
|
||||
delete model;
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestEntryModel);
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestEntryModel)
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <QtTest/QSignalSpy>
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include "tests.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Group.h"
|
||||
#include "crypto/Crypto.h"
|
||||
@ -175,4 +176,4 @@ void TestGroup::testDeleteSignals()
|
||||
delete group;
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestGroup);
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestGroup)
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include "modeltest.h"
|
||||
#include "tests.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Group.h"
|
||||
#include "crypto/Crypto.h"
|
||||
@ -109,4 +110,4 @@ void TestGroupModel::test()
|
||||
delete model;
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestGroupModel);
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestGroupModel)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include "tests.h"
|
||||
#include "crypto/Crypto.h"
|
||||
#include "streams/HashedBlockStream.h"
|
||||
|
||||
@ -69,4 +70,4 @@ void TestHashedBlockStream::testWriteRead()
|
||||
buffer.buffer().clear();
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestHashedBlockStream);
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestHashedBlockStream)
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include "tests.h"
|
||||
#include "crypto/Crypto.h"
|
||||
#include "crypto/CryptoHash.h"
|
||||
#include "crypto/SymmetricCipher.h"
|
||||
@ -77,4 +78,4 @@ void TestKeePass2RandomStream::test()
|
||||
QCOMPARE(randomStreamData, cipherData);
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestKeePass2RandomStream);
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestKeePass2RandomStream)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include "config-keepassx-tests.h"
|
||||
#include "tests.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Group.h"
|
||||
#include "core/Metadata.h"
|
||||
@ -91,4 +92,4 @@ void TestKeePass2Reader::testProtectedStrings()
|
||||
delete reader;
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestKeePass2Reader);
|
||||
QTEST_MAIN(TestKeePass2Reader)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include "tests.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Group.h"
|
||||
#include "core/Metadata.h"
|
||||
@ -78,4 +79,4 @@ void TestKeePass2Writer::testProtectedAttributes()
|
||||
QCOMPARE(entry->isAttributeProtected("test"), true);
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestKeePass2Writer);
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestKeePass2Writer)
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include "tests.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Group.h"
|
||||
#include "core/Metadata.h"
|
||||
@ -321,4 +322,4 @@ void TestKeePass2XmlReader::testDeletedObjects()
|
||||
QVERIFY(objList.isEmpty());
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestKeePass2XmlReader);
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestKeePass2XmlReader)
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include "config-keepassx-tests.h"
|
||||
#include "tests.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Metadata.h"
|
||||
#include "crypto/Crypto.h"
|
||||
@ -144,4 +145,4 @@ void TestKeys::testFileKeyError()
|
||||
errorMsg = "";
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestKeys);
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestKeys)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include "tests.h"
|
||||
#include "crypto/Crypto.h"
|
||||
#include "crypto/SymmetricCipher.h"
|
||||
#include "streams/SymmetricCipherStream.h"
|
||||
@ -160,4 +161,4 @@ void TestSymmetricCipher::testSalsa20()
|
||||
QCOMPARE(cipherTextB.mid(448, 64), expectedCipherText4);
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestSymmetricCipher);
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestSymmetricCipher)
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <QtGui/QPushButton>
|
||||
|
||||
#include "config-keepassx-tests.h"
|
||||
#include "tests.h"
|
||||
#include "crypto/Crypto.h"
|
||||
#include "gui/FileDialog.h"
|
||||
#include "gui/MainWindow.h"
|
||||
@ -65,4 +66,4 @@ void TestGui::cleanupTestCase()
|
||||
delete m_mainWindow;
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestGui);
|
||||
KEEPASSX_QTEST_GUI_MAIN(TestGui)
|
||||
|
34
tests/tests.h
Normal file
34
tests/tests.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 or (at your option)
|
||||
* version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KEEPASSX_TESTS_H
|
||||
#define KEEPASSX_TESTS_H
|
||||
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#define KEEPASSX_QTEST_CORE_MAIN(TestObject) \
|
||||
int main(int argc, char *argv[]) \
|
||||
{ \
|
||||
QCoreApplication app(argc, argv); \
|
||||
TestObject tc; \
|
||||
return QTest::qExec(&tc, argc, argv); \
|
||||
}
|
||||
|
||||
// just for the sake of a consistent naming scheme
|
||||
#define KEEPASSX_QTEST_GUI_MAIN QTEST_MAIN
|
||||
|
||||
#endif // KEEPASSX_TESTS_H
|
Loading…
Reference in New Issue
Block a user