diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2018-02-28 16:07:41 +0100 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2018-03-08 10:34:08 +0000 |
commit | bdac13745f2f2613aca133aa590ae2da1b67e6ad (patch) | |
tree | 04471907bc9eb6887ba6889839bedc0f1986bea5 | |
parent | 223ddfbae6cccce87d1a778379494c381d4056f9 (diff) | |
download | qtwayland-bdac13745f2f2613aca133aa590ae2da1b67e6ad.tar.gz |
Test what happens when wl_display_connect fails
A failed wl_display_connect should make the platform plugin fail gracefully.
Add a test for it to make sure.
Change-Id: I87a3d9ee151fcdb1bc6ad9ffba44ad5014ede005
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
-rw-r--r-- | tests/auto/client/client.pro | 3 | ||||
-rw-r--r-- | tests/auto/client/wl_connect/tst_wlconnect.cpp | 58 | ||||
-rw-r--r-- | tests/auto/client/wl_connect/wl_connect.pro | 5 |
3 files changed, 65 insertions, 1 deletions
diff --git a/tests/auto/client/client.pro b/tests/auto/client/client.pro index d1932679..a668d37d 100644 --- a/tests/auto/client/client.pro +++ b/tests/auto/client/client.pro @@ -2,4 +2,5 @@ TEMPLATE=subdirs SUBDIRS += \ client \ - xdgshellv6 + xdgshellv6 \ + wl_connect diff --git a/tests/auto/client/wl_connect/tst_wlconnect.cpp b/tests/auto/client/wl_connect/tst_wlconnect.cpp new file mode 100644 index 00000000..661f7ad6 --- /dev/null +++ b/tests/auto/client/wl_connect/tst_wlconnect.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QGuiApplication> +#include <qpa/qplatformintegrationfactory_p.h> + +class tst_WlConnect : public QObject +{ + Q_OBJECT +private slots: + void failsGracefully() + { + // This tests whether the Wayland platform integration will fail gracefully when it's + // unable to connect to a compositor + + // Make sure the connection actually fails + setenv("XDG_RUNTIME_DIR", "/dev/null", 1); // a place where there are no Wayland sockets + setenv("WAYLAND_DISPLAY", "qt_invalid_socket", 1); // just to be sure + + QStringList arguments; + QString platformPluginPath; + int argc = 0; + char **argv = nullptr; //It's not currently used by the wayland plugin + auto *platformIntegration = QPlatformIntegrationFactory::create("wayland", arguments, argc, argv, platformPluginPath); + + // The factory method should return nullptr to signify it failed gracefully + Q_ASSERT(!platformIntegration); + } +}; + +QTEST_APPLESS_MAIN(tst_WlConnect) +#include <tst_wlconnect.moc> diff --git a/tests/auto/client/wl_connect/wl_connect.pro b/tests/auto/client/wl_connect/wl_connect.pro new file mode 100644 index 00000000..28723bee --- /dev/null +++ b/tests/auto/client/wl_connect/wl_connect.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +QT += gui-private testlib + +SOURCES += tst_wlconnect.cpp +TARGET = tst_wlconnect |