Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/decoration_input_test.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 57 | private Q_SLOTS: | |||
---|---|---|---|---|---|
71 | void testTapToMove_data(); | 71 | void testTapToMove_data(); | ||
72 | void testTapToMove(); | 72 | void testTapToMove(); | ||
73 | void testResizeOutsideWindow_data(); | 73 | void testResizeOutsideWindow_data(); | ||
74 | void testResizeOutsideWindow(); | 74 | void testResizeOutsideWindow(); | ||
75 | void testModifierClickUnrestrictedMove_data(); | 75 | void testModifierClickUnrestrictedMove_data(); | ||
76 | void testModifierClickUnrestrictedMove(); | 76 | void testModifierClickUnrestrictedMove(); | ||
77 | void testModifierScrollOpacity_data(); | 77 | void testModifierScrollOpacity_data(); | ||
78 | void testModifierScrollOpacity(); | 78 | void testModifierScrollOpacity(); | ||
79 | void testTouchEvents_data(); | ||||
80 | void testTouchEvents(); | ||||
79 | 81 | | |||
80 | private: | 82 | private: | ||
81 | AbstractClient *showWindow(Test::ShellSurfaceType type); | 83 | AbstractClient *showWindow(Test::ShellSurfaceType type); | ||
82 | }; | 84 | }; | ||
83 | 85 | | |||
84 | #define MOTION(target) \ | 86 | #define MOTION(target) \ | ||
85 | kwinApp()->platform()->pointerMotion(target, timestamp++) | 87 | kwinApp()->platform()->pointerMotion(target, timestamp++) | ||
86 | 88 | | |||
▲ Show 20 Lines • Show All 665 Lines • ▼ Show 20 Line(s) | 721 | { | |||
752 | kwinApp()->platform()->pointerAxisVertical(5, timestamp++); | 754 | kwinApp()->platform()->pointerAxisVertical(5, timestamp++); | ||
753 | QCOMPARE(c->opacity(), 0.5); | 755 | QCOMPARE(c->opacity(), 0.5); | ||
754 | kwinApp()->platform()->keyboardKeyReleased(modifierKey, timestamp++); | 756 | kwinApp()->platform()->keyboardKeyReleased(modifierKey, timestamp++); | ||
755 | if (capsLock) { | 757 | if (capsLock) { | ||
756 | kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); | 758 | kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); | ||
757 | } | 759 | } | ||
758 | } | 760 | } | ||
759 | 761 | | |||
762 | void DecorationInputTest::testTouchEvents_data() | ||||
763 | { | ||||
764 | QTest::addColumn<Test::ShellSurfaceType>("type"); | ||||
765 | | ||||
766 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | ||||
767 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | ||||
768 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | ||||
769 | } | ||||
770 | | ||||
771 | class EventHelper : public QObject | ||||
772 | { | ||||
773 | Q_OBJECT | ||||
774 | public: | ||||
775 | EventHelper() : QObject() {} | ||||
776 | ~EventHelper() override = default; | ||||
777 | | ||||
778 | bool eventFilter(QObject *watched, QEvent *event) override | ||||
779 | { | ||||
780 | Q_UNUSED(watched) | ||||
781 | if (event->type() == QEvent::HoverMove) { | ||||
782 | emit hoverMove(); | ||||
783 | } else if (event->type() == QEvent::HoverLeave) { | ||||
784 | emit hoverLeave(); | ||||
785 | } | ||||
786 | return false; | ||||
787 | } | ||||
788 | | ||||
789 | Q_SIGNALS: | ||||
790 | void hoverMove(); | ||||
791 | void hoverLeave(); | ||||
792 | }; | ||||
793 | | ||||
794 | void DecorationInputTest::testTouchEvents() | ||||
795 | { | ||||
796 | // this test verifies that the decoration gets a hover leave event on touch release | ||||
797 | // see BUG 386231 | ||||
798 | QFETCH(Test::ShellSurfaceType, type); | ||||
799 | AbstractClient *c = showWindow(type); | ||||
800 | QVERIFY(c); | ||||
801 | QVERIFY(c->isDecorated()); | ||||
802 | QVERIFY(!c->noBorder()); | ||||
803 | | ||||
804 | EventHelper helper; | ||||
805 | c->decoration()->installEventFilter(&helper); | ||||
806 | QSignalSpy hoverMoveSpy(&helper, &EventHelper::hoverMove); | ||||
807 | QVERIFY(hoverMoveSpy.isValid()); | ||||
808 | QSignalSpy hoverLeaveSpy(&helper, &EventHelper::hoverLeave); | ||||
809 | QVERIFY(hoverLeaveSpy.isValid()); | ||||
810 | | ||||
811 | quint32 timestamp = 1; | ||||
812 | const QPoint tapPoint(c->geometry().center().x(), c->clientPos().y() / 2); | ||||
813 | | ||||
814 | QVERIFY(!input()->touch()->decoration()); | ||||
815 | kwinApp()->platform()->touchDown(0, tapPoint, timestamp++); | ||||
816 | QVERIFY(input()->touch()->decoration()); | ||||
817 | QCOMPARE(input()->touch()->decoration()->decoration(), c->decoration()); | ||||
818 | QCOMPARE(hoverMoveSpy.count(), 1); | ||||
819 | QCOMPARE(hoverLeaveSpy.count(), 0); | ||||
820 | kwinApp()->platform()->touchUp(0, timestamp++); | ||||
821 | QCOMPARE(hoverMoveSpy.count(), 1); | ||||
822 | QCOMPARE(hoverLeaveSpy.count(), 1); | ||||
823 | | ||||
824 | QCOMPARE(c->isMove(), false); | ||||
825 | | ||||
826 | // let's check that a hover motion is sent if the pointer is on deco, when touch release | ||||
827 | Cursor::setPos(tapPoint); | ||||
828 | QCOMPARE(hoverMoveSpy.count(), 2); | ||||
829 | kwinApp()->platform()->touchDown(0, tapPoint, timestamp++); | ||||
830 | QCOMPARE(hoverMoveSpy.count(), 3); | ||||
831 | QCOMPARE(hoverLeaveSpy.count(), 1); | ||||
832 | kwinApp()->platform()->touchUp(0, timestamp++); | ||||
833 | QCOMPARE(hoverMoveSpy.count(), 4); | ||||
834 | QCOMPARE(hoverLeaveSpy.count(), 1); | ||||
835 | } | ||||
836 | | ||||
760 | } | 837 | } | ||
761 | 838 | | |||
762 | WAYLANDTEST_MAIN(KWin::DecorationInputTest) | 839 | WAYLANDTEST_MAIN(KWin::DecorationInputTest) | ||
763 | #include "decoration_input_test.moc" | 840 | #include "decoration_input_test.moc" |