From bdac13745f2f2613aca133aa590ae2da1b67e6ad Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 28 Feb 2018 16:07:41 +0100 Subject: 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 Reviewed-by: Pier Luigi Fiorini --- tests/auto/client/client.pro | 3 +- tests/auto/client/wl_connect/tst_wlconnect.cpp | 58 ++++++++++++++++++++++++++ tests/auto/client/wl_connect/wl_connect.pro | 5 +++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 tests/auto/client/wl_connect/tst_wlconnect.cpp create mode 100644 tests/auto/client/wl_connect/wl_connect.pro (limited to 'tests') diff --git a/tests/auto/client/client.pro b/tests/auto/client/client.pro index d19326797..a668d37d5 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 000000000..661f7ad62 --- /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 +#include +#include + +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 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 000000000..28723beee --- /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 -- cgit v1.2.3