| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818 |
- /*
- * Copyright © 2013 Red Hat, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
- #include "config.h"
- #include "litest-config.h"
- #ifndef LITEST_H
- #define LITEST_H
- #include <libevdev/libevdev-uinput.h>
- #include <libevdev/libevdev.h>
- #include <libinput.h>
- #include <math.h>
- #include <stdarg.h>
- #include <stdbool.h>
- #include "libinput-private-config.h"
- #include "libinput-util.h"
- #include "litest-runner.h"
- #include "quirks.h"
- DEFINE_DESTROY_CLEANUP_FUNC(libevdev_uinput);
- #define START_TEST(func_) \
- static enum litest_runner_result func_(const struct litest_runner_test_env *test_env) { \
- int _i _unused_ = test_env->rangeval;
- #define END_TEST \
- return LITEST_PASS; \
- }
- struct test_device {
- const char *name;
- struct litest_test_device *device;
- } __attribute__((aligned(16)));
- #define TEST_DEVICE(which, ...) \
- static struct litest_test_device _device; \
- \
- static void _setup(void) { \
- struct litest_device *d = litest_create_device(_device.type); \
- litest_set_current_device(d); \
- } \
- \
- static const struct test_device _test_device \
- __attribute__ ((used)) \
- __attribute__ ((section ("test_device_section"))) = { \
- #which, &_device \
- }; \
- static struct litest_test_device _device = { \
- .setup = _setup, \
- .shortname = #which, \
- .type = which, \
- __VA_ARGS__ \
- };
- struct test_collection {
- const char *name;
- void (*setup)(void);
- } __attribute__((aligned(16)));
- #define TEST_COLLECTION(name_) \
- static void (CONCAT(name_ , __LINE__))(void); \
- static const struct test_collection CONCAT(_test_collection_, __LINE__) \
- __attribute__ ((used)) \
- __attribute__ ((section ("test_collection_section"))) = { \
- #name_, CONCAT(name_, __LINE__) \
- }; \
- static void (CONCAT(name_, __LINE__))(void)
- #define litest_mark_test_start() \
- litest_checkpoint("==================== BOILERPLATE END. TEST CONTENT STARTING NOW ====================");
- __attribute__((format(printf, 3, 0))) void
- _litest_checkpoint(const char *func,
- int line,
- const char *color,
- const char *format,
- ...);
- #define litest_checkpoint(...) \
- _litest_checkpoint(__func__, __LINE__, ANSI_GREEN, __VA_ARGS__)
- #define litest_log_group(...) \
- for (bool i_ = ({ \
- litest_checkpoint("🭋🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂 %s:%3d 🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🭀", __func__, __LINE__); \
- litest_checkpoint(" " __VA_ARGS__); true; }); \
- i_; \
- i_ = ({litest_checkpoint("🭦🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭 %s:%3d 🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🭛", __func__, __LINE__); \
- false; }))
- /**
- * litest itself needs the user_data to store some test-suite-specific
- * information. Tests must not override this pointer, any data they need
- * they can hang off the private pointer in this struct.
- */
- struct litest_user_data {
- void *private;
- };
- void
- litest_fail_condition(const char *file,
- int line,
- const char *func,
- const char *condition,
- const char *message,
- ...);
- void
- litest_fail_comparison_int(const char *file,
- int line,
- const char *func,
- const char *operator,
- int a,
- int b,
- const char *astr,
- const char *bstr);
- void
- litest_fail_comparison_double(const char *file,
- int line,
- const char *func,
- const char *operator,
- double a,
- double b,
- const char *astr,
- const char *bstr);
- void
- litest_fail_comparison_ptr(const char *file,
- int line,
- const char *func,
- const char *comparison);
- void
- litest_fail_comparison_str(const char *file,
- int line,
- const char *func,
- const char *comparison,
- const char *operator,
- const char * astr,
- const char *bstr);
- #define litest_assert(cond) \
- do { \
- if (!(cond)) \
- litest_fail_condition(__FILE__, __LINE__, __func__, \
- #cond, NULL); \
- } while(0)
- #define litest_assert_msg(cond, ...) \
- do { \
- if (!(cond)) \
- litest_fail_condition(__FILE__, __LINE__, __func__, \
- #cond, __VA_ARGS__); \
- } while(0)
- #define litest_assert_not_reached() \
- litest_abort_msg("Triggered unreachable code\n")
- #define _litest_abort_msg(file_, line_, func_, ...) do {\
- litest_fail_condition(file_, line_, func_, \
- "aborting", __VA_ARGS__); \
- abort(); \
- } while (0)
- #define litest_abort_msg(...) \
- _litest_abort_msg(__FILE__, __LINE__, __func__, __VA_ARGS__)
- #define litest_assert_notnull(cond) \
- do { \
- if ((cond) == NULL) \
- litest_fail_condition(__FILE__, __LINE__, __func__, \
- #cond " != NULL", "\n"); \
- } while(0)
- #define litest_assert_comparison_int_(a_, op_, b_) \
- do { \
- __typeof__(a_) _a = a_; \
- __typeof__(b_) _b = b_; \
- if (trunc(_a) != _a || trunc(_b) != _b) \
- litest_abort_msg("litest_assert_int_* used for non-integer value\n"); \
- if (!((_a) op_ (_b))) \
- litest_fail_comparison_int(__FILE__, __LINE__, __func__,\
- #op_, _a, _b, \
- #a_, #b_); \
- } while(0)
- #define litest_assert_neg_errno_success(a_) \
- do { \
- __typeof__(a_) _a = a_; \
- if (_a < 0) \
- litest_abort_msg("Unexpected negative errno: %d (%s)", _a, strerror(-_a)); \
- } while(0);
- #define litest_assert_errno_success(a_) \
- do { \
- __typeof__(a_) _a = a_; \
- __typeof__(a_) _e = errno; \
- if (_a < 0) \
- litest_abort_msg("Unexpected errno: %d (%s)", _e, strerror(_e)); \
- } while(0);
- #define litest_assert_comparison_enum_(a_, op_, b_) \
- do { \
- __typeof__(a_) _a = a_; \
- __typeof__(a_) _b = b_; \
- if (!((_a) op_ (_b))) \
- litest_fail_comparison_int(__FILE__, __LINE__, __func__,\
- #op_, (int)_a, (int)_b, \
- #a_, #b_); \
- } while(0)
- #define litest_assert_enum_eq(a_, b_) \
- litest_assert_comparison_enum_(a_, ==, b_)
- #define litest_assert_enum_ne(a_, b_) \
- litest_assert_comparison_enum_(a_, !=, b_)
- #define litest_assert_int_eq(a_, b_) \
- litest_assert_comparison_int_(a_, ==, b_)
- #define litest_assert_int_ne(a_, b_) \
- litest_assert_comparison_int_(a_, !=, b_)
- #define litest_assert_int_lt(a_, b_) \
- litest_assert_comparison_int_(a_, <, b_)
- #define litest_assert_int_le(a_, b_) \
- litest_assert_comparison_int_(a_, <=, b_)
- #define litest_assert_int_ge(a_, b_) \
- litest_assert_comparison_int_(a_, >=, b_)
- #define litest_assert_int_gt(a_, b_) \
- litest_assert_comparison_int_(a_, >, b_)
- #define litest_assert_comparison_ptr_(a_, op_, b_) \
- do { \
- __typeof__(a_) _a = a_; \
- __typeof__(b_) _b = b_; \
- if (!((_a) op_ (_b))) \
- litest_fail_comparison_ptr(__FILE__, __LINE__, __func__,\
- #a_ " " #op_ " " #b_); \
- } while(0)
- #define litest_assert_ptr_eq(a_, b_) \
- litest_assert_comparison_ptr_(a_, ==, b_)
- #define litest_assert_ptr_ne(a_, b_) \
- litest_assert_comparison_ptr_(a_, !=, b_)
- #define litest_assert_ptr_null(a_) \
- litest_assert_comparison_ptr_(a_, ==, NULL)
- #define litest_assert_ptr_notnull(a_) \
- litest_assert_comparison_ptr_(a_, !=, NULL)
- #define litest_assert_str_eq(a_, b_) \
- do { \
- const char *_a = a_; \
- const char *_b = b_; \
- if (!streq(_a, _b)) \
- litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
- #a_ " == " #b_, \
- "==", \
- _a, _b); \
- } while(0)
- #define litest_assert_str_ne(a_, b_) \
- do { \
- const char *_a = a_; \
- const char *_b = b_; \
- if (streq(_a, _b)) \
- litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
- #a_ " != " #b_, \
- "!=", \
- _a, _b); \
- } while(0)
- #define litest_assert_str_in(needle_, haystack_) \
- do { \
- const char *_needle = needle_; \
- const char *_haystack = haystack_; \
- if (!strstr(_haystack, _needle)) \
- litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
- "'" #needle_ "' in: '" #haystack_ "'", \
- "in", \
- _needle, _haystack); \
- } while(0)
- #define litest_assert_str_not_in(needle_, haystack_) \
- do { \
- const char *_needle = needle_; \
- const char *_haystack = haystack_; \
- if (strstr(_haystack, _needle)) \
- litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
- "'" #needle_ "' not in: '" #haystack_ "'", \
- "not in", \
- _needle, _haystack); \
- } while(0)
- #define LITEST_DEFAULT_EPSILON 0.001
- #define litest_assert_double_eq_epsilon(a_, b_, epsilon_)\
- do { \
- __typeof__(a_) _a = a_; \
- __typeof__(b_) _b = b_; \
- if (!(fabs((_a) - (_b)) < epsilon_)) \
- litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
- "==", _a, _b, \
- #a_, #b_); \
- } while(0)
- #define litest_assert_double_ne_epsilon(a_, b_, epsilon_)\
- do { \
- __typeof__(a_) _a = a_; \
- __typeof__(b_) _b = b_; \
- if (!(fabs((_a) - (_b)) > epsilon_)) \
- litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
- "!=", _a, _b, \
- #a_, #b_); \
- } while(0)
- #define litest_assert_double_gt_epsilon(a_, b_, epsilon_)\
- do { \
- __typeof__(a_) _a = a_; \
- __typeof__(b_) _b = b_; \
- if (!(_a - (epsilon_) > _b)) \
- litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
- ">", _a, _b, \
- #a_, #b_); \
- } while(0)
- #define litest_assert_double_ge_epsilon(a_, b_, epsilon_)\
- do { \
- __typeof__(a_) _a = a_; \
- __typeof__(b_) _b = b_; \
- if (!(_a > _b || fabs((_a) - (_b)) < epsilon_)) \
- litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
- ">=", _a, _b, \
- #a_, #b_); \
- } while(0)
- #define litest_assert_double_lt_epsilon(a_, b_, epsilon_)\
- do { \
- __typeof__(a_) _a = a_; \
- __typeof__(b_) _b = b_; \
- if (!(_a < _b - (epsilon_))) \
- litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
- "<", _a, _b, \
- #a_, #b_); \
- } while(0)
- #define litest_assert_double_le_epsilon(a_, b_, epsilon_)\
- do { \
- __typeof__(a_) _a = a_; \
- __typeof__(b_) _b = b_; \
- if (!(_a < _b || fabs((_a) - (_b)) < epsilon_)) \
- litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
- "<=", _a, _b, \
- #a_, #b_); \
- } while(0)
- #define litest_assert_comparison_double_(a_, op_, b_) \
- litest_assert_comparison_double_epsilon_(a_, op_, b_, LITEST_DEFAULT_EPSILON)
- #define litest_assert_double_eq(a_, b_)\
- litest_assert_double_eq_epsilon((a_), (b_), LITEST_DEFAULT_EPSILON)
- #define litest_assert_double_ne(a_, b_)\
- litest_assert_double_ne_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
- #define litest_assert_double_lt(a_, b_)\
- litest_assert_double_lt_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
- #define litest_assert_double_le(a_, b_)\
- litest_assert_double_le_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
- #define litest_assert_double_gt(a_, b_)\
- litest_assert_double_gt_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
- #define litest_assert_double_ge(a_, b_)\
- litest_assert_double_ge_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
- void
- _litest_assert_strv_substring(char **strv,
- char *substring,
- const char *file,
- const char *func,
- int line);
- #define litest_assert_strv_substring(strv_, substring_) \
- _litest_assert_strv_substring(strv_, substring_, __FILE__, __func__, __LINE__)
- void
- _litest_assert_strv_no_substring(char **strv,
- char *substring,
- const char *file,
- const char *func,
- int line);
- #define litest_assert_strv_no_substring(strv_, substring_) \
- _litest_assert_strv_no_substring(strv_, substring_, __FILE__, __func__, __LINE__)
- void
- litest_backtrace(const char *func);
- enum litest_device_type {
- LITEST_NO_DEVICE = -1,
- /* Touchpads and associated devices */
- LITEST_ACER_HAWAII_TOUCHPAD = -1000,
- LITEST_GENERIC_USBCOMBO_TOUCHPAD,
- LITEST_AIPTEK,
- LITEST_ALPS_3FG,
- LITEST_ALPS_DUALPOINT,
- LITEST_ALPS_SEMI_MT,
- LITEST_APPLETOUCH,
- LITEST_ATMEL_HOVER,
- LITEST_BCM5974,
- LITEST_ELANTECH_TOUCHPAD,
- LITEST_GENERIC_PRESSUREPAD,
- LITEST_MAGIC_TRACKPAD,
- LITEST_SYNAPTICS_CLICKPAD_X220,
- LITEST_SYNAPTICS_HOVER_SEMI_MT,
- LITEST_SYNAPTICS_I2C,
- LITEST_SYNAPTICS_PHANTOMCLICKS,
- LITEST_SYNAPTICS_PRESSUREPAD,
- LITEST_SYNAPTICS_RMI4,
- LITEST_SYNAPTICS_TOPBUTTONPAD,
- LITEST_SYNAPTICS_TOUCHPAD,
- LITEST_TOUCHPAD_PALMPRESSURE_ZERO,
- LITEST_WACOM_INTUOS5_FINGER,
- /* Touchscreens */
- LITEST_CALIBRATED_TOUCHSCREEN,
- LITEST_GENERIC_MULTITOUCH_SCREEN,
- LITEST_GENERIC_SINGLETOUCH,
- LITEST_MS_SURFACE_COVER,
- LITEST_MULTITOUCH_FUZZ_SCREEN,
- LITEST_NEXUS4_TOUCH_SCREEN,
- LITEST_PROTOCOL_A_SCREEN,
- LITEST_TOUCHSCREEN_INVALID_RANGE,
- LITEST_TOUCHSCREEN_MT_TOOL_TYPE,
- LITEST_WACOM_ISDV4_E6_FINGER,
- /* Pointing devices and keyboards */
- LITEST_MOUSE,
- LITEST_MOUSE_PS2,
- LITEST_KEYBOARD,
- LITEST_TRACKPOINT,
- LITEST_ABSINFO_OVERRIDE,
- LITEST_ACER_HAWAII_KEYBOARD,
- LITEST_GENERIC_USBCOMBO_KEYBOARD,
- LITEST_ANKER_MOUSE_KBD,
- LITEST_APPLE_KEYBOARD,
- LITEST_CYBORG_RAT,
- LITEST_HP_WMI_HOTKEYS,
- LITEST_IGNORED_MOUSE,
- LITEST_KEYBOARD_ALL_CODES,
- LITEST_KEYBOARD_BLACKWIDOW,
- LITEST_KEYBOARD_BLADE_STEALTH,
- LITEST_KEYBOARD_BLADE_STEALTH_VIDEOSWITCH,
- LITEST_KEYBOARD_LOGITECH_MEDIA_KEYBOARD_ELITE,
- LITEST_KEYBOARD_QUIRKED,
- LITEST_LENOVO_SCROLLPOINT,
- LITEST_LOGITECH_TRACKBALL,
- LITEST_MAGICMOUSE,
- LITEST_MOUSE_FORMAT_STRING,
- LITEST_MOUSE_GLADIUS,
- LITEST_MOUSE_LOW_DPI,
- LITEST_MOUSE_ROCCAT,
- LITEST_MOUSE_VIRTUAL,
- LITEST_MOUSE_WHEEL_CLICK_ANGLE,
- LITEST_MOUSE_WHEEL_CLICK_COUNT,
- LITEST_MOUSE_WHEEL_TILT,
- LITEST_MOUSE_WHEEL_HIRES_DISABLED,
- LITEST_MS_NANO_TRANSCEIVER_MOUSE,
- LITEST_SONY_VAIO_KEYS,
- LITEST_SYNAPTICS_TRACKPOINT_BUTTONS,
- LITEST_THINKPAD_EXTRABUTTONS,
- LITEST_VMWARE_VIRTMOUSE,
- LITEST_WHEEL_ONLY,
- LITEST_XEN_VIRTUAL_POINTER,
- /* Switches */
- LITEST_LID_SWITCH,
- LITEST_LID_SWITCH_SURFACE3,
- LITEST_KEYPAD_SLIDE_SWITCH,
- LITEST_TABLET_MODE_UNRELIABLE,
- /* Special devices */
- LITEST_DELL_CANVAS_TOTEM,
- LITEST_DELL_CANVAS_TOTEM_TOUCH,
- LITEST_GPIO_KEYS,
- LITEST_YUBIKEY,
- /* Tablets */
- LITEST_ELAN_TABLET,
- LITEST_HUION_TABLET,
- LITEST_HUION_Q620M_DIAL,
- LITEST_PLOOPY_PAVONIS_STYLUS,
- LITEST_QEMU_TABLET,
- LITEST_TABLET_DOUBLEDIAL_PAD,
- LITEST_TABLET_REL_DIAL_PAD,
- LITEST_UCLOGIC_TABLET,
- LITEST_WACOM_BAMBOO_16FG_PEN,
- LITEST_WACOM_BAMBOO_2FG_FINGER,
- LITEST_WACOM_BAMBOO_2FG_PAD,
- LITEST_WACOM_BAMBOO_2FG_PEN,
- LITEST_WACOM_CALIBRATED_TABLET_PEN,
- LITEST_WACOM_CINTIQ_12WX_PEN,
- LITEST_WACOM_CINTIQ_13HDT_FINGER,
- LITEST_WACOM_CINTIQ_13HDT_PAD,
- LITEST_WACOM_CINTIQ_13HDT_PEN,
- LITEST_WACOM_CINTIQ_24HDT_PAD,
- LITEST_WACOM_CINTIQ_24HD_PEN,
- LITEST_WACOM_CINTIQ_PRO16_FINGER,
- LITEST_WACOM_CINTIQ_PRO16_PAD,
- LITEST_WACOM_CINTIQ_PRO16_PEN,
- LITEST_WACOM_EKR,
- LITEST_WACOM_HID4800_PEN,
- LITEST_WACOM_INTUOS3_PAD,
- LITEST_WACOM_INTUOS5_PAD,
- LITEST_WACOM_INTUOS5_PEN,
- LITEST_WACOM_ISDV4_4200_PEN,
- LITEST_WACOM_ISDV4_524C_PEN,
- LITEST_WACOM_ISDV4_E6_PEN,
- LITEST_WACOM_MOBILESTUDIO_PRO_16_PAD,
- LITEST_WALTOP,
- };
- #define LITEST_DEVICELESS -2
- #define LITEST_DISABLE_DEVICE -1
- #define LITEST_ANY 0
- #define LITEST_TOUCHPAD bit(0)
- #define LITEST_CLICKPAD bit(1)
- #define LITEST_BUTTON bit(2)
- #define LITEST_KEYS bit(3)
- #define LITEST_RELATIVE bit(4)
- #define LITEST_WHEEL bit(5)
- #define LITEST_TOUCH bit(6)
- #define LITEST_SINGLE_TOUCH bit(7)
- #define LITEST_APPLE_CLICKPAD bit(8)
- #define LITEST_TOPBUTTONPAD bit(9)
- #define LITEST_SEMI_MT bit(10)
- #define LITEST_POINTINGSTICK bit(11)
- #define LITEST_FAKE_MT bit(12)
- #define LITEST_ABSOLUTE bit(13)
- #define LITEST_PROTOCOL_A bit(14)
- #define LITEST_HOVER bit(15)
- #define LITEST_ELLIPSE bit(16)
- #define LITEST_TABLET bit(17)
- #define LITEST_DISTANCE bit(18)
- #define LITEST_TOOL_SERIAL bit(19)
- #define LITEST_TILT bit(20)
- #define LITEST_TABLET_PAD bit(21)
- #define LITEST_RING bit(22)
- #define LITEST_STRIP bit(23)
- #define LITEST_TRACKBALL bit(24)
- #define LITEST_LEDS bit(25)
- #define LITEST_SWITCH bit(26)
- #define LITEST_IGNORED bit(27)
- #define LITEST_NO_DEBOUNCE bit(28)
- #define LITEST_TOOL_MOUSE bit(29)
- #define LITEST_DIRECT bit(30)
- #define LITEST_TOTEM bit(31)
- #define LITEST_FORCED_PROXOUT bit(32)
- #define LITEST_PRECALIBRATED bit(33)
- #define LITEST_DIAL bit(34)
- /* this is a semi-mt device, so we keep track of the touches that the tests
- * send and modify them so that the first touch is always slot 0 and sends
- * the top-left of the bounding box, the second is always slot 1 and sends
- * the bottom-right of the bounding box.
- * Lifting any of two fingers terminates slot 1
- */
- struct litest_semi_mt {
- bool is_semi_mt;
- int tracking_id;
- /* The actual touches requested by the test for the two slots
- * in the 0..100 range used by litest */
- struct {
- double x, y;
- } touches[2];
- };
- struct litest_device {
- enum litest_device_type which;
- struct libevdev *evdev;
- struct libevdev_uinput *uinput;
- struct libinput *libinput;
- struct quirks *quirks;
- bool owns_context;
- struct libinput_device *libinput_device;
- struct litest_device_interface *interface;
- struct {
- struct input_event events[64];
- size_t nevents;
- } frame;
- int ntouches_down;
- int skip_ev_syn;
- struct litest_semi_mt semi_mt; /** only used for semi-mt device */
- void *private; /* device-specific data */
- };
- struct axis_replacement {
- int32_t evcode;
- double value;
- };
- /**
- * Same as litest_axis_set_value but allows for ranges outside 0..100%
- */
- static inline void
- litest_axis_set_value_unchecked(struct axis_replacement *axes, int code, double value)
- {
- while (axes->evcode != -1) { /* NOLINT(clang-analyzer-security.ArrayBound) */
- if (axes->evcode == code) {
- axes->value = value;
- return;
- }
- axes++;
- }
- litest_abort_msg("Missing axis code %d\n", code);
- }
- /**
- * Takes a value in percent and sets the given axis to that code.
- */
- static inline void
- litest_axis_set_value(struct axis_replacement *axes, int code, double value)
- {
- litest_assert_double_ge(value, 0.0);
- litest_assert_double_le(value, 100.0);
- litest_axis_set_value_unchecked(axes, code, value);
- }
- struct libinput *
- litest_create_context(void);
- /* Adds the given plugin dir to the context but does *not* initialize
- * the plugins */
- struct libinput *
- litest_create_context_with_plugindir(const char *plugindir);
- void
- litest_destroy_context(struct libinput *li);
- DEFINE_TRIVIAL_CLEANUP_FUNC(struct libinput *, litest_destroy_context);
- #define _litest_context_destroy_ _cleanup_(litest_destroy_contextp)
- void
- litest_context_set_user_data(struct libinput *li, void *data);
- void *
- litest_context_get_user_data(struct libinput *li);
- void
- litest_disable_log_handler(struct libinput *libinput);
- void
- litest_restore_log_handler(struct libinput *libinput);
- void
- litest_set_log_handler_bug(struct libinput *libinput);
- struct litest_parameters;
- /**
- * Create a new set of parameters for a test case.
- *
- * This function takes a variable set of arguments in the format
- * [name, type, count, arg1, arg2, arg3, ..], for example:
- *
- * litest_parameter_new("axis", 'u', 2, ABS_X, ABS_Y,
- * "direction", 's', 4, "north", "south", "east", "west",
- * NULL);
- *
- * Parsing stops at the first null name argument.
- */
- struct litest_parameters *
- _litest_parameters_new(const char *name, ...);
- /* Helper to ensure it's always null-terminated */
- #define litest_parameters_new(name_, ...) \
- _litest_parameters_new(name_, __VA_ARGS__, NULL)
- #define litest_with_parameters(params_, ...) \
- for (struct litest_parameters *params_ = litest_parameters_new(__VA_ARGS__); \
- params_; \
- params_ = litest_parameters_unref(params_))
- #define _LITEST_NAMED_I32(v_, n_, ...) (struct litest_named_i32){ .value = v_, .name = n_ }
- /* Helper to default second argument to stringification of first argument.
- * This allows for two uses of this macro:
- * - litest_named_i32(0) expands to { 0, "0" }
- * - litest_named_i32(0, "zero") expands to (effectively) { 0, "zero" }
- */
- #define litest_named_i32(...) _LITEST_NAMED_I32(__VA_ARGS__, #__VA_ARGS__)
- struct litest_named_i32 {
- int32_t value;
- const char *name;
- };
- struct litest_parameters_permutation_value {
- struct list link;
- char name[128];
- const struct multivalue value;
- };
- /**
- * Argument for the callback function to litest_parameters_permutations().
- * This is simple wrapper around a linked list that contains all elements
- * of the current permutation.
- */
- struct litest_parameters_permutation {
- struct list values; /* struct litest_parameters_permutation_value */
- };
- /**
- * Callback function invoked for each permutation of a struct litest_parameters.
- */
- typedef int (*litest_parameters_permutation_func_t)(
- struct litest_parameters_permutation *permutation,
- void *userdata);
- /**
- * Permutates the given parameters and calls func for every possible
- * permutation. If func returns a nonzero status, permutation stops
- * and that nonzero status is returned to the caller.
- *
- * Userdata is passed through as-is.
- */
- int
- litest_parameters_permutations(struct litest_parameters *params,
- litest_parameters_permutation_func_t func,
- void *userdata);
- struct litest_parameters *
- litest_parameters_ref(struct litest_parameters *p);
- struct litest_parameters *
- litest_parameters_unref(struct litest_parameters *params);
- #define litest_add(func_, ...) \
- _litest_add(__FILE__, #func_, func_, __VA_ARGS__)
- #define litest_add_ranged(func_, ...) \
- _litest_add_ranged(__FILE__, #func_, func_, __VA_ARGS__)
- #define litest_add_parametrized(func_, ...) \
- _litest_add_parametrized(__FILE__, #func_, func_, __VA_ARGS__)
- #define litest_add_for_device(func_, ...) \
- _litest_add_for_device(__FILE__, #func_, func_, __VA_ARGS__)
- #define litest_add_ranged_for_device(func_, ...) \
- _litest_add_ranged_for_device(__FILE__, #func_, func_, __VA_ARGS__)
- #define litest_add_parametrized_for_device(func_, ...) \
- _litest_add_parametrized_for_device(__FILE__, #func_, func_, __VA_ARGS__)
- #define litest_add_no_device(func_) \
- _litest_add_no_device(__FILE__, #func_, func_)
- #define litest_add_parametrized_no_device(func_, ...) \
- _litest_add_parametrized_no_device(__FILE__, #func_, func_, __VA_ARGS__)
- #define litest_add_ranged_no_device(func_, ...) \
- _litest_add_ranged_no_device(__FILE__, #func_, func_, __VA_ARGS__)
- #define litest_add_deviceless(func_) \
- _litest_add_deviceless(__FILE__, #func_, func_)
- #define litest_add_parametrized_deviceless(func_, params) \
- _litest_add_parametrize_deviceless(__FILE__, #func_, func_, params)
- void
- _litest_add(const char *name,
- const char *funcname,
- const void *func,
- int64_t required_feature,
- int64_t excluded_feature);
- void
- _litest_add_ranged(const char *name,
- const char *funcname,
- const void *func,
- int64_t required,
- int64_t excluded,
- const struct range *range);
- void
- _litest_add_parametrized(const char *name,
- const char *funcname,
- const void *func,
- int64_t required,
- int64_t excluded,
- struct litest_parameters *params);
- void
- _litest_add_for_device(const char *name,
- const char *funcname,
- const void *func,
- enum litest_device_type type);
- void
- _litest_add_ranged_for_device(const char *name,
- const char *funcname,
- const void *func,
- enum litest_device_type type,
- const struct range *range);
- void
- _litest_add_parametrized_for_device(const char *name,
- const char *funcname,
- const void *func,
- enum litest_device_type type,
- struct litest_parameters *params);
- void
- _litest_add_no_device(const char *name, const char *funcname, const void *func);
- void
- _litest_add_parametrized_no_device(const char *name,
- const char *funcname,
- const void *func,
- struct litest_parameters *params);
- void
- _litest_add_ranged_no_device(const char *name,
- const char *funcname,
- const void *func,
- const struct range *range);
- void
- _litest_add_deviceless(const char *name, const char *funcname, const void *func);
- void
- _litest_add_parametrized_deviceless(const char *name,
- const char *funcname,
- const void *func,
- struct litest_parameters *params);
- struct litest_device *
- litest_create_device(enum litest_device_type which);
- struct litest_device *
- litest_add_device(struct libinput *libinput, enum litest_device_type which);
- struct libevdev_uinput *
- litest_create_uinput_device_from_description(const char *name,
- const struct input_id *id,
- const struct input_absinfo *abs,
- const int *events);
- struct litest_device *
- litest_create(enum litest_device_type which,
- const char *name_override,
- struct input_id *id_override,
- const struct input_absinfo *abs_override,
- const int *events_override);
- struct litest_device *
- litest_create_device_with_overrides(enum litest_device_type which,
- const char *name_override,
- struct input_id *id_override,
- const struct input_absinfo *abs_override,
- const int *events_override);
- struct litest_device *
- litest_add_device_with_overrides(struct libinput *libinput,
- enum litest_device_type which,
- const char *name_override,
- struct input_id *id_override,
- const struct input_absinfo *abs_override,
- const int *events_override);
- struct litest_device *
- litest_current_device(void);
- void
- litest_grab_device(struct litest_device *d);
- void
- litest_ungrab_device(struct litest_device *d);
- void
- litest_device_destroy(struct litest_device *d);
- DEFINE_DESTROY_CLEANUP_FUNC(litest_device);
- const char *
- litest_event_type_str(enum libinput_event_type type);
- int
- _litest_dispatch(struct libinput *li, const char *func, int line);
- #define litest_dispatch(li_) \
- _litest_dispatch(li_, __func__, __LINE__)
- void
- litest_event(struct litest_device *t, unsigned int type, unsigned int code, int value);
- void
- litest_event_unchecked(struct litest_device *d,
- unsigned int type,
- unsigned int code,
- int value);
- int
- litest_auto_assign_value(struct litest_device *d,
- const struct input_event *ev,
- int slot,
- double x,
- double y,
- struct axis_replacement *axes,
- bool touching);
- void
- litest_touch_up(struct litest_device *d, unsigned int slot);
- void
- litest_touch_move(struct litest_device *d, unsigned int slot, double x, double y);
- void
- litest_touch_move_extended(struct litest_device *d,
- unsigned int slot,
- double x,
- double y,
- struct axis_replacement *axes);
- void
- litest_touch_sequence(struct litest_device *d,
- unsigned int slot,
- double x1,
- double y1,
- double x2,
- double y2,
- int steps);
- void
- litest_touch_down(struct litest_device *d, unsigned int slot, double x, double y);
- void
- litest_touch_down_extended(struct litest_device *d,
- unsigned int slot,
- double x,
- double y,
- struct axis_replacement *axes);
- void
- litest_touch_move_to(struct litest_device *d,
- unsigned int slot,
- double x_from,
- double y_from,
- double x_to,
- double y_to,
- int steps);
- void
- litest_touch_move_to_extended(struct litest_device *d,
- unsigned int slot,
- double x_from,
- double y_from,
- double x_to,
- double y_to,
- struct axis_replacement *axes,
- int steps);
- void
- litest_touch_move_two_touches(struct litest_device *d,
- double x0,
- double y0,
- double x1,
- double y1,
- double dx,
- double dy,
- int steps);
- void
- litest_touch_move_three_touches(struct litest_device *d,
- double x0,
- double y0,
- double x1,
- double y1,
- double x2,
- double y2,
- double dx,
- double dy,
- int steps);
- void
- litest_tablet_set_tool_type(struct litest_device *d, unsigned int code);
- void
- litest_tablet_proximity_in(struct litest_device *d,
- double x,
- double y,
- struct axis_replacement *axes);
- void
- litest_tablet_proximity_out(struct litest_device *d);
- void
- litest_tablet_tip_down(struct litest_device *d,
- double x,
- double y,
- struct axis_replacement *axes);
- void
- litest_tablet_tip_up(struct litest_device *d,
- double x,
- double y,
- struct axis_replacement *axes);
- void
- litest_tablet_motion(struct litest_device *d,
- double x,
- double y,
- struct axis_replacement *axes);
- void
- litest_pad_ring_start(struct litest_device *d, double value);
- void
- litest_pad_ring_change(struct litest_device *d, double value);
- void
- litest_pad_ring_end(struct litest_device *d);
- void
- litest_pad_strip_start(struct litest_device *d, double value);
- void
- litest_pad_strip_change(struct litest_device *d, double value);
- void
- litest_pad_strip_end(struct litest_device *d);
- void
- litest_hover_start(struct litest_device *d, unsigned int slot, double x, double y);
- void
- litest_hover_end(struct litest_device *d, unsigned int slot);
- void
- litest_hover_move(struct litest_device *d, unsigned int slot, double x, double y);
- void
- litest_hover_move_to(struct litest_device *d,
- unsigned int slot,
- double x_from,
- double y_from,
- double x_to,
- double y_to,
- int steps);
- void
- litest_hover_move_two_touches(struct litest_device *d,
- double x0,
- double y0,
- double x1,
- double y1,
- double dx,
- double dy,
- int steps);
- void
- litest_button_click_debounced(struct litest_device *d,
- struct libinput *li,
- unsigned int button,
- bool is_press);
- void
- litest_button_click(struct litest_device *d, unsigned int button, bool is_press);
- void
- litest_button_scroll(struct litest_device *d,
- unsigned int button,
- double dx,
- double dy);
- void
- litest_button_scroll_locked(struct litest_device *d,
- unsigned int button,
- double dx,
- double dy);
- void
- litest_keyboard_key(struct litest_device *d, unsigned int key, bool is_press);
- void
- litest_switch_action(struct litest_device *d,
- enum libinput_switch sw,
- enum libinput_switch_state state);
- void
- litest_wait_for_event(struct libinput *li);
- void
- _litest_wait_for_event_of_type(struct libinput *li, const char *func, int lineno, ...);
- #define litest_wait_for_event_of_type(li_, ...) \
- _litest_wait_for_event_of_type(li_, __func__, __LINE__, __VA_ARGS__, -1)
- void
- litest_drain_events(struct libinput *li);
- void
- _litest_drain_events_of_type(struct libinput *li, ...);
- #define litest_drain_events_of_type(li_, ...) \
- _litest_drain_events_of_type(li_, __VA_ARGS__, -1)
- #define litest_assert_event_type(e_, want_) \
- _litest_assert_event_type(e_, want_, __func__, __LINE__)
- void
- _litest_assert_event_type(struct libinput_event *event,
- enum libinput_event_type want,
- const char *func,
- int lineno);
- #define litest_assert_event_type_is_one_of(ev_, ...) \
- _litest_assert_event_type_is_one_of(ev_, __func__, __LINE__, __VA_ARGS__, -1)
- void
- _litest_assert_event_type_is_one_of(struct libinput_event *event,
- const char *func,
- int lineno,
- ...);
- #define litest_assert_event_type_not_one_of(ev_, ...) \
- _litest_assert_event_type_not_one_of(ev_, __func__, __LINE__, __VA_ARGS__, -1)
- void
- _litest_assert_event_type_not_one_of(struct libinput_event *event,
- const char *func,
- int lineno,
- ...);
- #define litest_assert_empty_queue(li_) \
- _litest_assert_empty_queue(li_, __func__, __LINE__)
- void
- _litest_assert_empty_queue(struct libinput *li, const char *func, int line);
- void
- litest_assert_touch_sequence(struct libinput *li);
- void
- litest_assert_touch_motion_frame(struct libinput *li);
- void
- litest_assert_touch_down_frame(struct libinput *li);
- void
- litest_assert_touch_up_frame(struct libinput *li);
- void
- litest_assert_touch_cancel(struct libinput *li);
- struct libinput_event_pointer *
- litest_is_button_event(struct libinput_event *event,
- unsigned int button,
- enum libinput_button_state state);
- struct libinput_event_pointer *
- litest_is_axis_event(struct libinput_event *event,
- enum libinput_event_type axis_type,
- enum libinput_pointer_axis axis,
- enum libinput_pointer_axis_source source);
- bool
- litest_is_high_res_axis_event(struct libinput_event *event);
- struct libinput_event_pointer *
- litest_is_motion_event(struct libinput_event *event);
- struct libinput_event_touch *
- litest_is_touch_event(struct libinput_event *event, enum libinput_event_type type);
- struct libinput_event_keyboard *
- litest_is_keyboard_event(struct libinput_event *event,
- unsigned int key,
- enum libinput_key_state state);
- struct libinput_event_gesture *
- litest_is_gesture_event(struct libinput_event *event,
- enum libinput_event_type type,
- int nfingers);
- struct libinput_event_tablet_tool *
- litest_is_tablet_event(struct libinput_event *event, enum libinput_event_type type);
- struct libinput_event_tablet_pad *
- litest_is_pad_button_event(struct libinput_event *event,
- unsigned int button,
- enum libinput_button_state state);
- struct libinput_event_tablet_pad *
- litest_is_pad_dial_event(struct libinput_event *event, unsigned int number);
- struct libinput_event_tablet_pad *
- litest_is_pad_ring_event(struct libinput_event *event,
- unsigned int number,
- enum libinput_tablet_pad_ring_axis_source source);
- struct libinput_event_tablet_pad *
- litest_is_pad_strip_event(struct libinput_event *event,
- unsigned int number,
- enum libinput_tablet_pad_strip_axis_source source);
- struct libinput_event_tablet_pad *
- litest_is_pad_key_event(struct libinput_event *event,
- unsigned int key,
- enum libinput_key_state state);
- struct libinput_event_switch *
- litest_is_switch_event(struct libinput_event *event,
- enum libinput_switch sw,
- enum libinput_switch_state state);
- struct libinput_event_tablet_tool *
- litest_is_proximity_event(struct libinput_event *event,
- enum libinput_tablet_tool_proximity_state state);
- double
- litest_event_pointer_get_value(struct libinput_event_pointer *ptrev,
- enum libinput_pointer_axis axis);
- enum libinput_pointer_axis_source
- litest_event_pointer_get_axis_source(struct libinput_event_pointer *event);
- #define litest_assert_key_event(li_, key_, state_) \
- _litest_assert_key_event(li_, key_, state_, __func__, __LINE__)
- void
- _litest_assert_key_event(struct libinput *li,
- unsigned int key,
- enum libinput_key_state state,
- const char *func,
- int lineno);
- #define litest_assert_button_event(li_, button_, state_) \
- _litest_assert_button_event(li_, button_, state_, __func__, __LINE__)
- void
- _litest_assert_button_event(struct libinput *li,
- unsigned int button,
- enum libinput_button_state state,
- const char *func,
- int line);
- #define litest_assert_switch_event(li_, sw_, state_) \
- _litest_assert_switch_event(li_, sw_, state_, __func__, __LINE__)
- void
- _litest_assert_switch_event(struct libinput *li,
- enum libinput_switch sw,
- enum libinput_switch_state state,
- const char *func,
- int lineno);
- void
- litest_assert_scroll(struct libinput *li,
- enum libinput_event_type axis_type,
- enum libinput_pointer_axis axis,
- int minimum_movement);
- void
- litest_assert_axis_end_sequence(struct libinput *li,
- enum libinput_event_type axis_type,
- enum libinput_pointer_axis axis,
- enum libinput_pointer_axis_source source);
- #define litest_assert_only_typed_events(...) \
- _litest_assert_only_typed_events(__VA_ARGS__, __func__, __LINE__)
- void
- _litest_assert_only_typed_events(struct libinput *li,
- enum libinput_event_type type,
- const char *func,
- int line);
- void
- litest_assert_only_axis_events(struct libinput *li, enum libinput_event_type axis_type);
- void
- litest_assert_no_typed_events(struct libinput *li, enum libinput_event_type type);
- #define litest_assert_tablet_button_event(li_, button_, state_) \
- _litest_assert_tablet_button_event(li_, button_, state_, __func__, __LINE__)
- void
- _litest_assert_tablet_button_event(struct libinput *li,
- unsigned int button,
- enum libinput_button_state state,
- const char *func,
- int lineno);
- #define litest_assert_tablet_axis_event(li_) \
- _litest_assert_tablet_axis_event(li_, __func__, __LINE__)
- void
- _litest_assert_tablet_axis_event(struct libinput *li, const char *func, int lineno);
- #define litest_assert_tablet_proximity_event(li_, state_) \
- _litest_assert_tablet_proximity_event(li_, state_, __func__, __LINE__)
- void
- _litest_assert_tablet_proximity_event(struct libinput *li,
- enum libinput_tablet_tool_proximity_state state,
- const char *func,
- int lineno);
- #define litest_assert_tablet_tip_event(li_, state_) \
- _litest_assert_tablet_tip_event(li_, state_, __func__, __LINE__)
- void
- _litest_assert_tablet_tip_event(struct libinput *li,
- enum libinput_tablet_tool_tip_state state,
- const char *func,
- int lineno);
- #define litest_assert_pad_button_event(li_, button_, state_) \
- _litest_assert_pad_button_event(li_, button_, state_, __func__, __LINE__)
- void
- _litest_assert_pad_button_event(struct libinput *li,
- unsigned int button,
- enum libinput_button_state state,
- const char *func,
- int lineno);
- #define litest_assert_pad_key_event(li_, key_, state_) \
- _litest_assert_pad_key_event(li_, key_, state_, __func__, __LINE__)
- void
- _litest_assert_pad_key_event(struct libinput *li,
- unsigned int key,
- enum libinput_key_state state,
- const char *func,
- int lineno);
- #define litest_assert_gesture_event(...) \
- _litest_assert_gesture_event(__VA_ARGS__, __func__, __LINE__)
- void
- _litest_assert_gesture_event(struct libinput *li,
- enum libinput_event_type type,
- int nfingers,
- const char *func,
- int line);
- struct libevdev_uinput *
- litest_create_uinput_device(const char *name, struct input_id *id, ...);
- struct libevdev_uinput *
- litest_create_uinput_abs_device(const char *name,
- struct input_id *id,
- const struct input_absinfo *abs,
- ...);
- void
- _litest_timeout(struct libinput *li, const char *func, int lineno, int millis);
- #define litest_timeout(li_, millis) \
- _litest_timeout(li_, __func__, __LINE__, millis)
- #define litest_timeout_tap(li_) litest_timeout(li_, 300)
- #define litest_timeout_tapndrag(li_) litest_timeout(li_, 520)
- #define litest_timeout_debounce(li_) litest_timeout(li_, 30)
- #define litest_timeout_softbuttons(li_) litest_timeout(li_, 300)
- #define litest_timeout_buttonscroll(li_) litest_timeout(li_, 300)
- #define litest_timeout_scroll_button_lock_grace(li_) litest_timeout(li_, 600)
- #define litest_timeout_wheel_scroll(li_) litest_timeout(li_, 600)
- #define litest_timeout_edgescroll(li_) litest_timeout(li_, 300)
- #define litest_timeout_finger_switch(li_) litest_timeout(li_, 140)
- #define litest_timeout_middlebutton(li_) litest_timeout(li_, 70)
- #define litest_timeout_dwt_short(li_) litest_timeout(li_, 220)
- #define litest_timeout_dwt_long(li_) litest_timeout(li_, 520)
- #define litest_timeout_gesture(li_) litest_timeout(li_, 120)
- #define litest_timeout_gesture_scroll(li_) litest_timeout(li_, 180)
- #define litest_timeout_gesture_hold(li_) litest_timeout(li_, 300)
- #define litest_timeout_gesture_quick_hold(li_) litest_timeout(li_, 60)
- #define litest_timeout_trackpoint(li_) litest_timeout(li_, 320)
- #define litest_timeout_tablet_proxout(li_) litest_timeout(li_, 170)
- #define litest_timeout_touch_arbitration(li_) litest_timeout(li_, 100)
- #define litest_timeout_hysteresis(li_) litest_timeout(li_, 90)
- #define litest_timeout_3fg_drag_or_swipe(li_) litest_timeout(li_, 90)
- #define litest_timeout_3fg_drag(li_) litest_timeout(li_, 800)
- #define litest_timeout_eraser_button(li_) litest_timeout(li_, 50)
- struct litest_logcapture {
- char **errors;
- char **infos;
- char **debugs;
- char **bugs;
- };
- void
- litest_logcapture_destroy(struct litest_logcapture *c);
- DEFINE_DESTROY_CLEANUP_FUNC(litest_logcapture);
- struct litest_logcapture *
- litest_logcapture_setup(struct libinput *li);
- struct litest_logcapture *
- litest_logcapture_remove(struct libinput *li, struct litest_logcapture *capture);
- #define litest_with_logcapture(li_, capture_) \
- for (struct litest_logcapture *capture_ = litest_logcapture_setup(li_); \
- capture_ != NULL; \
- capture_ = litest_logcapture_remove(li_, capture_))
- void
- _litest_assert_logcapture_no_errors(struct litest_logcapture *c,
- const char *file,
- const char *func,
- int lineno);
- #define litest_assert_logcapture_no_errors(c_) \
- _litest_assert_logcapture_no_errors(c_, __FILE__, __func__, __LINE__)
- #define litest_with_event_frame(dev_) \
- for (bool _i = ({litest_push_event_frame(dev_); true; }); \
- _i; \
- ({ litest_pop_event_frame(dev_); _i = false; }))
- void
- litest_push_event_frame(struct litest_device *dev);
- void
- litest_pop_event_frame(struct litest_device *dev);
- void
- litest_filter_event(struct litest_device *dev, unsigned int type, unsigned int code);
- void
- litest_unfilter_event(struct litest_device *dev, unsigned int type, unsigned int code);
- void
- litest_semi_mt_touch_down(struct litest_device *d,
- struct litest_semi_mt *semi_mt,
- unsigned int slot,
- double x,
- double y);
- void
- litest_semi_mt_touch_move(struct litest_device *d,
- struct litest_semi_mt *semi_mt,
- unsigned int slot,
- double x,
- double y);
- void
- litest_semi_mt_touch_up(struct litest_device *d,
- struct litest_semi_mt *semi_mt,
- unsigned int slot);
- static inline void
- litest_enable_3fg_drag(struct libinput_device *device, unsigned int nfingers)
- {
- enum libinput_config_3fg_drag_state enabled;
- switch (nfingers) {
- case 3:
- enabled = LIBINPUT_CONFIG_3FG_DRAG_ENABLED_3FG;
- break;
- case 4:
- enabled = LIBINPUT_CONFIG_3FG_DRAG_ENABLED_4FG;
- break;
- default:
- litest_abort_msg("Invalid finger count");
- break;
- }
- enum libinput_config_status status =
- libinput_device_config_3fg_drag_set_enabled(device, enabled);
- litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
- }
- static inline void
- litest_enable_tap(struct libinput_device *device)
- {
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_tap_set_enabled(device,
- LIBINPUT_CONFIG_TAP_ENABLED);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_disable_tap(struct libinput_device *device)
- {
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_tap_set_enabled(device,
- LIBINPUT_CONFIG_TAP_DISABLED);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_set_tap_map(struct libinput_device *device,
- enum libinput_config_tap_button_map map)
- {
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_tap_set_button_map(device, map);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_enable_tap_drag(struct libinput_device *device)
- {
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_tap_set_drag_enabled(
- device,
- LIBINPUT_CONFIG_DRAG_ENABLED);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_disable_tap_drag(struct libinput_device *device)
- {
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_tap_set_drag_enabled(
- device,
- LIBINPUT_CONFIG_DRAG_DISABLED);
- litest_assert_int_eq(status, expected);
- }
- static inline bool
- litest_has_2fg_scroll(struct litest_device *dev)
- {
- struct libinput_device *device = dev->libinput_device;
- return !!(libinput_device_config_scroll_get_methods(device) &
- LIBINPUT_CONFIG_SCROLL_2FG);
- }
- static inline void
- litest_enable_2fg_scroll(struct litest_device *dev)
- {
- enum libinput_config_status status, expected;
- struct libinput_device *device = dev->libinput_device;
- status = libinput_device_config_scroll_set_method(device,
- LIBINPUT_CONFIG_SCROLL_2FG);
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- litest_assert_int_eq(status, expected);
- libinput_device_config_scroll_set_natural_scroll_enabled(device, 0);
- }
- static inline void
- litest_enable_edge_scroll(struct litest_device *dev)
- {
- enum libinput_config_status status, expected;
- struct libinput_device *device = dev->libinput_device;
- status = libinput_device_config_scroll_set_method(device,
- LIBINPUT_CONFIG_SCROLL_EDGE);
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- litest_assert_int_eq(status, expected);
- libinput_device_config_scroll_set_natural_scroll_enabled(device, 0);
- }
- static inline bool
- litest_has_clickfinger(struct litest_device *dev)
- {
- struct libinput_device *device = dev->libinput_device;
- uint32_t methods = libinput_device_config_click_get_methods(device);
- return methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
- }
- static inline bool
- litest_has_btnareas(struct litest_device *dev)
- {
- struct libinput_device *device = dev->libinput_device;
- uint32_t methods = libinput_device_config_click_get_methods(device);
- return methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
- }
- static inline void
- litest_enable_clickfinger(struct litest_device *dev)
- {
- enum libinput_config_status status, expected;
- struct libinput_device *device = dev->libinput_device;
- status = libinput_device_config_click_set_method(
- device,
- LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_set_clickfinger_map(struct litest_device *dev,
- enum libinput_config_clickfinger_button_map map)
- {
- enum libinput_config_status status, expected;
- struct libinput_device *device = dev->libinput_device;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_click_set_clickfinger_button_map(device, map);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_enable_buttonareas(struct litest_device *dev)
- {
- enum libinput_config_status status, expected;
- struct libinput_device *device = dev->libinput_device;
- status = libinput_device_config_click_set_method(
- device,
- LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_enable_drag_lock_sticky(struct libinput_device *device)
- {
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_tap_set_drag_lock_enabled(
- device,
- LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_STICKY);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_enable_drag_lock(struct libinput_device *device)
- {
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_tap_set_drag_lock_enabled(
- device,
- LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_TIMEOUT);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_disable_drag_lock(struct libinput_device *device)
- {
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_tap_set_drag_lock_enabled(
- device,
- LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_enable_middleemu(struct litest_device *dev)
- {
- struct libinput_device *device = dev->libinput_device;
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_middle_emulation_set_enabled(
- device,
- LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_disable_middleemu(struct litest_device *dev)
- {
- struct libinput_device *device = dev->libinput_device;
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_middle_emulation_set_enabled(
- device,
- LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_sendevents_off(struct litest_device *dev)
- {
- struct libinput_device *device = dev->libinput_device;
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_send_events_set_mode(
- device,
- LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_sendevents_on(struct litest_device *dev)
- {
- struct libinput_device *device = dev->libinput_device;
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_send_events_set_mode(
- device,
- LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_sendevents_ext_mouse(struct litest_device *dev)
- {
- struct libinput_device *device = dev->libinput_device;
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_send_events_set_mode(
- device,
- LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_enable_hold_gestures(struct libinput_device *device)
- {
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_gesture_set_hold_enabled(
- device,
- LIBINPUT_CONFIG_HOLD_ENABLED);
- litest_assert_int_eq(status, expected);
- }
- static inline void
- litest_disable_hold_gestures(struct libinput_device *device)
- {
- enum libinput_config_status status, expected;
- expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
- status = libinput_device_config_gesture_set_hold_enabled(
- device,
- LIBINPUT_CONFIG_HOLD_DISABLED);
- litest_assert_int_eq(status, expected);
- }
- static inline bool
- litest_touchpad_is_external(struct litest_device *dev)
- {
- struct udev_device *udev_device;
- const char *prop;
- bool is_external;
- if (libinput_device_get_id_vendor(dev->libinput_device) == VENDOR_ID_WACOM)
- return true;
- udev_device = libinput_device_get_udev_device(dev->libinput_device);
- prop = udev_device_get_property_value(udev_device, "ID_INTEGRATION");
- is_external = prop && streq(prop, "external");
- udev_device_unref(udev_device);
- return is_external;
- }
- static inline int
- litest_send_file(int sock, int fd)
- {
- char buf[40960];
- int n = read(fd, buf, 40960);
- litest_assert_int_gt(n, 0);
- return write(sock, buf, n);
- }
- static inline int
- litest_slot_count(struct litest_device *dev)
- {
- if (dev->which == LITEST_ALPS_3FG)
- return 2;
- return libevdev_get_num_slots(dev->evdev);
- }
- static inline bool
- litest_has_palm_detect_size(struct litest_device *dev)
- {
- double width, height;
- unsigned int vendor;
- unsigned int bustype;
- int rc;
- vendor = libinput_device_get_id_vendor(dev->libinput_device);
- bustype = libevdev_get_id_bustype(dev->evdev);
- if (vendor == VENDOR_ID_WACOM)
- return 0;
- if (bustype == BUS_BLUETOOTH)
- return 0;
- if (vendor == VENDOR_ID_APPLE)
- return 0;
- rc = libinput_device_get_size(dev->libinput_device, &width, &height);
- return rc == 0 && width >= 70;
- }
- #endif /* LITEST_H */
|