┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/main.cpp13
-rw-r--r--src/tests/CMakeLists.txt6
3 files changed, 20 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4faabe9d5..a8769454b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -668,6 +668,7 @@ install(
)
if(BUILD_TESTING)
+ target_compile_definitions(dolphin PRIVATE BUILD_TESTING)
add_subdirectory(tests)
endif()
diff --git a/src/main.cpp b/src/main.cpp
index 1ef608193..3c89f98a9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -37,6 +37,7 @@
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QSessionManager>
+#include <QTimer>
#if HAVE_X11
#include <private/qtx11extras_p.h>
@@ -142,6 +143,12 @@ int main(int argc, char **argv)
i18nc("@info:shell", "Set up Dolphin for administrative tasks.")));
parser.addOption(
QCommandLineOption(QStringList() << QStringLiteral("daemon"), i18nc("@info:shell", "Start Dolphin Daemon (only required for DBus Interface).")));
+#ifdef BUILD_TESTING
+ {
+ QCommandLineOption selfTestOption(QStringLiteral("self-test"));
+ parser.addOption(selfTestOption);
+ }
+#endif
parser.addPositionalArgument(QStringLiteral("+[Url]"), i18nc("@info:shell", "Document to open"));
parser.process(app);
@@ -275,5 +282,11 @@ int main(int argc, char **argv)
Q_UNUSED(feedbackProvider)
#endif
+#ifdef BUILD_TESTING
+ if (parser.isSet(QStringLiteral("self-test"))) {
+ QTimer::singleShot(std::chrono::milliseconds(500), &app, &QCoreApplication::quit);
+ }
+#endif
+
return app.exec(); // krazy:exclude=crash;
}
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 6a07ff8b9..a694ec8fb 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -99,6 +99,12 @@ add_test(
fi"
)
+# Smoke test: launch Dolphin, verify it starts without crashing, then quit.
+if(NOT WIN32)
+ add_test(NAME dolphin_smoketest COMMAND "$<TARGET_FILE:dolphin>" --self-test)
+ set_tests_properties(dolphin_smoketest PROPERTIES TIMEOUT 30)
+endif()
+
find_gem(test-unit)
set_package_properties(Gem_test-unit PROPERTIES
TYPE RECOMMENDED