Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/window_rules_test.cpp
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
42 | { | 42 | { | ||
43 | Q_OBJECT | 43 | Q_OBJECT | ||
44 | private Q_SLOTS: | 44 | private Q_SLOTS: | ||
45 | void initTestCase(); | 45 | void initTestCase(); | ||
46 | void init(); | 46 | void init(); | ||
47 | void cleanup(); | 47 | void cleanup(); | ||
48 | void testApplyInitialMaximizeVert_data(); | 48 | void testApplyInitialMaximizeVert_data(); | ||
49 | void testApplyInitialMaximizeVert(); | 49 | void testApplyInitialMaximizeVert(); | ||
50 | void testWindowClassChange(); | ||||
50 | }; | 51 | }; | ||
51 | 52 | | |||
52 | void WindowRuleTest::initTestCase() | 53 | void WindowRuleTest::initTestCase() | ||
53 | { | 54 | { | ||
54 | qRegisterMetaType<KWin::ShellClient*>(); | 55 | qRegisterMetaType<KWin::ShellClient*>(); | ||
55 | qRegisterMetaType<KWin::AbstractClient*>(); | 56 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
56 | qRegisterMetaType<KWin::Deleted*>(); | 57 | qRegisterMetaType<KWin::Deleted*>(); | ||
57 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 58 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | 103 | { | |||
160 | QSignalSpy windowClosedSpy(client, &Client::windowClosed); | 161 | QSignalSpy windowClosedSpy(client, &Client::windowClosed); | ||
161 | QVERIFY(windowClosedSpy.isValid()); | 162 | QVERIFY(windowClosedSpy.isValid()); | ||
162 | xcb_unmap_window(c.data(), w); | 163 | xcb_unmap_window(c.data(), w); | ||
163 | xcb_destroy_window(c.data(), w); | 164 | xcb_destroy_window(c.data(), w); | ||
164 | xcb_flush(c.data()); | 165 | xcb_flush(c.data()); | ||
165 | QVERIFY(windowClosedSpy.wait()); | 166 | QVERIFY(windowClosedSpy.wait()); | ||
166 | } | 167 | } | ||
167 | 168 | | |||
169 | void WindowRuleTest::testWindowClassChange() | ||||
170 | { | ||||
171 | KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); | ||||
172 | config->group("General").writeEntry("count", 1); | ||||
173 | | ||||
174 | auto group = config->group("1"); | ||||
175 | group.writeEntry("above", true); | ||||
176 | group.writeEntry("aboverule", 2); | ||||
177 | group.writeEntry("wmclass", "org.kde.foo"); | ||||
178 | group.writeEntry("wmclasscomplete", false); | ||||
179 | group.writeEntry("wmclassmatch", 1); | ||||
180 | group.sync(); | ||||
181 | | ||||
182 | RuleBook::self()->setConfig(config); | ||||
183 | workspace()->slotReconfigure(); | ||||
184 | | ||||
185 | // create the test window | ||||
186 | QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr)); | ||||
187 | QVERIFY(!xcb_connection_has_error(c.data())); | ||||
188 | | ||||
189 | xcb_window_t w = xcb_generate_id(c.data()); | ||||
190 | const QRect windowGeometry = QRect(0, 0, 10, 20); | ||||
191 | const uint32_t values[] = { | ||||
192 | XCB_EVENT_MASK_ENTER_WINDOW | | ||||
193 | XCB_EVENT_MASK_LEAVE_WINDOW | ||||
zzag: Do we need these events? | |||||
Not sure. Copied from other effect which also seems to not need them. So I assumed we need them. graesslin: Not sure. Copied from other effect which also seems to not need them. So I assumed we need them. | |||||
194 | }; | ||||
195 | xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(), | ||||
196 | windowGeometry.x(), | ||||
197 | windowGeometry.y(), | ||||
198 | windowGeometry.width(), | ||||
199 | windowGeometry.height(), | ||||
200 | 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, XCB_CW_EVENT_MASK, values); | ||||
201 | xcb_size_hints_t hints; | ||||
202 | memset(&hints, 0, sizeof(hints)); | ||||
203 | xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y()); | ||||
204 | xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height()); | ||||
205 | xcb_icccm_set_wm_normal_hints(c.data(), w, &hints); | ||||
206 | xcb_icccm_set_wm_class(c.data(), w, 23, "org.kde.bar\0org.kde.bar"); | ||||
207 | | ||||
208 | NETWinInfo info(c.data(), w, rootWindow(), NET::WMAllProperties, NET::WM2AllProperties); | ||||
209 | info.setWindowType(NET::Normal); | ||||
210 | xcb_map_window(c.data(), w); | ||||
211 | xcb_flush(c.data()); | ||||
212 | | ||||
213 | QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded); | ||||
214 | QVERIFY(windowCreatedSpy.isValid()); | ||||
215 | QVERIFY(windowCreatedSpy.wait()); | ||||
216 | Client *client = windowCreatedSpy.last().first().value<Client*>(); | ||||
217 | QVERIFY(client); | ||||
218 | QVERIFY(client->isDecorated()); | ||||
219 | QVERIFY(!client->hasStrut()); | ||||
220 | QVERIFY(!client->isHiddenInternal()); | ||||
221 | QVERIFY(!client->readyForPainting()); | ||||
222 | QMetaObject::invokeMethod(client, "setReadyForPainting"); | ||||
223 | QVERIFY(client->readyForPainting()); | ||||
224 | QVERIFY(!client->surface()); | ||||
225 | QSignalSpy surfaceChangedSpy(client, &Toplevel::surfaceChanged); | ||||
226 | QVERIFY(surfaceChangedSpy.isValid()); | ||||
227 | QVERIFY(surfaceChangedSpy.wait()); | ||||
228 | QVERIFY(client->surface()); | ||||
229 | QCOMPARE(client->keepAbove(), false); | ||||
230 | | ||||
231 | // now change class | ||||
232 | QSignalSpy windowClassChangedSpy{client, &Client::windowClassChanged}; | ||||
233 | QVERIFY(windowClassChangedSpy.isValid()); | ||||
234 | xcb_icccm_set_wm_class(c.data(), w, 23, "org.kde.foo\0org.kde.foo"); | ||||
235 | xcb_flush(c.data()); | ||||
236 | QVERIFY(windowClassChangedSpy.wait()); | ||||
237 | QCOMPARE(client->keepAbove(), true); | ||||
238 | | ||||
239 | // destroy window | ||||
zzag: > again
Is it a typo? | |||||
No, copy and paste from other test. And probably a Germanism. It's how you would write it in German and just translated. graesslin: No, copy and paste from other test. And probably a Germanism. It's how you would write it in… | |||||
240 | QSignalSpy windowClosedSpy(client, &Client::windowClosed); | ||||
241 | QVERIFY(windowClosedSpy.isValid()); | ||||
242 | xcb_unmap_window(c.data(), w); | ||||
243 | xcb_destroy_window(c.data(), w); | ||||
244 | xcb_flush(c.data()); | ||||
245 | QVERIFY(windowClosedSpy.wait()); | ||||
246 | } | ||||
247 | | ||||
168 | } | 248 | } | ||
169 | 249 | | |||
170 | WAYLANDTEST_MAIN(KWin::WindowRuleTest) | 250 | WAYLANDTEST_MAIN(KWin::WindowRuleTest) | ||
171 | #include "window_rules_test.moc" | 251 | #include "window_rules_test.moc" |
Do we need these events?