MCPcopy Create free account
hub / github.com/KDE/kwin / testOpenClose

Method testOpenClose

autotests/integration/inputmethod_test.cpp:128–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128void 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.

Callers

nothing calls this directly

Calls 15

workspaceFunction · 0.85
createSurfaceFunction · 0.85
createXdgToplevelSurfaceFunction · 0.85
waylandTextInputManagerFunction · 0.85
waylandSeatFunction · 0.85
kwinAppFunction · 0.85
renderFunction · 0.85
waitForWindowClosedFunction · 0.85
frameGeometryMethod · 0.80
createTextInputMethod · 0.80
showInputPanelMethod · 0.80
inputMethodMethod · 0.80

Tested by

no test coverage detected