10#include "KWayland/Client/compositor.h"
11#include "KWayland/Client/connection_thread.h"
12#include "KWayland/Client/event_queue.h"
13#include "KWayland/Client/keyboard.h"
14#include "KWayland/Client/registry.h"
15#include "KWayland/Client/seat.h"
16#include "KWayland/Client/surface.h"
17#include "KWayland/Client/textinput.h"
26using namespace std::literals;
35 void testEnterLeave_data();
36 void testEnterLeave();
37 void testFocusedBeforeCreateTextInput();
38 void testShowHidePanel();
39 void testCursorRectangle();
40 void testPreferredLanguage();
42 void testSurroundingText();
43 void testContentHints_data();
44 void testContentHints();
45 void testContentPurpose_data();
46 void testContentPurpose();
47 void testTextDirection_data();
48 void testTextDirection();
56 KWayland::Client::TextInput *createTextInput();
61 KWayland::Client::ConnectionThread *m_connection =
nullptr;
62 QThread *m_thread =
nullptr;
63 KWayland::Client::EventQueue *m_queue =
nullptr;
64 KWayland::Client::Seat *m_seat =
nullptr;
65 KWayland::Client::Keyboard *m_keyboard =
nullptr;
66 KWayland::Client::Compositor *m_compositor =
nullptr;
67 KWayland::Client::TextInputManager *m_textInputManagerV2 =
nullptr;
70static const QString s_socketName = QStringLiteral(
"kwayland-test-text-input-0");
72void TextInputTest::init()
87 m_connection =
new KWayland::Client::ConnectionThread;
88 QSignalSpy connectedSpy(m_connection, &KWayland::Client::ConnectionThread::connected);
89 m_connection->setSocketName(s_socketName);
91 m_thread =
new QThread(
this);
92 m_connection->moveToThread(m_thread);
95 m_connection->initConnection();
96 QVERIFY(connectedSpy.wait());
98 m_queue =
new KWayland::Client::EventQueue(
this);
99 m_queue->setup(m_connection);
101 KWayland::Client::Registry registry;
102 QSignalSpy interfacesAnnouncedSpy(®istry, &KWayland::Client::Registry::interfacesAnnounced);
103 registry.setEventQueue(m_queue);
104 registry.create(m_connection);
105 QVERIFY(registry.isValid());
107 QVERIFY(interfacesAnnouncedSpy.wait());
109 m_seat = registry.createSeat(registry.interface(KWayland::Client::Registry::Interface::Seat).name, registry.interface(KWayland::Client::Registry::Interface::Seat).version,
this);
110 QVERIFY(m_seat->isValid());
111 QSignalSpy hasKeyboardSpy(m_seat, &KWayland::Client::Seat::hasKeyboardChanged);
112 QVERIFY(hasKeyboardSpy.wait());
113 m_keyboard = m_seat->createKeyboard(
this);
114 QVERIFY(m_keyboard->isValid());
117 registry.createCompositor(registry.interface(KWayland::Client::Registry::Interface::Compositor).name, registry.interface(KWayland::Client::Registry::Interface::Compositor).version,
this);
118 QVERIFY(m_compositor->isValid());
120 m_textInputManagerV2 = registry.createTextInputManager(registry.interface(KWayland::Client::Registry::Interface::TextInputManagerUnstableV2).name,
121 registry.interface(KWayland::Client::Registry::Interface::TextInputManagerUnstableV2).version,
123 QVERIFY(m_textInputManagerV2->isValid());
126void TextInputTest::cleanup()
128#define CLEANUP(variable) \
131 variable = nullptr; \
139 m_connection->deleteLater();
140 m_connection =
nullptr;
153 m_textInputManagerV2Interface =
nullptr;
154 m_compositorInterface =
nullptr;
155 m_seatInterface =
nullptr;
161 if (!surfaceCreatedSpy.isValid()) {
164 if (!surfaceCreatedSpy.wait(500)) {
167 if (surfaceCreatedSpy.count() != 1) {
173KWayland::Client::TextInput *TextInputTest::createTextInput()
175 return m_textInputManagerV2->createTextInput(m_seat);
178void TextInputTest::testEnterLeave_data()
180 QTest::addColumn<bool>(
"updatesDirectly");
181 QTest::newRow(
"UnstableV2") <<
true;
184void TextInputTest::testEnterLeave()
187 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
189 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
190 auto serverSurface = waitForSurface();
191 QVERIFY(serverSurface);
192 QVERIFY(textInput !=
nullptr);
193 QSignalSpy enteredSpy(textInput.get(), &KWayland::Client::TextInput::entered);
194 QSignalSpy leftSpy(textInput.get(), &KWayland::Client::TextInput::left);
202 QFETCH(
bool, updatesDirectly);
203 QCOMPARE(
bool(m_seatInterface->
textInputV2()), updatesDirectly);
204 QCOMPARE(textInputChangedSpy.isEmpty(), !updatesDirectly);
205 textInput->enable(surface.get());
207 if (!updatesDirectly) {
208 QVERIFY(textInputChangedSpy.wait());
210 QCOMPARE(textInputChangedSpy.count(), 1);
211 auto serverTextInput = m_seatInterface->
textInputV2();
212 QVERIFY(serverTextInput);
214 if (updatesDirectly) {
215 QVERIFY(enabledChangedSpy.wait());
216 enabledChangedSpy.clear();
218 QCOMPARE(serverTextInput->surface().data(), serverSurface);
219 QVERIFY(serverTextInput->isEnabled());
222 if (enteredSpy.isEmpty()) {
223 QVERIFY(enteredSpy.wait());
225 QCOMPARE(enteredSpy.count(), 1);
226 QCOMPARE(textInput->enteredSurface(), surface.get());
230 QCOMPARE(textInputChangedSpy.count(), 2);
231 QVERIFY(leftSpy.wait());
232 QVERIFY(!textInput->enteredSurface());
233 QVERIFY(!serverTextInput->isEnabled());
237 QCOMPARE(textInputChangedSpy.count(), 3);
239 QVERIFY(enteredSpy.wait());
240 QCOMPARE(enteredSpy.count(), 2);
241 QCOMPARE(textInput->enteredSurface(), surface.get());
242 QVERIFY(serverTextInput->isEnabled());
245 textInput->disable(surface.get());
246 QVERIFY(enabledChangedSpy.wait());
247 QCOMPARE(enabledChangedSpy.count(), 3);
248 QVERIFY(!serverTextInput->isEnabled());
250 QCOMPARE(textInputChangedSpy.count(), 3);
252 QCOMPARE(m_seatInterface->
textInputV2(), serverTextInput);
254 textInput->enable(surface.get());
255 QVERIFY(enabledChangedSpy.wait());
258 QSignalSpy unboundSpy(serverSurface, &QObject::destroyed);
260 QVERIFY(unboundSpy.wait());
261 QVERIFY(leftSpy.wait());
262 QVERIFY(!textInput->enteredSurface());
265void TextInputTest::testFocusedBeforeCreateTextInput()
268 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
269 auto serverSurface = waitForSurface();
275 QCOMPARE(textInputChangedSpy.count(), 1);
280 QVERIFY(serverSurface);
281 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
282 QVERIFY(textInput !=
nullptr);
283 QSignalSpy enteredSpy(textInput.get(), &KWayland::Client::TextInput::entered);
284 QSignalSpy leftSpy(textInput.get(), &KWayland::Client::TextInput::left);
287 if (enteredSpy.isEmpty()) {
288 QVERIFY(enteredSpy.wait());
290 QCOMPARE(enteredSpy.count(), 1);
291 QCOMPARE(textInput->enteredSurface(), surface.get());
298 QCOMPARE(textInputChangedSpy.count(), 2);
299 QVERIFY(leftSpy.wait());
300 QVERIFY(!textInput->enteredSurface());
306void TextInputTest::testShowHidePanel()
310 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
311 auto serverSurface = waitForSurface();
312 QVERIFY(serverSurface);
314 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
315 QVERIFY(textInput !=
nullptr);
316 textInput->enable(surface.get());
317 m_connection->flush();
326 QSignalSpy inputPanelStateChangedSpy(textInput.get(), &KWayland::Client::TextInput::inputPanelStateChanged);
328 QCOMPARE(textInput->isInputPanelVisible(),
false);
329 textInput->showInputPanel();
330 QVERIFY(showPanelRequestedSpy.wait());
331 ti->setInputPanelState(
true, QRect(0, 0, 0, 0));
332 QVERIFY(inputPanelStateChangedSpy.wait());
333 QCOMPARE(textInput->isInputPanelVisible(),
true);
335 textInput->hideInputPanel();
336 QVERIFY(hidePanelRequestedSpy.wait());
337 ti->setInputPanelState(
false, QRect(0, 0, 0, 0));
338 QVERIFY(inputPanelStateChangedSpy.wait());
339 QCOMPARE(textInput->isInputPanelVisible(),
false);
342void TextInputTest::testCursorRectangle()
346 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
347 auto serverSurface = waitForSurface();
348 QVERIFY(serverSurface);
350 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
351 QVERIFY(textInput !=
nullptr);
352 textInput->enable(surface.get());
353 m_connection->flush();
359 QCOMPARE(ti->cursorRectangle(), QRect());
362 textInput->setCursorRectangle(QRect(10, 20, 30, 40));
363 QVERIFY(cursorRectangleChangedSpy.wait());
364 QCOMPARE(ti->cursorRectangle(), QRect(10, 20, 30, 40));
367void TextInputTest::testPreferredLanguage()
370 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
371 auto serverSurface = waitForSurface();
372 QVERIFY(serverSurface);
374 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
375 QVERIFY(textInput !=
nullptr);
376 textInput->enable(surface.get());
377 m_connection->flush();
383 QVERIFY(ti->preferredLanguage().isEmpty());
386 textInput->setPreferredLanguage(QStringLiteral(
"foo"));
387 QVERIFY(preferredLanguageChangedSpy.wait());
388 QCOMPARE(ti->preferredLanguage(), QStringLiteral(
"foo").toUtf8());
391void TextInputTest::testReset()
394 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
395 auto serverSurface = waitForSurface();
396 QVERIFY(serverSurface);
398 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
399 QVERIFY(textInput !=
nullptr);
400 textInput->enable(surface.get());
401 m_connection->flush();
411 QVERIFY(stateUpdatedSpy.wait());
414void TextInputTest::testSurroundingText()
417 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
418 auto serverSurface = waitForSurface();
419 QVERIFY(serverSurface);
421 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
422 QVERIFY(textInput !=
nullptr);
423 textInput->enable(surface.get());
424 m_connection->flush();
430 QVERIFY(ti->surroundingText().isEmpty());
431 QCOMPARE(ti->surroundingTextCursorPosition(), 0);
432 QCOMPARE(ti->surroundingTextSelectionAnchor(), 0);
436 textInput->setSurroundingText(QStringLiteral(
"100 €, 100 $"), 5, 6);
437 QVERIFY(surroundingTextChangedSpy.wait());
438 QCOMPARE(ti->surroundingText(), QStringLiteral(
"100 €, 100 $").toUtf8());
439 QCOMPARE(ti->surroundingTextCursorPosition(), QStringLiteral(
"100 €, 100 $").toUtf8().indexOf(
','));
440 QCOMPARE(ti->surroundingTextSelectionAnchor(), QStringLiteral(
"100 €, 100 $").toUtf8().indexOf(
' ', ti->surroundingTextCursorPosition()));
443void TextInputTest::testContentHints_data()
445 QTest::addColumn<KWayland::Client::TextInput::ContentHints>(
"clientHints");
446 QTest::addColumn<KWin::TextInputContentHints>(
"serverHints");
448 QTest::newRow(
"completion/v2") << KWayland::Client::TextInput::ContentHints(KWayland::Client::TextInput::ContentHint::AutoCompletion)
450 QTest::newRow(
"Correction/v2") << KWayland::Client::TextInput::ContentHints(KWayland::Client::TextInput::ContentHint::AutoCorrection)
452 QTest::newRow(
"Capitalization/v2") << KWayland::Client::TextInput::ContentHints(KWayland::Client::TextInput::ContentHint::AutoCapitalization)
454 QTest::newRow(
"Lowercase/v2") << KWayland::Client::TextInput::ContentHints(KWayland::Client::TextInput::ContentHint::LowerCase)
456 QTest::newRow(
"Uppercase/v2") << KWayland::Client::TextInput::ContentHints(KWayland::Client::TextInput::ContentHint::UpperCase)
458 QTest::newRow(
"Titlecase/v2") << KWayland::Client::TextInput::ContentHints(KWayland::Client::TextInput::ContentHint::TitleCase)
460 QTest::newRow(
"HiddenText/v2") << KWayland::Client::TextInput::ContentHints(KWayland::Client::TextInput::ContentHint::HiddenText)
462 QTest::newRow(
"SensitiveData/v2") << KWayland::Client::TextInput::ContentHints(KWayland::Client::TextInput::ContentHint::SensitiveData)
464 QTest::newRow(
"Latin/v2") << KWayland::Client::TextInput::ContentHints(KWayland::Client::TextInput::ContentHint::Latin)
466 QTest::newRow(
"Multiline/v2") << KWayland::Client::TextInput::ContentHints(KWayland::Client::TextInput::ContentHint::MultiLine)
469 QTest::newRow(
"autos/v2") << (KWayland::Client::TextInput::ContentHint::AutoCompletion | KWayland::Client::TextInput::ContentHint::AutoCorrection | KWayland::Client::TextInput::ContentHint::AutoCapitalization)
474 QTest::newRow(
"all/v2") << (KWayland::Client::TextInput::ContentHint::AutoCompletion | KWayland::Client::TextInput::ContentHint::AutoCorrection | KWayland::Client::TextInput::ContentHint::AutoCapitalization
475 | KWayland::Client::TextInput::ContentHint::LowerCase | KWayland::Client::TextInput::ContentHint::UpperCase | KWayland::Client::TextInput::ContentHint::TitleCase
476 | KWayland::Client::TextInput::ContentHint::HiddenText | KWayland::Client::TextInput::ContentHint::SensitiveData | KWayland::Client::TextInput::ContentHint::Latin
477 | KWayland::Client::TextInput::ContentHint::MultiLine)
485void TextInputTest::testContentHints()
488 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
489 auto serverSurface = waitForSurface();
490 QVERIFY(serverSurface);
492 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
493 QVERIFY(textInput !=
nullptr);
494 textInput->enable(surface.get());
495 m_connection->flush();
501 QCOMPARE(ti->contentHints(), KWin::TextInputContentHints());
504 QFETCH(KWayland::Client::TextInput::ContentHints, clientHints);
505 textInput->setContentType(clientHints, KWayland::Client::TextInput::ContentPurpose::Normal);
506 QVERIFY(contentTypeChangedSpy.wait());
507 QTEST(ti->contentHints(),
"serverHints");
510 textInput->setContentType(clientHints, KWayland::Client::TextInput::ContentPurpose::Normal);
511 QVERIFY(!contentTypeChangedSpy.wait(100));
514 textInput->setContentType(KWayland::Client::TextInput::ContentHints(), KWayland::Client::TextInput::ContentPurpose::Normal);
515 QVERIFY(contentTypeChangedSpy.wait());
516 QCOMPARE(ti->contentHints(), KWin::TextInputContentHints());
519void TextInputTest::testContentPurpose_data()
521 QTest::addColumn<KWayland::Client::TextInput::ContentPurpose>(
"clientPurpose");
522 QTest::addColumn<KWin::TextInputContentPurpose>(
"serverPurpose");
538void TextInputTest::testContentPurpose()
541 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
542 auto serverSurface = waitForSurface();
543 QVERIFY(serverSurface);
545 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
546 QVERIFY(textInput !=
nullptr);
547 textInput->enable(surface.get());
548 m_connection->flush();
557 QFETCH(KWayland::Client::TextInput::ContentPurpose, clientPurpose);
558 textInput->setContentType(KWayland::Client::TextInput::ContentHints(), clientPurpose);
559 QVERIFY(contentTypeChangedSpy.wait());
560 QTEST(ti->contentPurpose(),
"serverPurpose");
563 textInput->setContentType(KWayland::Client::TextInput::ContentHints(), clientPurpose);
564 QVERIFY(!contentTypeChangedSpy.wait(100));
567 textInput->setContentType(KWayland::Client::TextInput::ContentHints(), KWayland::Client::TextInput::ContentPurpose::Normal);
568 QVERIFY(contentTypeChangedSpy.wait());
572void TextInputTest::testTextDirection_data()
574 QTest::addColumn<Qt::LayoutDirection>(
"textDirection");
576 QTest::newRow(
"ltr/v0") << Qt::LeftToRight;
577 QTest::newRow(
"rtl/v0") << Qt::RightToLeft;
579 QTest::newRow(
"ltr/v2") << Qt::LeftToRight;
580 QTest::newRow(
"rtl/v2") << Qt::RightToLeft;
583void TextInputTest::testTextDirection()
586 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
587 auto serverSurface = waitForSurface();
588 QVERIFY(serverSurface);
590 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
591 QVERIFY(textInput !=
nullptr);
593 QCOMPARE(textInput->textDirection(), Qt::LayoutDirectionAuto);
594 textInput->enable(surface.get());
595 m_connection->flush();
603 QSignalSpy textDirectionChangedSpy(textInput.get(), &KWayland::Client::TextInput::textDirectionChanged);
604 QFETCH(Qt::LayoutDirection, textDirection);
605 ti->setTextDirection(textDirection);
606 QVERIFY(textDirectionChangedSpy.wait());
607 QCOMPARE(textInput->textDirection(), textDirection);
609 ti->setTextDirection(textDirection);
610 QVERIFY(!textDirectionChangedSpy.wait(100));
613 ti->setTextDirection(Qt::LayoutDirectionAuto);
614 QVERIFY(textDirectionChangedSpy.wait());
615 QCOMPARE(textInput->textDirection(), Qt::LayoutDirectionAuto);
618void TextInputTest::testLanguage()
621 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
622 auto serverSurface = waitForSurface();
623 QVERIFY(serverSurface);
625 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
626 QVERIFY(textInput !=
nullptr);
628 QVERIFY(textInput->language().isEmpty());
629 textInput->enable(surface.get());
630 m_connection->flush();
638 QSignalSpy langugageChangedSpy(textInput.get(), &KWayland::Client::TextInput::languageChanged);
639 ti->setLanguage(QByteArrayLiteral(
"foo"));
640 QVERIFY(langugageChangedSpy.wait());
641 QCOMPARE(textInput->language(), QByteArrayLiteral(
"foo"));
643 ti->setLanguage(QByteArrayLiteral(
"foo"));
644 QVERIFY(!langugageChangedSpy.wait(100));
646 ti->setLanguage(QByteArrayLiteral(
"bar"));
647 QVERIFY(langugageChangedSpy.wait());
648 QCOMPARE(textInput->language(), QByteArrayLiteral(
"bar"));
651void TextInputTest::testKeyEvent()
653 qRegisterMetaType<Qt::KeyboardModifiers>();
654 qRegisterMetaType<KWayland::Client::TextInput::KeyState>();
656 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
657 auto serverSurface = waitForSurface();
658 QVERIFY(serverSurface);
660 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
661 QVERIFY(textInput !=
nullptr);
662 textInput->enable(surface.get());
663 m_connection->flush();
671 QSignalSpy keyEventSpy(textInput.get(), &KWayland::Client::TextInput::keyEvent);
673 ti->keysymPressed(2);
674 QVERIFY(keyEventSpy.wait());
675 QCOMPARE(keyEventSpy.count(), 1);
676 QCOMPARE(keyEventSpy.last().at(0).value<quint32>(), 2u);
677 QCOMPARE(keyEventSpy.last().at(1).value<KWayland::Client::TextInput::KeyState>(), KWayland::Client::TextInput::KeyState::Pressed);
678 QCOMPARE(keyEventSpy.last().at(2).value<Qt::KeyboardModifiers>(), Qt::KeyboardModifiers());
679 QCOMPARE(keyEventSpy.last().at(3).value<quint32>(), 100u);
681 ti->keysymReleased(2);
682 QVERIFY(keyEventSpy.wait());
683 QCOMPARE(keyEventSpy.count(), 2);
684 QCOMPARE(keyEventSpy.last().at(0).value<quint32>(), 2u);
685 QCOMPARE(keyEventSpy.last().at(1).value<KWayland::Client::TextInput::KeyState>(), KWayland::Client::TextInput::KeyState::Released);
686 QCOMPARE(keyEventSpy.last().at(2).value<Qt::KeyboardModifiers>(), Qt::KeyboardModifiers());
687 QCOMPARE(keyEventSpy.last().at(3).value<quint32>(), 101u);
690void TextInputTest::testPreEdit()
693 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
694 auto serverSurface = waitForSurface();
695 QVERIFY(serverSurface);
697 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
698 QVERIFY(textInput !=
nullptr);
700 QVERIFY(textInput->composingText().isEmpty());
701 QVERIFY(textInput->composingFallbackText().isEmpty());
702 QCOMPARE(textInput->composingTextCursorPosition(), 0);
704 textInput->enable(surface.get());
705 m_connection->flush();
713 QSignalSpy composingTextChangedSpy(textInput.get(), &KWayland::Client::TextInput::composingTextChanged);
714 ti->setPreEditCursor(1);
715 ti->preEdit(QByteArrayLiteral(
"foo"), QByteArrayLiteral(
"bar"));
716 QVERIFY(composingTextChangedSpy.wait());
717 QCOMPARE(composingTextChangedSpy.count(), 1);
718 QCOMPARE(textInput->composingText(), QByteArrayLiteral(
"foo"));
719 QCOMPARE(textInput->composingFallbackText(), QByteArrayLiteral(
"bar"));
720 QCOMPARE(textInput->composingTextCursorPosition(), 1);
723 ti->preEdit(QByteArrayLiteral(
"foobar"), QByteArray());
724 QVERIFY(composingTextChangedSpy.wait());
725 QCOMPARE(composingTextChangedSpy.count(), 2);
726 QCOMPARE(textInput->composingText(), QByteArrayLiteral(
"foobar"));
727 QCOMPARE(textInput->composingFallbackText(), QByteArray());
728 QCOMPARE(textInput->composingTextCursorPosition(), 6);
731void TextInputTest::testCommit()
734 std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
735 auto serverSurface = waitForSurface();
736 QVERIFY(serverSurface);
738 std::unique_ptr<KWayland::Client::TextInput> textInput(createTextInput());
739 QVERIFY(textInput !=
nullptr);
741 QCOMPARE(textInput->commitText(), QByteArray());
742 QCOMPARE(textInput->cursorPosition(), 0);
743 QCOMPARE(textInput->anchorPosition(), 0);
744 QCOMPARE(textInput->deleteSurroundingText().beforeLength, 0u);
745 QCOMPARE(textInput->deleteSurroundingText().afterLength, 0u);
747 textInput->enable(surface.get());
748 m_connection->flush();
756 QSignalSpy committedSpy(textInput.get(), &KWayland::Client::TextInput::committed);
757 ti->setCursorPosition(3, 4);
758 ti->deleteSurroundingText(2, 1);
759 ti->commitString(QByteArrayLiteral(
"foo"));
761 QVERIFY(committedSpy.wait());
762 QCOMPARE(textInput->commitText(), QByteArrayLiteral(
"foo"));
763 QCOMPARE(textInput->cursorPosition(), 3);
764 QCOMPARE(textInput->anchorPosition(), 4);
765 QCOMPARE(textInput->deleteSurroundingText().beforeLength, 2u);
766 QCOMPARE(textInput->deleteSurroundingText().afterLength, 1u);
770#include "test_text_input_v2.moc"
void surfaceCreated(KWin::SurfaceInterface *surface)
Class holding the Wayland server display loop.
bool addSocketName(const QString &name=QString())
Represents a Seat on the Wayland Display.
SurfaceInterface * focusedTextInputSurface() const
void setHasTouch(bool has)
void setHasKeyboard(bool has)
void setTimestamp(std::chrono::microseconds time)
void focusedTextInputSurfaceChanged()
TextInputV2Interface * textInputV2() const
void setFocusedKeyboardSurface(SurfaceInterface *surface)
Resource representing a wl_surface.
Represent the Global for the interface.
void requestShowInputPanel()
void stateUpdated(uint32_t serial, UpdateReason reason)
void preferredLanguageChanged(const QString &language)
QPointer< SurfaceInterface > surface() const
void requestHideInputPanel()
void cursorRectangleChanged(const QRect &rect)
void surroundingTextChanged()
void contentTypeChanged()
#define CLEANUP(variable)