diff options
author | Jonathan White <support@dmapps.us> | 2020-03-09 05:45:51 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2020-03-10 01:03:20 +0300 |
commit | 1d7ef5d4eb67f935741d95f638770e38ed04f059 (patch) | |
tree | 3469a5e1a709ce371e0952b7437d3ec14034ef90 /tests | |
parent | a8c02fdc3cb39e8cabfd7012a6104e60938d3bb8 (diff) |
Move theme detection into Application
* Add function to Application to quickly determine if in light or dark theme
* Add kpxcApp symbol
* Explicitly define main function for GUI tests to improve performance and use custom Application.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gui/TestGui.cpp | 21 | ||||
-rw-r--r-- | tests/gui/TestGuiBrowser.cpp | 17 |
2 files changed, 32 insertions, 6 deletions
diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index 8ce9b0587..76766c8dc 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -74,16 +74,27 @@ #include "keys/FileKey.h" #include "keys/PasswordKey.h" -QTEST_MAIN(TestGui) +int main(int argc, char* argv[]) +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); +#endif + Application app(argc, argv); + app.setApplicationName("KeePassXC"); + app.setApplicationVersion(KEEPASSXC_VERSION); + app.setQuitOnLastWindowClosed(false); + app.setAttribute(Qt::AA_Use96Dpi, true); + QTEST_DISABLE_KEYPAD_NAVIGATION + TestGui tc; + QTEST_SET_MAIN_SOURCE_PATH + return QTest::qExec(&tc, argc, argv); +} static QString dbFileName = QStringLiteral(KEEPASSX_TEST_DATA_DIR).append("/NewDatabase.kdbx"); void TestGui::initTestCase() { - Application::setApplicationName("KeePassXC"); - Application::setApplicationVersion(KEEPASSXC_VERSION); - QApplication::setQuitOnLastWindowClosed(false); - QVERIFY(Crypto::init()); Config::createTempFileInstance(); // Disable autosave so we can test the modified file indicator diff --git a/tests/gui/TestGuiBrowser.cpp b/tests/gui/TestGuiBrowser.cpp index 834aea581..1750caa80 100644 --- a/tests/gui/TestGuiBrowser.cpp +++ b/tests/gui/TestGuiBrowser.cpp @@ -47,7 +47,22 @@ #include "gui/entry/EditEntryWidget.h" #include "gui/entry/EntryView.h" -QTEST_MAIN(TestGuiBrowser) +int main(int argc, char* argv[]) +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); +#endif + Application app(argc, argv); + app.setApplicationName("KeePassXC"); + app.setApplicationVersion(KEEPASSXC_VERSION); + app.setQuitOnLastWindowClosed(false); + app.setAttribute(Qt::AA_Use96Dpi, true); + QTEST_DISABLE_KEYPAD_NAVIGATION + TestGuiBrowser tc; + QTEST_SET_MAIN_SOURCE_PATH + return QTest::qExec(&tc, argc, argv); +} void TestGuiBrowser::initTestCase() { |