| 126 | } |
| 127 | |
| 128 | void InputMethodTest::testOpenClose() |
| 129 | { |
| 130 | QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded); |
| 131 | QSignalSpy windowRemovedSpy(workspace(), &Workspace::windowRemoved); |
| 132 | |
| 133 | // Create an xdg_toplevel surface and wait for the compositor to catch up. |
| 134 | std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface()); |
| 135 | std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get())); |
| 136 | Window *window = Test::renderAndWaitForShown(surface.get(), QSize(1280, 1024), Qt::red); |
| 137 | QVERIFY(window); |
| 138 | QVERIFY(window->isActive()); |
| 139 | QCOMPARE(window->frameGeometry().size(), QSize(1280, 1024)); |
| 140 | QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged); |
| 141 | QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested); |
| 142 | QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested); |
| 143 | QVERIFY(surfaceConfigureRequestedSpy.wait()); |
| 144 | |
| 145 | std::unique_ptr<KWayland::Client::TextInput> textInput(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat())); |
| 146 | QVERIFY(textInput != nullptr); |
| 147 | |
| 148 | // Show the keyboard |
| 149 | touchNow(); |
| 150 | textInput->enable(surface.get()); |
| 151 | textInput->showInputPanel(); |
| 152 | QSignalSpy paneladded(kwinApp()->inputMethod(), &KWin::InputMethod::panelChanged); |
| 153 | QVERIFY(windowAddedSpy.wait()); |
| 154 | QCOMPARE(paneladded.count(), 1); |
| 155 | |
| 156 | Window *keyboardClient = windowAddedSpy.last().first().value<Window *>(); |
| 157 | QVERIFY(keyboardClient); |
| 158 | QVERIFY(keyboardClient->isInputMethod()); |
| 159 | |
| 160 | // Do the actual resize |
| 161 | QVERIFY(surfaceConfigureRequestedSpy.wait()); |
| 162 | |
| 163 | Test::render(surface.get(), toplevelConfigureRequestedSpy.last().first().value<QSize>(), Qt::red); |
| 164 | QVERIFY(frameGeometryChangedSpy.wait()); |
| 165 | |
| 166 | QCOMPARE(window->frameGeometry().height(), 1024 - keyboardClient->frameGeometry().height()); |
| 167 | |
| 168 | // Hide the keyboard |
| 169 | textInput->hideInputPanel(); |
| 170 | |
| 171 | QVERIFY(surfaceConfigureRequestedSpy.wait()); |
| 172 | Test::render(surface.get(), toplevelConfigureRequestedSpy.last().first().value<QSize>(), Qt::red); |
| 173 | QVERIFY(frameGeometryChangedSpy.wait()); |
| 174 | |
| 175 | QCOMPARE(window->frameGeometry().height(), 1024); |
| 176 | |
| 177 | // show the keyboard again |
| 178 | touchNow(); |
| 179 | textInput->enable(surface.get()); |
| 180 | textInput->showInputPanel(); |
| 181 | |
| 182 | QVERIFY(surfaceConfigureRequestedSpy.wait()); |
| 183 | QVERIFY(keyboardClient->isShown()); |
| 184 | |
| 185 | // Destroy the test window. |
nothing calls this directly
no test coverage detected