GCC Code Coverage Report


Directory: ./
File: autotests/server/test_no_xdg_runtime_dir.cpp
Date: 2024-01-22 17:25:27
Exec Total Coverage
Lines: 12 12 100.0%
Branches: 15 30 50.0%

Line Branch Exec Source
1 /********************************************************************
2 Copyright 2016 Martin Gräßlin <mgraesslin@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), which shall
10 act as a proxy defined in Section 6 of version 3 of the license.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 *********************************************************************/
20 #include <QtTest>
21
22 #include "../../server/display.h"
23
24 class NoXdgRuntimeDirTest : public QObject
25 {
26 Q_OBJECT
27 private Q_SLOTS:
28 void initTestCase();
29 void testCreate();
30 };
31
32 1 void NoXdgRuntimeDirTest::initTestCase()
33 {
34 1 qunsetenv("XDG_RUNTIME_DIR");
35 1 }
36
37 constexpr auto socket_name{"wrapland-test-no-xdg-runtime-dir-0"};
38
39 1 void NoXdgRuntimeDirTest::testCreate()
40 {
41 // this test verifies that not having an XDG_RUNTIME_DIR is handled gracefully
42 // the server cannot start, but should not crash
43 1 Wrapland::Server::Display display;
44
45
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 display.set_socket_name(socket_name);
46
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 QVERIFY(!display.running());
47
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 display.start();
48
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 QVERIFY(!display.running());
49
50 // call into dispatchEvents should not crash
51
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 display.dispatchEvents();
52
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 }
53
54
4/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
1 QTEST_GUILESS_MAIN(NoXdgRuntimeDirTest)
55 #include "test_no_xdg_runtime_dir.moc"
56