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:
authorFelix Geyer <debfx@fobos.de>2012-01-02 01:04:27 +0400
committerFelix Geyer <debfx@fobos.de>2012-01-02 01:04:27 +0400
commita61057d7f666d58b62f7f593b59dc205e10e3b6f (patch)
treece0d2e9ff7ec6ce7e38531b33581ad6962cc7f10 /tests
parent17d0fb9963d9d02ea7d6fc8b52631d7ae6705cd6 (diff)
Core tests instantiate QCoreApplication instead of QApplication.
This way they can be used without a running X server.
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt2
-rw-r--r--tests/TestCryptoHash.cpp3
-rw-r--r--tests/TestEntryModel.cpp3
-rw-r--r--tests/TestGroup.cpp3
-rw-r--r--tests/TestGroupModel.cpp3
-rw-r--r--tests/TestHashedBlockStream.cpp3
-rw-r--r--tests/TestKeePass2RandomStream.cpp3
-rw-r--r--tests/TestKeePass2Reader.cpp3
-rw-r--r--tests/TestKeePass2Writer.cpp3
-rw-r--r--tests/TestKeePass2XmlReader.cpp3
-rw-r--r--tests/TestKeys.cpp3
-rw-r--r--tests/TestSymmetricCipher.cpp3
-rw-r--r--tests/gui/TestGui.cpp3
-rw-r--r--tests/tests.h34
14 files changed, 59 insertions, 13 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index cf131c435..31f2539a3 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -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)
diff --git a/tests/TestCryptoHash.cpp b/tests/TestCryptoHash.cpp
index ea99d7fe4..cabb545a8 100644
--- a/tests/TestCryptoHash.cpp
+++ b/tests/TestCryptoHash.cpp
@@ -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)
diff --git a/tests/TestEntryModel.cpp b/tests/TestEntryModel.cpp
index 8555de4c4..cd8cb3f66 100644
--- a/tests/TestEntryModel.cpp
+++ b/tests/TestEntryModel.cpp
@@ -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)
diff --git a/tests/TestGroup.cpp b/tests/TestGroup.cpp
index dbcc050d8..8a45591f4 100644
--- a/tests/TestGroup.cpp
+++ b/tests/TestGroup.cpp
@@ -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)
diff --git a/tests/TestGroupModel.cpp b/tests/TestGroupModel.cpp
index 70a6e4c66..82a6bff24 100644
--- a/tests/TestGroupModel.cpp
+++ b/tests/TestGroupModel.cpp
@@ -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)
diff --git a/tests/TestHashedBlockStream.cpp b/tests/TestHashedBlockStream.cpp
index b15e7870c..74eccd111 100644
--- a/tests/TestHashedBlockStream.cpp
+++ b/tests/TestHashedBlockStream.cpp
@@ -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)
diff --git a/tests/TestKeePass2RandomStream.cpp b/tests/TestKeePass2RandomStream.cpp
index af71df863..cf520d1d1 100644
--- a/tests/TestKeePass2RandomStream.cpp
+++ b/tests/TestKeePass2RandomStream.cpp
@@ -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)
diff --git a/tests/TestKeePass2Reader.cpp b/tests/TestKeePass2Reader.cpp
index c92624ef2..4a37bd199 100644
--- a/tests/TestKeePass2Reader.cpp
+++ b/tests/TestKeePass2Reader.cpp
@@ -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)
diff --git a/tests/TestKeePass2Writer.cpp b/tests/TestKeePass2Writer.cpp
index 87ea72527..3513b92da 100644
--- a/tests/TestKeePass2Writer.cpp
+++ b/tests/TestKeePass2Writer.cpp
@@ -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)
diff --git a/tests/TestKeePass2XmlReader.cpp b/tests/TestKeePass2XmlReader.cpp
index cac8cb314..641e777f5 100644
--- a/tests/TestKeePass2XmlReader.cpp
+++ b/tests/TestKeePass2XmlReader.cpp
@@ -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)
diff --git a/tests/TestKeys.cpp b/tests/TestKeys.cpp
index 3854efe2f..44a09771f 100644
--- a/tests/TestKeys.cpp
+++ b/tests/TestKeys.cpp
@@ -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)
diff --git a/tests/TestSymmetricCipher.cpp b/tests/TestSymmetricCipher.cpp
index 669a58049..f26c65659 100644
--- a/tests/TestSymmetricCipher.cpp
+++ b/tests/TestSymmetricCipher.cpp
@@ -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)
diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp
index 69f8ca965..51e9df4a9 100644
--- a/tests/gui/TestGui.cpp
+++ b/tests/gui/TestGui.cpp
@@ -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)
diff --git a/tests/tests.h b/tests/tests.h
new file mode 100644
index 000000000..cfb679f9b
--- /dev/null
+++ b/tests/tests.h
@@ -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