2017-11-16 20:48:19 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2017 Martin Flöser <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#include "kwin_wayland_test.h"
|
2020-03-04 07:55:26 +00:00
|
|
|
#include "abstract_client.h"
|
[autotests] Fix failing autotests
Summary:
After recent output-related changes testIdleInhibition and
testColorCorrectionNightColor started failing with the following output:
❯ dbus-run-session bin/testIdleInhibition
********* Start testing of TestIdleInhibition *********
Config: Using QtTest library 5.13.0, Qt 5.13.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 9.1.0)
QFATAL : TestIdleInhibition::initTestCase() ASSERT: "mode.size.isValid()" in file /home/vlad/Workspace/KDE/src/frameworks/kwayland/src/server/outputdevice_interface.cpp, line 188
FAIL! : TestIdleInhibition::initTestCase() Received a fatal error.
Loc: [Unknown file(0)]
Totals: 0 passed, 1 failed, 0 skipped, 0 blacklisted, 13ms
********* Finished testing of TestIdleInhibition ********
Apparently, they both don't initialize virtual outputs properly.
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23539
2019-08-28 16:05:59 +00:00
|
|
|
#include "platform.h"
|
2017-11-16 20:48:19 +00:00
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
|
|
|
|
#include <KWayland/Client/idleinhibit.h>
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
#include <KWayland/Client/xdgshell.h>
|
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/display.h>
|
|
|
|
#include <KWaylandServer/idle_interface.h>
|
2017-11-16 20:48:19 +00:00
|
|
|
|
|
|
|
using namespace KWin;
|
|
|
|
using namespace KWayland::Client;
|
2020-04-29 15:18:41 +00:00
|
|
|
using KWaylandServer::IdleInterface;
|
2017-11-16 20:48:19 +00:00
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_idle_inhbition_test-0");
|
|
|
|
|
|
|
|
class TestIdleInhibition : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void testInhibit_data();
|
|
|
|
void testInhibit();
|
2018-12-04 09:32:37 +00:00
|
|
|
void testDontInhibitWhenNotOnCurrentDesktop();
|
|
|
|
void testDontInhibitWhenMinimized();
|
|
|
|
void testDontInhibitWhenUnmapped();
|
|
|
|
void testDontInhibitWhenLeftCurrentDesktop();
|
2017-11-16 20:48:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void TestIdleInhibition::initTestCase()
|
|
|
|
{
|
|
|
|
qRegisterMetaType<KWin::AbstractClient*>();
|
|
|
|
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
|
|
|
QVERIFY(applicationStartedSpy.isValid());
|
[autotests] Fix failing autotests
Summary:
After recent output-related changes testIdleInhibition and
testColorCorrectionNightColor started failing with the following output:
❯ dbus-run-session bin/testIdleInhibition
********* Start testing of TestIdleInhibition *********
Config: Using QtTest library 5.13.0, Qt 5.13.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 9.1.0)
QFATAL : TestIdleInhibition::initTestCase() ASSERT: "mode.size.isValid()" in file /home/vlad/Workspace/KDE/src/frameworks/kwayland/src/server/outputdevice_interface.cpp, line 188
FAIL! : TestIdleInhibition::initTestCase() Received a fatal error.
Loc: [Unknown file(0)]
Totals: 0 passed, 1 failed, 0 skipped, 0 blacklisted, 13ms
********* Finished testing of TestIdleInhibition ********
Apparently, they both don't initialize virtual outputs properly.
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23539
2019-08-28 16:05:59 +00:00
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
2017-11-16 20:48:19 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
|
[autotests] Fix failing autotests
Summary:
After recent output-related changes testIdleInhibition and
testColorCorrectionNightColor started failing with the following output:
❯ dbus-run-session bin/testIdleInhibition
********* Start testing of TestIdleInhibition *********
Config: Using QtTest library 5.13.0, Qt 5.13.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 9.1.0)
QFATAL : TestIdleInhibition::initTestCase() ASSERT: "mode.size.isValid()" in file /home/vlad/Workspace/KDE/src/frameworks/kwayland/src/server/outputdevice_interface.cpp, line 188
FAIL! : TestIdleInhibition::initTestCase() Received a fatal error.
Loc: [Unknown file(0)]
Totals: 0 passed, 1 failed, 0 skipped, 0 blacklisted, 13ms
********* Finished testing of TestIdleInhibition ********
Apparently, they both don't initialize virtual outputs properly.
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23539
2019-08-28 16:05:59 +00:00
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
|
2017-11-16 20:48:19 +00:00
|
|
|
|
|
|
|
kwinApp()->start();
|
2020-07-07 09:32:29 +00:00
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2017-11-16 20:48:19 +00:00
|
|
|
waylandServer()->initWorkspace();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestIdleInhibition::init()
|
|
|
|
{
|
|
|
|
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::IdleInhibition));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestIdleInhibition::cleanup()
|
|
|
|
{
|
|
|
|
Test::destroyWaylandConnection();
|
2018-12-04 09:32:37 +00:00
|
|
|
|
|
|
|
VirtualDesktopManager::self()->setCount(1);
|
|
|
|
QCOMPARE(VirtualDesktopManager::self()->count(), 1u);
|
2017-11-16 20:48:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestIdleInhibition::testInhibit_data()
|
|
|
|
{
|
2019-08-27 15:01:14 +00:00
|
|
|
QTest::addColumn<Test::XdgShellSurfaceType>("type");
|
2017-11-16 20:48:19 +00:00
|
|
|
|
2019-08-27 15:01:14 +00:00
|
|
|
QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable;
|
2017-11-16 20:48:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestIdleInhibition::testInhibit()
|
|
|
|
{
|
|
|
|
auto idle = waylandServer()->display()->findChild<IdleInterface*>();
|
|
|
|
QVERIFY(idle);
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged);
|
|
|
|
QVERIFY(inhibitedSpy.isValid());
|
|
|
|
|
|
|
|
// now create window
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
2019-08-27 15:01:14 +00:00
|
|
|
QFETCH(Test::XdgShellSurfaceType, type);
|
|
|
|
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data()));
|
2017-11-16 20:48:19 +00:00
|
|
|
|
|
|
|
// now create inhibition on window
|
|
|
|
QScopedPointer<IdleInhibitor> inhibitor(Test::waylandIdleInhibitManager()->createInhibitor(surface.data()));
|
|
|
|
QVERIFY(inhibitor->isValid());
|
2018-11-28 22:55:44 +00:00
|
|
|
|
|
|
|
// render the client
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
|
2017-11-16 20:48:19 +00:00
|
|
|
// this should inhibit our server object
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
|
|
|
|
// deleting the object should uninhibit again
|
|
|
|
inhibitor.reset();
|
|
|
|
QVERIFY(inhibitedSpy.wait());
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
|
|
|
|
// inhibit again and destroy window
|
|
|
|
Test::waylandIdleInhibitManager()->createInhibitor(surface.data(), surface.data());
|
|
|
|
QVERIFY(inhibitedSpy.wait());
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
|
|
|
|
shellSurface.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(c));
|
|
|
|
QTRY_VERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 4);
|
|
|
|
}
|
|
|
|
|
2018-12-04 09:32:37 +00:00
|
|
|
void TestIdleInhibition::testDontInhibitWhenNotOnCurrentDesktop()
|
|
|
|
{
|
|
|
|
// This test verifies that the idle inhibitor object is not honored when
|
|
|
|
// the associated surface is not on the current virtual desktop.
|
|
|
|
|
|
|
|
VirtualDesktopManager::self()->setCount(2);
|
|
|
|
QCOMPARE(VirtualDesktopManager::self()->count(), 2u);
|
|
|
|
|
|
|
|
// Get reference to the idle interface.
|
|
|
|
auto idle = waylandServer()->display()->findChild<IdleInterface *>();
|
|
|
|
QVERIFY(idle);
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged);
|
|
|
|
QVERIFY(inhibitedSpy.isValid());
|
|
|
|
|
|
|
|
// Create the test client.
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QVERIFY(!surface.isNull());
|
|
|
|
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data()));
|
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
|
|
|
|
// Create the inhibitor object.
|
|
|
|
QScopedPointer<IdleInhibitor> inhibitor(Test::waylandIdleInhibitManager()->createInhibitor(surface.data()));
|
|
|
|
QVERIFY(inhibitor->isValid());
|
|
|
|
|
|
|
|
// Render the client.
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
|
|
|
|
// The test client should be only on the first virtual desktop.
|
|
|
|
QCOMPARE(c->desktops().count(), 1);
|
|
|
|
QCOMPARE(c->desktops().first(), VirtualDesktopManager::self()->desktops().first());
|
|
|
|
|
|
|
|
// This should inhibit our server object.
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 1);
|
|
|
|
|
|
|
|
// Switch to the second virtual desktop.
|
|
|
|
VirtualDesktopManager::self()->setCurrent(2);
|
|
|
|
|
|
|
|
// The surface is no longer visible, so the compositor don't have to honor the
|
|
|
|
// idle inhibitor object.
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 2);
|
|
|
|
|
|
|
|
// Switch back to the first virtual desktop.
|
|
|
|
VirtualDesktopManager::self()->setCurrent(1);
|
|
|
|
|
|
|
|
// The test client became visible again, so the compositor has to honor the idle
|
|
|
|
// inhibitor object back again.
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 3);
|
|
|
|
|
|
|
|
// Destroy the test client.
|
|
|
|
shellSurface.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(c));
|
|
|
|
QTRY_VERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestIdleInhibition::testDontInhibitWhenMinimized()
|
|
|
|
{
|
|
|
|
// This test verifies that the idle inhibitor object is not honored when the
|
|
|
|
// associated surface is minimized.
|
|
|
|
|
|
|
|
// Get reference to the idle interface.
|
|
|
|
auto idle = waylandServer()->display()->findChild<IdleInterface *>();
|
|
|
|
QVERIFY(idle);
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged);
|
|
|
|
QVERIFY(inhibitedSpy.isValid());
|
|
|
|
|
|
|
|
// Create the test client.
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QVERIFY(!surface.isNull());
|
|
|
|
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data()));
|
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
|
|
|
|
// Create the inhibitor object.
|
|
|
|
QScopedPointer<IdleInhibitor> inhibitor(Test::waylandIdleInhibitManager()->createInhibitor(surface.data()));
|
|
|
|
QVERIFY(inhibitor->isValid());
|
|
|
|
|
|
|
|
// Render the client.
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
|
|
|
|
// This should inhibit our server object.
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 1);
|
|
|
|
|
|
|
|
// Minimize the client, the idle inhibitor object should not be honored.
|
|
|
|
c->minimize();
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 2);
|
|
|
|
|
|
|
|
// Unminimize the client, the idle inhibitor object should be honored back again.
|
|
|
|
c->unminimize();
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 3);
|
|
|
|
|
|
|
|
// Destroy the test client.
|
|
|
|
shellSurface.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(c));
|
|
|
|
QTRY_VERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestIdleInhibition::testDontInhibitWhenUnmapped()
|
|
|
|
{
|
|
|
|
// This test verifies that the idle inhibitor object is not honored by KWin
|
|
|
|
// when the associated client is unmapped.
|
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
// Get reference to the idle interface.
|
2018-12-04 09:32:37 +00:00
|
|
|
auto idle = waylandServer()->display()->findChild<IdleInterface *>();
|
|
|
|
QVERIFY(idle);
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged);
|
|
|
|
QVERIFY(inhibitedSpy.isValid());
|
|
|
|
|
|
|
|
// Create the test client.
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QVERIFY(!surface.isNull());
|
|
|
|
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data()));
|
|
|
|
QVERIFY(!shellSurface.isNull());
|
2020-05-07 14:29:41 +00:00
|
|
|
QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested);
|
|
|
|
QVERIFY(configureRequestedSpy.isValid());
|
2018-12-04 09:32:37 +00:00
|
|
|
|
|
|
|
// Create the inhibitor object.
|
|
|
|
QScopedPointer<IdleInhibitor> inhibitor(Test::waylandIdleInhibitManager()->createInhibitor(surface.data()));
|
|
|
|
QVERIFY(inhibitor->isValid());
|
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
// Map the client.
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(clientAddedSpy.isEmpty());
|
|
|
|
QVERIFY(clientAddedSpy.wait());
|
|
|
|
QCOMPARE(clientAddedSpy.count(), 1);
|
|
|
|
AbstractClient *client = clientAddedSpy.last().first().value<AbstractClient *>();
|
|
|
|
QVERIFY(client);
|
|
|
|
QCOMPARE(client->readyForPainting(), true);
|
|
|
|
|
|
|
|
// The compositor will respond with a configure event when the surface becomes active.
|
|
|
|
QVERIFY(configureRequestedSpy.wait());
|
|
|
|
QCOMPARE(configureRequestedSpy.count(), 1);
|
2018-12-04 09:32:37 +00:00
|
|
|
|
|
|
|
// This should inhibit our server object.
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 1);
|
|
|
|
|
|
|
|
// Unmap the client.
|
|
|
|
surface->attachBuffer(Buffer::Ptr());
|
|
|
|
surface->commit(Surface::CommitFlag::None);
|
2020-05-07 14:29:41 +00:00
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client));
|
2018-12-04 09:32:37 +00:00
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
// The surface is no longer visible, so the compositor doesn't have to honor the
|
2018-12-04 09:32:37 +00:00
|
|
|
// idle inhibitor object.
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 2);
|
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
// Tell the compositor that we want to map the surface.
|
|
|
|
surface->commit(Surface::CommitFlag::None);
|
|
|
|
|
|
|
|
// The compositor will respond with a configure event.
|
|
|
|
QVERIFY(configureRequestedSpy.wait());
|
|
|
|
QCOMPARE(configureRequestedSpy.count(), 2);
|
|
|
|
|
2018-12-04 09:32:37 +00:00
|
|
|
// Map the client.
|
|
|
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
2020-05-07 14:29:41 +00:00
|
|
|
QVERIFY(clientAddedSpy.wait());
|
|
|
|
QCOMPARE(clientAddedSpy.count(), 2);
|
|
|
|
client = clientAddedSpy.last().first().value<AbstractClient *>();
|
|
|
|
QVERIFY(client);
|
|
|
|
QCOMPARE(client->readyForPainting(), true);
|
2018-12-04 09:32:37 +00:00
|
|
|
|
|
|
|
// The test client became visible again, so the compositor has to honor the idle
|
|
|
|
// inhibitor object back again.
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 3);
|
|
|
|
|
|
|
|
// Destroy the test client.
|
|
|
|
shellSurface.reset();
|
2020-05-07 14:29:41 +00:00
|
|
|
QVERIFY(Test::waitForWindowDestroyed(client));
|
2018-12-04 09:32:37 +00:00
|
|
|
QTRY_VERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestIdleInhibition::testDontInhibitWhenLeftCurrentDesktop()
|
|
|
|
{
|
|
|
|
// This test verifies that the idle inhibitor object is not honored by KWin
|
|
|
|
// when the associated surface leaves the current virtual desktop.
|
|
|
|
|
|
|
|
VirtualDesktopManager::self()->setCount(2);
|
|
|
|
QCOMPARE(VirtualDesktopManager::self()->count(), 2u);
|
|
|
|
|
|
|
|
// Get reference to the idle interface.
|
|
|
|
auto idle = waylandServer()->display()->findChild<IdleInterface *>();
|
|
|
|
QVERIFY(idle);
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged);
|
|
|
|
QVERIFY(inhibitedSpy.isValid());
|
|
|
|
|
|
|
|
// Create the test client.
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QVERIFY(!surface.isNull());
|
|
|
|
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data()));
|
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
|
|
|
|
// Create the inhibitor object.
|
|
|
|
QScopedPointer<IdleInhibitor> inhibitor(Test::waylandIdleInhibitManager()->createInhibitor(surface.data()));
|
|
|
|
QVERIFY(inhibitor->isValid());
|
|
|
|
|
|
|
|
// Render the client.
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
|
|
|
|
// The test client should be only on the first virtual desktop.
|
|
|
|
QCOMPARE(c->desktops().count(), 1);
|
|
|
|
QCOMPARE(c->desktops().first(), VirtualDesktopManager::self()->desktops().first());
|
|
|
|
|
|
|
|
// This should inhibit our server object.
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 1);
|
|
|
|
|
|
|
|
// Let the client enter the second virtual desktop.
|
|
|
|
c->enterDesktop(VirtualDesktopManager::self()->desktops().at(1));
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 1);
|
|
|
|
|
|
|
|
// If the client leaves the first virtual desktop, then the associated idle
|
|
|
|
// inhibitor object should not be honored.
|
|
|
|
c->leaveDesktop(VirtualDesktopManager::self()->desktops().at(0));
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 2);
|
|
|
|
|
|
|
|
// If the client enters the first desktop, then the associated idle inhibitor
|
|
|
|
// object should be honored back again.
|
|
|
|
c->enterDesktop(VirtualDesktopManager::self()->desktops().at(0));
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 3);
|
|
|
|
|
|
|
|
// Destroy the test client.
|
|
|
|
shellSurface.reset();
|
|
|
|
QVERIFY(Test::waitForWindowDestroyed(c));
|
|
|
|
QTRY_VERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 4);
|
|
|
|
}
|
|
|
|
|
2017-11-16 20:48:19 +00:00
|
|
|
WAYLANDTEST_MAIN(TestIdleInhibition)
|
|
|
|
#include "idle_inhibition_test.moc"
|