| 1 |
// Copyright (C) 2018 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
#include <QtTest/QtTest> |
| 5 |
#include <QGuiApplication> |
| 6 |
#include <qpa/qplatformintegrationfactory_p.h> |
| 7 |
|
| 8 |
class tst_WlConnect : public QObject |
| 9 |
{ |
| 10 |
Q_OBJECT |
| 11 |
private slots: |
| 12 |
void failsGracefully() |
| 13 |
{ |
| 14 |
// This tests whether the Wayland platform integration will fail gracefully when it's |
| 15 |
// unable to connect to a compositor |
| 16 |
|
| 17 |
// Make sure the connection actually fails |
| 18 |
qputenv("XDG_RUNTIME_DIR", "/dev/null"); // a place where there are no Wayland sockets |
| 19 |
qputenv("WAYLAND_DISPLAY", "qt_invalid_socket"); // just to be sure |
| 20 |
|
| 21 |
QStringList arguments; |
| 22 |
QString platformPluginPath; |
| 23 |
int argc = 0; |
| 24 |
char **argv = nullptr; //It's not currently used by the wayland plugin |
| 25 |
auto *platformIntegration = QPlatformIntegrationFactory::create("wayland", arguments, argc, argv, platformPluginPath); |
| 26 |
|
| 27 |
// The factory method should return nullptr to signify it failed gracefully |
| 28 |
Q_ASSERT(!platformIntegration); |
| 29 |
} |
| 30 |
}; |
| 31 |
|
| 32 |
QTEST_APPLESS_MAIN(tst_WlConnect) |
| 33 |
#include <tst_wlconnect.moc> |