InputMethodTest: Only create the windowAddedSpy when actually needed

We don't really care about the window showing up until we're calling
showInputPanel, but since Workspace::windowAdded is triggered for any
window that gets added, the test sometimes fails because count() is 2
instead of 1. To avoid that, only create the spy when it's actually
relevant instead of all the way at the start before any other setup is
done.
This commit is contained in:
Arjen Hiemstra 2022-07-13 15:24:19 +00:00
parent c050716a3b
commit 8284740cdf

View file

@ -201,7 +201,6 @@ void InputMethodTest::testEnableActive()
{
QVERIFY(!InputMethod::self()->isActive());
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
QSignalSpy windowRemovedSpy(workspace(), &Workspace::windowRemoved);
QSignalSpy activateSpy(InputMethod::self(), &InputMethod::activeChanged);
@ -223,9 +222,9 @@ void InputMethodTest::testEnableActive()
QVERIFY(!textInput.isNull());
textInput->enable(surface.data());
QVERIFY(surfaceConfigureRequestedSpy.wait());
QCOMPARE(windowAddedSpy.count(), 1);
// Show the keyboard
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
textInput->showInputPanel();
QVERIFY(windowAddedSpy.wait());