Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/idle_inhibition_test.cpp
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 78 | { | |||
---|---|---|---|---|---|
79 | Test::destroyWaylandConnection(); | 79 | Test::destroyWaylandConnection(); | ||
80 | 80 | | |||
81 | VirtualDesktopManager::self()->setCount(1); | 81 | VirtualDesktopManager::self()->setCount(1); | ||
82 | QCOMPARE(VirtualDesktopManager::self()->count(), 1u); | 82 | QCOMPARE(VirtualDesktopManager::self()->count(), 1u); | ||
83 | } | 83 | } | ||
84 | 84 | | |||
85 | void TestIdleInhibition::testInhibit_data() | 85 | void TestIdleInhibition::testInhibit_data() | ||
86 | { | 86 | { | ||
87 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 87 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
88 | 88 | | |||
89 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 89 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
90 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 90 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
91 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 91 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
92 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | | |||
93 | } | 92 | } | ||
94 | 93 | | |||
95 | void TestIdleInhibition::testInhibit() | 94 | void TestIdleInhibition::testInhibit() | ||
96 | { | 95 | { | ||
97 | auto idle = waylandServer()->display()->findChild<IdleInterface*>(); | 96 | auto idle = waylandServer()->display()->findChild<IdleInterface*>(); | ||
98 | QVERIFY(idle); | 97 | QVERIFY(idle); | ||
99 | QVERIFY(!idle->isInhibited()); | 98 | QVERIFY(!idle->isInhibited()); | ||
100 | QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged); | 99 | QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged); | ||
101 | QVERIFY(inhibitedSpy.isValid()); | 100 | QVERIFY(inhibitedSpy.isValid()); | ||
102 | 101 | | |||
103 | // now create window | 102 | // now create window | ||
104 | QScopedPointer<Surface> surface(Test::createSurface()); | 103 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
105 | QFETCH(Test::ShellSurfaceType, type); | 104 | QFETCH(Test::XdgShellSurfaceType, type); | ||
106 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 105 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
107 | 106 | | |||
108 | // now create inhibition on window | 107 | // now create inhibition on window | ||
109 | QScopedPointer<IdleInhibitor> inhibitor(Test::waylandIdleInhibitManager()->createInhibitor(surface.data())); | 108 | QScopedPointer<IdleInhibitor> inhibitor(Test::waylandIdleInhibitManager()->createInhibitor(surface.data())); | ||
110 | QVERIFY(inhibitor->isValid()); | 109 | QVERIFY(inhibitor->isValid()); | ||
111 | 110 | | |||
112 | // render the client | 111 | // render the client | ||
113 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 112 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
114 | QVERIFY(c); | 113 | QVERIFY(c); | ||
115 | 114 | | |||
116 | // this should inhibit our server object | 115 | // this should inhibit our server object | ||
117 | QVERIFY(idle->isInhibited()); | 116 | QVERIFY(idle->isInhibited()); | ||
118 | 117 | | |||
119 | // deleting the object should uninhibit again | 118 | // deleting the object should uninhibit again | ||
120 | inhibitor.reset(); | 119 | inhibitor.reset(); | ||
121 | QVERIFY(inhibitedSpy.wait()); | 120 | QVERIFY(inhibitedSpy.wait()); | ||
122 | QVERIFY(!idle->isInhibited()); | 121 | QVERIFY(!idle->isInhibited()); | ||
123 | 122 | | |||
124 | // inhibit again and destroy window | 123 | // inhibit again and destroy window | ||
125 | Test::waylandIdleInhibitManager()->createInhibitor(surface.data(), surface.data()); | 124 | Test::waylandIdleInhibitManager()->createInhibitor(surface.data(), surface.data()); | ||
126 | QVERIFY(inhibitedSpy.wait()); | 125 | QVERIFY(inhibitedSpy.wait()); | ||
127 | QVERIFY(idle->isInhibited()); | 126 | QVERIFY(idle->isInhibited()); | ||
128 | 127 | | |||
129 | shellSurface.reset(); | 128 | shellSurface.reset(); | ||
130 | if (type == Test::ShellSurfaceType::WlShell) { | | |||
131 | surface.reset(); | | |||
132 | } | | |||
133 | QVERIFY(Test::waitForWindowDestroyed(c)); | 129 | QVERIFY(Test::waitForWindowDestroyed(c)); | ||
134 | QTRY_VERIFY(!idle->isInhibited()); | 130 | QTRY_VERIFY(!idle->isInhibited()); | ||
135 | QCOMPARE(inhibitedSpy.count(), 4); | 131 | QCOMPARE(inhibitedSpy.count(), 4); | ||
136 | } | 132 | } | ||
137 | 133 | | |||
138 | void TestIdleInhibition::testDontInhibitWhenNotOnCurrentDesktop() | 134 | void TestIdleInhibition::testDontInhibitWhenNotOnCurrentDesktop() | ||
139 | { | 135 | { | ||
140 | // This test verifies that the idle inhibitor object is not honored when | 136 | // This test verifies that the idle inhibitor object is not honored when | ||
▲ Show 20 Lines • Show All 226 Lines • Show Last 20 Lines |