From: Peter Hutterer Date: Wed, 22 Jan 2014 00:34:11 +0000 (+1000) Subject: test: add a simple touch test X-Git-Tag: 0.1.0~53 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=05cc4a8ca8eff1325d43869d1c603afce99f5830;p=platform%2Fupstream%2Flibinput.git test: add a simple touch test Currently testing for touch frame events only Signed-off-by: Peter Hutterer --- diff --git a/test/Makefile.am b/test/Makefile.am index 8b3d4dba..59687f60 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -16,7 +16,7 @@ liblitest_la_SOURCES = \ litest-wacom-touch.c \ litest.c -run_tests = test-udev test-path test-pointer +run_tests = test-udev test-path test-pointer test-touch build_tests = test-build-linker test-build-pedantic-c99 test-build-std-gnuc90 noinst_PROGRAMS = $(build_tests) $(run_tests) @@ -37,6 +37,11 @@ test_pointer_CFLAGS = $(AM_CPPFLAGS) test_pointer_LDADD = $(TEST_LIBS) test_pointer_LDFLAGS = -static +test_touch_SOURCES = touch.c +test_touch_CFLAGS = $(AM_CPPFLAGS) +test_touch_LDADD = $(TEST_LIBS) +test_touch_LDFLAGS = -static + # build-test only test_build_pedantic_c99_SOURCES = build-pedantic.c test_build_pedantic_c99_CFLAGS = $(AM_CPPFLAGS) -std=c99 -pedantic -Werror diff --git a/test/touch.c b/test/touch.c new file mode 100644 index 00000000..2d9ce0af --- /dev/null +++ b/test/touch.c @@ -0,0 +1,70 @@ +/* + * Copyright © 2013 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the copyright holders not be used in + * advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. The copyright holders make + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include +#include +#include +#include +#include + +#include "libinput-util.h" +#include "litest.h" + +START_TEST(touch_frame_events) +{ + struct litest_device *dev = litest_current_device(); + struct libinput *li = dev->libinput; + struct libinput_event *event; + int have_frame_event = 0; + + litest_drain_events(dev->libinput); + + litest_touch_down(dev, 0, 10, 10); + libinput_dispatch(li); + + while ((event = libinput_get_event(li))) { + if (libinput_event_get_type(event) == LIBINPUT_EVENT_TOUCH_FRAME) + have_frame_event++; + libinput_event_destroy(event); + } + ck_assert_int_eq(have_frame_event, 1); + + litest_touch_down(dev, 1, 10, 10); + libinput_dispatch(li); + + while ((event = libinput_get_event(li))) { + if (libinput_event_get_type(event) == LIBINPUT_EVENT_TOUCH_FRAME) + have_frame_event++; + libinput_event_destroy(event); + } + ck_assert_int_eq(have_frame_event, 2); +} +END_TEST + +int main (int argc, char **argv) { + + litest_add("touch:frame", touch_frame_events, LITEST_TOUCH, LITEST_ANY); + + return litest_run(argc, argv); +}