diff options
Diffstat (limited to 'tests/manual/qscreen_xrandr/tst_qscreen_xrandr.cpp')
-rw-r--r-- | tests/manual/qscreen_xrandr/tst_qscreen_xrandr.cpp | 91 |
1 files changed, 63 insertions, 28 deletions
diff --git a/tests/manual/qscreen_xrandr/tst_qscreen_xrandr.cpp b/tests/manual/qscreen_xrandr/tst_qscreen_xrandr.cpp index 293dec47b4..542214792c 100644 --- a/tests/manual/qscreen_xrandr/tst_qscreen_xrandr.cpp +++ b/tests/manual/qscreen_xrandr/tst_qscreen_xrandr.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2022 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$ -** -****************************************************************************/ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <qpainter.h> #include <qrasterwindow.h> @@ -43,6 +18,7 @@ private slots: void xrandr_15_scale(); void xrandr_15_off_and_on(); void xrandr_15_primary(); + void xrandr_15_rotate(); private: void xrandr_process(const QStringList &arguments = {}); @@ -143,7 +119,7 @@ void tst_QScreen_Xrandr::xrandr_15_scale() QVERIFY(height2 == expectedHeight); QVERIFY(width2 == expectedWidth); - QSignalSpy geometryChangedSpy2(screen1, &QScreen::geometryChanged); + QSignalSpy geometryChangedSpy2(screen2, &QScreen::geometryChanged); // "xrandr --output name1 --scale 1x1" args.clear(); @@ -232,6 +208,65 @@ void tst_QScreen_Xrandr::xrandr_15_primary() } } +void tst_QScreen_Xrandr::xrandr_15_rotate() +{ + QList<QScreen *> screens = QGuiApplication::screens(); + int ss = screens.size(); + if (ss < 1) + QSKIP("This test requires at least one screen."); + + QScreen *screen1 = screens.at(0); + QString name1 = screen1->name(); + int height1 = screen1->size().height(); + int width1 = screen1->size().width(); + qDebug() << "screen " << name1 << ": height=" << height1 << ", width=" << width1; + + int expectedHeight = width1; + int expectedWidth = height1; + + QSignalSpy geometryChangedSpy1(screen1, &QScreen::geometryChanged); + + // "xrandr --output name1 --rotate left" + QStringList args; + args << "--output" << name1 << "--rotate" << "left"; + xrandr_process(args); + QTRY_COMPARE(geometryChangedSpy1.count(), 1); + + QList<QScreen *> screens2 = QGuiApplication::screens(); + QVERIFY(screens2.size() >= 1); + QScreen *screen2 = nullptr; + for (QScreen *s : screens2) { + if (s->name() == name1) + screen2 = s; + } + int height2 = screen2->size().height(); + int width2 = screen2->size().width(); + qDebug() << "screen " << name1 << ": height=" << height2 << ", width=" << width2; + QVERIFY(height2 == expectedHeight); + QVERIFY(width2 == expectedWidth); + + QSignalSpy geometryChangedSpy2(screen2, &QScreen::geometryChanged); + + // "xrandr --output name1 --rotate normal" + args.clear(); + args << "--output" << name1 << "--rotate" << "normal"; + xrandr_process(args); + QTRY_COMPARE(geometryChangedSpy2.count(), 1); + + QList<QScreen *> screens3 = QGuiApplication::screens(); + QVERIFY(screens3.size() >= 1); + QScreen *screen3 = nullptr; + for (QScreen *s : screens3) { + if (s->name() == name1) + screen3 = s; + } + int height3 = screen3->size().height(); + int width3 = screen3->size().width(); + qDebug() << "screen " << name1 << ": height=" << height3 << ", width=" << width3; + QVERIFY(height3 == height1); + QVERIFY(width3 == width1); +} + void tst_QScreen_Xrandr::xrandr_process(const QStringList &args) { QString prog = "xrandr"; |