diff options
author | Liang Qi <liang.qi@qt.io> | 2021-09-15 16:41:10 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2021-09-18 16:29:39 +0200 |
commit | 0d3b395c164039cae0c72ab27294c86f0adbbc89 (patch) | |
tree | 155d1003aa4e6d63e3bfe1e7e0d86d230fb6775d /tests | |
parent | b6bcf01b81626b966a93ddd4928059f4cb3e656a (diff) |
tests/xcb: add a test for screen off and on
Task-number: QTBUG-96247
Change-Id: I1fd6f21ad914480b7e8d07227ee80184e305276a
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/manual/qscreen_xrandr/tst_qscreen_xrandr.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/manual/qscreen_xrandr/tst_qscreen_xrandr.cpp b/tests/manual/qscreen_xrandr/tst_qscreen_xrandr.cpp index 9eeba585c9..166b11e2f6 100644 --- a/tests/manual/qscreen_xrandr/tst_qscreen_xrandr.cpp +++ b/tests/manual/qscreen_xrandr/tst_qscreen_xrandr.cpp @@ -41,6 +41,7 @@ class tst_QScreen_Xrandr: public QObject private slots: void xrandr_15_merge_and_unmerge(); void xrandr_15_scale(); + void xrandr_15_off_and_on(); private: void xrandr_process(const QStringList &arguments = {}); @@ -163,6 +164,41 @@ void tst_QScreen_Xrandr::xrandr_15_scale() QVERIFY(width3 == width1); } +void tst_QScreen_Xrandr::xrandr_15_off_and_on() +{ + QList<QScreen *> screens = QGuiApplication::screens(); + int ss = screens.size(); + if (ss < 1) + QSKIP("This test requires at least one screen."); + + QStringList names; + for (QScreen *s : screens) + names << s->name(); + + QStringList args; + for (int i = ss; i > 0; i--) { + QString name = names.at(i-1); + qDebug() << "i=" << i << ", name:" << name; + args.clear(); + args << "--output" << name << "--off"; + xrandr_process(args); + QTest::qWait(500); + + QVERIFY(QGuiApplication::screens().size() == (i != 1 ? i - 1 : i)); + } + + for (int i = ss; i > 0; i--) { + QString name = names.at(i-1); + qDebug() << "i=" << i << ", name:" << name; + args.clear(); + args << "--output" << name << "--auto"; + xrandr_process(args); + QTest::qWait(500); + + QVERIFY(QGuiApplication::screens().size() == (i == ss ? 1 : ss - i + 1)); + } +} + void tst_QScreen_Xrandr::xrandr_process(const QStringList &args) { QString prog = "xrandr"; |