Changeset View
Changeset View
Standalone View
Standalone View
autotests/test_screen_edges.cpp
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | 119 | private Q_SLOTS: | |||
---|---|---|---|---|---|
125 | void testCreatingInitialEdges(); | 125 | void testCreatingInitialEdges(); | ||
126 | void testCallback(); | 126 | void testCallback(); | ||
127 | void testCallbackWithCheck(); | 127 | void testCallbackWithCheck(); | ||
128 | void testPushBack_data(); | 128 | void testPushBack_data(); | ||
129 | void testPushBack(); | 129 | void testPushBack(); | ||
130 | void testFullScreenBlocking(); | 130 | void testFullScreenBlocking(); | ||
131 | void testClientEdge(); | 131 | void testClientEdge(); | ||
132 | void testTouchEdge(); | 132 | void testTouchEdge(); | ||
133 | void testTouchCallback_data(); | ||||
134 | void testTouchCallback(); | ||||
133 | }; | 135 | }; | ||
134 | 136 | | |||
135 | void TestScreenEdges::initTestCase() | 137 | void TestScreenEdges::initTestCase() | ||
136 | { | 138 | { | ||
137 | qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(QX11Info::appRootWindow())); | 139 | qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(QX11Info::appRootWindow())); | ||
138 | qApp->setProperty("x11Connection", QVariant::fromValue<void*>(QX11Info::connection())); | 140 | qApp->setProperty("x11Connection", QVariant::fromValue<void*>(QX11Info::connection())); | ||
139 | KWin::atoms = new KWin::Atoms; | 141 | KWin::atoms = new KWin::Atoms; | ||
140 | qRegisterMetaType<KWin::ElectricBorder>(); | 142 | qRegisterMetaType<KWin::ElectricBorder>(); | ||
▲ Show 20 Lines • Show All 794 Lines • ▼ Show 20 Line(s) | 862 | { | |||
935 | for (auto e : edges) { | 937 | for (auto e : edges) { | ||
936 | QCOMPARE(e->isReserved(), false); | 938 | QCOMPARE(e->isReserved(), false); | ||
937 | QCOMPARE(e->activatesForPointer(), false); | 939 | QCOMPARE(e->activatesForPointer(), false); | ||
938 | QCOMPARE(e->activatesForTouchGesture(), false); | 940 | QCOMPARE(e->activatesForTouchGesture(), false); | ||
939 | } | 941 | } | ||
940 | 942 | | |||
941 | } | 943 | } | ||
942 | 944 | | |||
945 | void TestScreenEdges::testTouchCallback_data() | ||||
946 | { | ||||
947 | QTest::addColumn<KWin::ElectricBorder>("border"); | ||||
948 | QTest::addColumn<QPoint>("startPos"); | ||||
949 | QTest::addColumn<QSizeF>("delta"); | ||||
950 | | ||||
951 | QTest::newRow("left") << KWin::ElectricLeft << QPoint(0, 50) << QSizeF(250, 20); | ||||
952 | QTest::newRow("top") << KWin::ElectricTop << QPoint(50, 0) << QSizeF(20, 250); | ||||
953 | QTest::newRow("right") << KWin::ElectricRight << QPoint(99, 50) << QSizeF(-200, 0); | ||||
954 | QTest::newRow("bottom") << KWin::ElectricBottom << QPoint(50, 99) << QSizeF(0, -200); | ||||
955 | } | ||||
956 | | ||||
957 | void TestScreenEdges::testTouchCallback() | ||||
958 | { | ||||
959 | qRegisterMetaType<KWin::ElectricBorder>("ElectricBorder"); | ||||
960 | using namespace KWin; | ||||
961 | auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); | ||||
962 | auto group = config->group("TouchEdges"); | ||||
963 | group.writeEntry("Top", "none"); | ||||
964 | group.writeEntry("Left", "none"); | ||||
965 | group.writeEntry("Bottom", "none"); | ||||
966 | group.writeEntry("Right", "none"); | ||||
967 | config->sync(); | ||||
968 | | ||||
969 | auto s = ScreenEdges::self(); | ||||
970 | s->setConfig(config); | ||||
971 | s->init(); | ||||
972 | | ||||
973 | // none of our actions should be reserved | ||||
974 | const QList<Edge*> edges = s->findChildren<Edge*>(QString(), Qt::FindDirectChildrenOnly); | ||||
975 | QCOMPARE(edges.size(), 8); | ||||
976 | for (auto e : edges) { | ||||
977 | QCOMPARE(e->isReserved(), false); | ||||
978 | QCOMPARE(e->activatesForPointer(), false); | ||||
979 | QCOMPARE(e->activatesForTouchGesture(), false); | ||||
980 | } | ||||
981 | | ||||
982 | // let's reserve an action | ||||
983 | QAction action; | ||||
984 | QSignalSpy actionTriggeredSpy(&action, &QAction::triggered); | ||||
985 | QVERIFY(actionTriggeredSpy.isValid()); | ||||
986 | QSignalSpy approachingSpy(s, &ScreenEdges::approaching); | ||||
987 | QVERIFY(approachingSpy.isValid()); | ||||
988 | | ||||
989 | // reserve on edge | ||||
990 | QFETCH(KWin::ElectricBorder, border); | ||||
991 | s->reserveTouch(border, &action); | ||||
992 | for (auto e : edges) { | ||||
993 | QCOMPARE(e->isReserved(), e->border() == border); | ||||
994 | QCOMPARE(e->activatesForPointer(), false); | ||||
995 | QCOMPARE(e->activatesForTouchGesture(), e->border() == border); | ||||
996 | } | ||||
997 | | ||||
998 | QVERIFY(approachingSpy.isEmpty()); | ||||
999 | QFETCH(QPoint, startPos); | ||||
1000 | QCOMPARE(s->gestureRecognizer()->startSwipeGesture(startPos), 1); | ||||
1001 | QVERIFY(actionTriggeredSpy.isEmpty()); | ||||
1002 | QCOMPARE(approachingSpy.count(), 1); | ||||
1003 | QFETCH(QSizeF, delta); | ||||
1004 | s->gestureRecognizer()->updateSwipeGesture(delta); | ||||
1005 | QCOMPARE(approachingSpy.count(), 2); | ||||
1006 | QVERIFY(actionTriggeredSpy.isEmpty()); | ||||
1007 | s->gestureRecognizer()->endSwipeGesture(); | ||||
1008 | QVERIFY(actionTriggeredSpy.wait()); | ||||
1009 | QCOMPARE(actionTriggeredSpy.count(), 1); | ||||
1010 | QCOMPARE(approachingSpy.count(), 3); | ||||
1011 | | ||||
1012 | // unreserve again | ||||
1013 | s->unreserveTouch(border, &action); | ||||
1014 | for (auto e : edges) { | ||||
1015 | QCOMPARE(e->isReserved(), false); | ||||
1016 | QCOMPARE(e->activatesForPointer(), false); | ||||
1017 | QCOMPARE(e->activatesForTouchGesture(), false); | ||||
1018 | } | ||||
1019 | | ||||
1020 | // reserve another action | ||||
1021 | QScopedPointer<QAction> action2(new QAction); | ||||
1022 | s->reserveTouch(border, action2.data()); | ||||
1023 | for (auto e : edges) { | ||||
1024 | QCOMPARE(e->isReserved(), e->border() == border); | ||||
1025 | QCOMPARE(e->activatesForPointer(), false); | ||||
1026 | QCOMPARE(e->activatesForTouchGesture(), e->border() == border); | ||||
1027 | } | ||||
1028 | // and unreserve by destroying | ||||
1029 | action2.reset(); | ||||
1030 | for (auto e : edges) { | ||||
1031 | QCOMPARE(e->isReserved(), false); | ||||
1032 | QCOMPARE(e->activatesForPointer(), false); | ||||
1033 | QCOMPARE(e->activatesForTouchGesture(), false); | ||||
1034 | } | ||||
1035 | } | ||||
1036 | | ||||
943 | Q_CONSTRUCTOR_FUNCTION(forceXcb) | 1037 | Q_CONSTRUCTOR_FUNCTION(forceXcb) | ||
944 | QTEST_MAIN(TestScreenEdges) | 1038 | QTEST_MAIN(TestScreenEdges) | ||
945 | #include "test_screen_edges.moc" | 1039 | #include "test_screen_edges.moc" |