aboutsummaryrefslogtreecommitdiff
path: root/tests/integration/main.cpp
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-12 07:21:06 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-12 07:21:06 +0200
commit785f555bb27046c1e33a7cd2e5aed04c59f3e13a (patch)
tree2882d5f497594c20e7cfd972dba45a241a0615b6 /tests/integration/main.cpp
parent8927dc74777270afd74f8227283cbaf79d110488 (diff)
parent81e181c07147a124a39f797416c2e02076d30ef1 (diff)
downloadayatana-indicator-sound-785f555bb27046c1e33a7cd2e5aed04c59f3e13a.tar.gz
ayatana-indicator-sound-785f555bb27046c1e33a7cd2e5aed04c59f3e13a.tar.bz2
ayatana-indicator-sound-785f555bb27046c1e33a7cd2e5aed04c59f3e13a.zip
Merge branch 'tari01-pr/ubports-patches'
Attributes GH PR #26: https://github.com/AyatanaIndicators/ayatana-indicator-sound/pull/26
Diffstat (limited to 'tests/integration/main.cpp')
-rw-r--r--tests/integration/main.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/integration/main.cpp b/tests/integration/main.cpp
index a29b3b6..f42c90a 100644
--- a/tests/integration/main.cpp
+++ b/tests/integration/main.cpp
@@ -20,6 +20,7 @@
//#include <config.h>
#include <QCoreApplication>
+#include <QTemporaryDir>
#include <QTimer>
#include <gtest/gtest.h>
@@ -44,6 +45,22 @@ int main(int argc, char **argv)
qputenv("LANG", "C.UTF-8");
unsetenv("LC_ALL");
+ /*
+ * A couple of things rely on having a HOME directory:
+ * - The indicator itself relies on having a writable gsettings/dconf
+ * database, and the test relies on the functionality it provides.
+ * - The test starts Pulseaudio, which requires both a runtime and a
+ * state directory, both of which has a failback to the HOME.
+ * Provide a temporary HOME for the test and its child, which both prevents
+ * polluting the building user's HOME and allow the test to run where
+ * HOME=/nonexistent (i.e. autobuilder).
+ */
+ QTemporaryDir tmpHome;
+ if (!tmpHome.isValid())
+ qFatal("Cannot create a temporary HOME for the test.");
+
+ setenv("HOME", tmpHome.path().toLocal8Bit().constData(), true);
+
QCoreApplication application(argc, argv);
DBusMock::registerMetaTypes();
DBusTypes::registerMetaTypes();