summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-11-01 10:38:04 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2013-11-01 10:38:04 +1000
commit1f7bbee82b079925fbbfc56cd3a786ea3c9af2f8 (patch)
tree7445fcba9cb834d2d60b679728bdeeca059199fa
parent764973c401e2059c7ead4ab08d96648a695c447b (diff)
server/misc: add a test for neg transition to zero
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--tests/server/misc.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/server/misc.cpp b/tests/server/misc.cpp
index f33457a..346d18a 100644
--- a/tests/server/misc.cpp
+++ b/tests/server/misc.cpp
@@ -544,6 +544,50 @@ TEST_F(IdletimerTest, NegativeTransitionMultipleAlarms)
ASSERT_EVENT(XSyncAlarmNotifyEvent, ev4, dpy, sync_event + XSyncAlarmNotify);
}
+TEST_F(IdletimerTest, NegativeTransitionToZero)
+{
+ XORG_TESTCASE("Set up an alarm on negative transition to 0\n"
+ "Move pointer\n"
+ "Expect event\n"
+ "Wait for timeout\n"
+ "Move pointer again\n"
+ "Expect event\n");
+
+ ::Display *dpy = Display();
+
+ /* make sure server is ready to send events */
+ WaitForEvent(dpy);
+ XSync(dpy, True);
+
+ XSyncAlarm neg_alarm;
+ XSyncCounter idlecounter;
+
+ /* bug: if the negative transition threshold fires but the idletime is
+ below the threshold, it is never set up again */
+ const int threshold = 0;
+ usleep(10000);
+
+ idlecounter = GetIdletimeCounter(dpy);
+ ASSERT_GT(idlecounter, (XSyncCounter)None);
+ neg_alarm = SetAbsoluteAlarm(dpy, idlecounter, threshold, XSyncNegativeTransition);
+ ASSERT_GT(neg_alarm, (XSyncAlarm)None);
+
+ dev->PlayOne(EV_REL, REL_X, 10, true);
+ WaitForEvent(dpy);
+ usleep(10000);
+
+ dev->PlayOne(EV_REL, REL_X, 10, true);
+ WaitForEvent(dpy);
+
+ ASSERT_EVENT(XSyncAlarmNotifyEvent, ev1, dpy, sync_event + XSyncAlarmNotify);
+ ASSERT_EQ(ev1->alarm, neg_alarm);
+ ASSERT_EQ(ev1->state, XSyncAlarmActive);
+
+ ASSERT_EVENT(XSyncAlarmNotifyEvent, ev2, dpy, sync_event + XSyncAlarmNotify);
+ ASSERT_EQ(ev2->alarm, neg_alarm);
+ ASSERT_EQ(ev1->state, XSyncAlarmActive);
+}
+
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();