| 275 | } |
| 276 | |
| 277 | void InputMethodTest::testHidePanel() |
| 278 | { |
| 279 | QVERIFY(!kwinApp()->inputMethod()->isActive()); |
| 280 | |
| 281 | touchNow(); |
| 282 | QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded); |
| 283 | QSignalSpy windowRemovedSpy(workspace(), &Workspace::windowRemoved); |
| 284 | |
| 285 | QSignalSpy activateSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged); |
| 286 | std::unique_ptr<KWayland::Client::TextInput> textInput(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat())); |
| 287 | |
| 288 | // Create an xdg_toplevel surface and wait for the compositor to catch up. |
| 289 | std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface()); |
| 290 | std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get())); |
| 291 | Window *window = Test::renderAndWaitForShown(surface.get(), QSize(1280, 1024), Qt::red); |
| 292 | waylandServer()->seat()->setFocusedTextInputSurface(window->surface()); |
| 293 | |
| 294 | textInput->enable(surface.get()); |
| 295 | QSignalSpy paneladded(kwinApp()->inputMethod(), &KWin::InputMethod::panelChanged); |
| 296 | QVERIFY(paneladded.wait()); |
| 297 | textInput->showInputPanel(); |
| 298 | QVERIFY(windowAddedSpy.wait()); |
| 299 | |
| 300 | QCOMPARE(workspace()->activeWindow(), window); |
| 301 | |
| 302 | QCOMPARE(windowAddedSpy.count(), 2); |
| 303 | QVERIFY(activateSpy.count() || activateSpy.wait()); |
| 304 | QVERIFY(kwinApp()->inputMethod()->isActive()); |
| 305 | |
| 306 | auto keyboardWindow = kwinApp()->inputMethod()->panel(); |
| 307 | auto ipsurface = Test::inputPanelSurface(); |
| 308 | QVERIFY(keyboardWindow); |
| 309 | windowRemovedSpy.clear(); |
| 310 | delete ipsurface; |
| 311 | QVERIFY(kwinApp()->inputMethod()->isVisible()); |
| 312 | QVERIFY(windowRemovedSpy.count() || windowRemovedSpy.wait()); |
| 313 | QVERIFY(!kwinApp()->inputMethod()->isVisible()); |
| 314 | |
| 315 | // Destroy the test window. |
| 316 | shellSurface.reset(); |
| 317 | QVERIFY(Test::waitForWindowClosed(window)); |
| 318 | } |
| 319 | |
| 320 | void InputMethodTest::testUnmapPanel() |
| 321 | { |
nothing calls this directly
no test coverage detected