litest.h 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818
  1. /*
  2. * Copyright © 2013 Red Hat, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. */
  23. #include "config.h"
  24. #include "litest-config.h"
  25. #ifndef LITEST_H
  26. #define LITEST_H
  27. #include <libevdev/libevdev-uinput.h>
  28. #include <libevdev/libevdev.h>
  29. #include <libinput.h>
  30. #include <math.h>
  31. #include <stdarg.h>
  32. #include <stdbool.h>
  33. #include "libinput-private-config.h"
  34. #include "libinput-util.h"
  35. #include "litest-runner.h"
  36. #include "quirks.h"
  37. DEFINE_DESTROY_CLEANUP_FUNC(libevdev_uinput);
  38. #define START_TEST(func_) \
  39. static enum litest_runner_result func_(const struct litest_runner_test_env *test_env) { \
  40. int _i _unused_ = test_env->rangeval;
  41. #define END_TEST \
  42. return LITEST_PASS; \
  43. }
  44. struct test_device {
  45. const char *name;
  46. struct litest_test_device *device;
  47. } __attribute__((aligned(16)));
  48. #define TEST_DEVICE(which, ...) \
  49. static struct litest_test_device _device; \
  50. \
  51. static void _setup(void) { \
  52. struct litest_device *d = litest_create_device(_device.type); \
  53. litest_set_current_device(d); \
  54. } \
  55. \
  56. static const struct test_device _test_device \
  57. __attribute__ ((used)) \
  58. __attribute__ ((section ("test_device_section"))) = { \
  59. #which, &_device \
  60. }; \
  61. static struct litest_test_device _device = { \
  62. .setup = _setup, \
  63. .shortname = #which, \
  64. .type = which, \
  65. __VA_ARGS__ \
  66. };
  67. struct test_collection {
  68. const char *name;
  69. void (*setup)(void);
  70. } __attribute__((aligned(16)));
  71. #define TEST_COLLECTION(name_) \
  72. static void (CONCAT(name_ , __LINE__))(void); \
  73. static const struct test_collection CONCAT(_test_collection_, __LINE__) \
  74. __attribute__ ((used)) \
  75. __attribute__ ((section ("test_collection_section"))) = { \
  76. #name_, CONCAT(name_, __LINE__) \
  77. }; \
  78. static void (CONCAT(name_, __LINE__))(void)
  79. #define litest_mark_test_start() \
  80. litest_checkpoint("==================== BOILERPLATE END. TEST CONTENT STARTING NOW ====================");
  81. __attribute__((format(printf, 3, 0))) void
  82. _litest_checkpoint(const char *func,
  83. int line,
  84. const char *color,
  85. const char *format,
  86. ...);
  87. #define litest_checkpoint(...) \
  88. _litest_checkpoint(__func__, __LINE__, ANSI_GREEN, __VA_ARGS__)
  89. #define litest_log_group(...) \
  90. for (bool i_ = ({ \
  91. litest_checkpoint("🭋🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂 %s:%3d 🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🬂🭀", __func__, __LINE__); \
  92. litest_checkpoint(" " __VA_ARGS__); true; }); \
  93. i_; \
  94. i_ = ({litest_checkpoint("🭦🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭 %s:%3d 🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🬭🭛", __func__, __LINE__); \
  95. false; }))
  96. /**
  97. * litest itself needs the user_data to store some test-suite-specific
  98. * information. Tests must not override this pointer, any data they need
  99. * they can hang off the private pointer in this struct.
  100. */
  101. struct litest_user_data {
  102. void *private;
  103. };
  104. void
  105. litest_fail_condition(const char *file,
  106. int line,
  107. const char *func,
  108. const char *condition,
  109. const char *message,
  110. ...);
  111. void
  112. litest_fail_comparison_int(const char *file,
  113. int line,
  114. const char *func,
  115. const char *operator,
  116. int a,
  117. int b,
  118. const char *astr,
  119. const char *bstr);
  120. void
  121. litest_fail_comparison_double(const char *file,
  122. int line,
  123. const char *func,
  124. const char *operator,
  125. double a,
  126. double b,
  127. const char *astr,
  128. const char *bstr);
  129. void
  130. litest_fail_comparison_ptr(const char *file,
  131. int line,
  132. const char *func,
  133. const char *comparison);
  134. void
  135. litest_fail_comparison_str(const char *file,
  136. int line,
  137. const char *func,
  138. const char *comparison,
  139. const char *operator,
  140. const char * astr,
  141. const char *bstr);
  142. #define litest_assert(cond) \
  143. do { \
  144. if (!(cond)) \
  145. litest_fail_condition(__FILE__, __LINE__, __func__, \
  146. #cond, NULL); \
  147. } while(0)
  148. #define litest_assert_msg(cond, ...) \
  149. do { \
  150. if (!(cond)) \
  151. litest_fail_condition(__FILE__, __LINE__, __func__, \
  152. #cond, __VA_ARGS__); \
  153. } while(0)
  154. #define litest_assert_not_reached() \
  155. litest_abort_msg("Triggered unreachable code\n")
  156. #define _litest_abort_msg(file_, line_, func_, ...) do {\
  157. litest_fail_condition(file_, line_, func_, \
  158. "aborting", __VA_ARGS__); \
  159. abort(); \
  160. } while (0)
  161. #define litest_abort_msg(...) \
  162. _litest_abort_msg(__FILE__, __LINE__, __func__, __VA_ARGS__)
  163. #define litest_assert_notnull(cond) \
  164. do { \
  165. if ((cond) == NULL) \
  166. litest_fail_condition(__FILE__, __LINE__, __func__, \
  167. #cond " != NULL", "\n"); \
  168. } while(0)
  169. #define litest_assert_comparison_int_(a_, op_, b_) \
  170. do { \
  171. __typeof__(a_) _a = a_; \
  172. __typeof__(b_) _b = b_; \
  173. if (trunc(_a) != _a || trunc(_b) != _b) \
  174. litest_abort_msg("litest_assert_int_* used for non-integer value\n"); \
  175. if (!((_a) op_ (_b))) \
  176. litest_fail_comparison_int(__FILE__, __LINE__, __func__,\
  177. #op_, _a, _b, \
  178. #a_, #b_); \
  179. } while(0)
  180. #define litest_assert_neg_errno_success(a_) \
  181. do { \
  182. __typeof__(a_) _a = a_; \
  183. if (_a < 0) \
  184. litest_abort_msg("Unexpected negative errno: %d (%s)", _a, strerror(-_a)); \
  185. } while(0);
  186. #define litest_assert_errno_success(a_) \
  187. do { \
  188. __typeof__(a_) _a = a_; \
  189. __typeof__(a_) _e = errno; \
  190. if (_a < 0) \
  191. litest_abort_msg("Unexpected errno: %d (%s)", _e, strerror(_e)); \
  192. } while(0);
  193. #define litest_assert_comparison_enum_(a_, op_, b_) \
  194. do { \
  195. __typeof__(a_) _a = a_; \
  196. __typeof__(a_) _b = b_; \
  197. if (!((_a) op_ (_b))) \
  198. litest_fail_comparison_int(__FILE__, __LINE__, __func__,\
  199. #op_, (int)_a, (int)_b, \
  200. #a_, #b_); \
  201. } while(0)
  202. #define litest_assert_enum_eq(a_, b_) \
  203. litest_assert_comparison_enum_(a_, ==, b_)
  204. #define litest_assert_enum_ne(a_, b_) \
  205. litest_assert_comparison_enum_(a_, !=, b_)
  206. #define litest_assert_int_eq(a_, b_) \
  207. litest_assert_comparison_int_(a_, ==, b_)
  208. #define litest_assert_int_ne(a_, b_) \
  209. litest_assert_comparison_int_(a_, !=, b_)
  210. #define litest_assert_int_lt(a_, b_) \
  211. litest_assert_comparison_int_(a_, <, b_)
  212. #define litest_assert_int_le(a_, b_) \
  213. litest_assert_comparison_int_(a_, <=, b_)
  214. #define litest_assert_int_ge(a_, b_) \
  215. litest_assert_comparison_int_(a_, >=, b_)
  216. #define litest_assert_int_gt(a_, b_) \
  217. litest_assert_comparison_int_(a_, >, b_)
  218. #define litest_assert_comparison_ptr_(a_, op_, b_) \
  219. do { \
  220. __typeof__(a_) _a = a_; \
  221. __typeof__(b_) _b = b_; \
  222. if (!((_a) op_ (_b))) \
  223. litest_fail_comparison_ptr(__FILE__, __LINE__, __func__,\
  224. #a_ " " #op_ " " #b_); \
  225. } while(0)
  226. #define litest_assert_ptr_eq(a_, b_) \
  227. litest_assert_comparison_ptr_(a_, ==, b_)
  228. #define litest_assert_ptr_ne(a_, b_) \
  229. litest_assert_comparison_ptr_(a_, !=, b_)
  230. #define litest_assert_ptr_null(a_) \
  231. litest_assert_comparison_ptr_(a_, ==, NULL)
  232. #define litest_assert_ptr_notnull(a_) \
  233. litest_assert_comparison_ptr_(a_, !=, NULL)
  234. #define litest_assert_str_eq(a_, b_) \
  235. do { \
  236. const char *_a = a_; \
  237. const char *_b = b_; \
  238. if (!streq(_a, _b)) \
  239. litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
  240. #a_ " == " #b_, \
  241. "==", \
  242. _a, _b); \
  243. } while(0)
  244. #define litest_assert_str_ne(a_, b_) \
  245. do { \
  246. const char *_a = a_; \
  247. const char *_b = b_; \
  248. if (streq(_a, _b)) \
  249. litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
  250. #a_ " != " #b_, \
  251. "!=", \
  252. _a, _b); \
  253. } while(0)
  254. #define litest_assert_str_in(needle_, haystack_) \
  255. do { \
  256. const char *_needle = needle_; \
  257. const char *_haystack = haystack_; \
  258. if (!strstr(_haystack, _needle)) \
  259. litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
  260. "'" #needle_ "' in: '" #haystack_ "'", \
  261. "in", \
  262. _needle, _haystack); \
  263. } while(0)
  264. #define litest_assert_str_not_in(needle_, haystack_) \
  265. do { \
  266. const char *_needle = needle_; \
  267. const char *_haystack = haystack_; \
  268. if (strstr(_haystack, _needle)) \
  269. litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
  270. "'" #needle_ "' not in: '" #haystack_ "'", \
  271. "not in", \
  272. _needle, _haystack); \
  273. } while(0)
  274. #define LITEST_DEFAULT_EPSILON 0.001
  275. #define litest_assert_double_eq_epsilon(a_, b_, epsilon_)\
  276. do { \
  277. __typeof__(a_) _a = a_; \
  278. __typeof__(b_) _b = b_; \
  279. if (!(fabs((_a) - (_b)) < epsilon_)) \
  280. litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
  281. "==", _a, _b, \
  282. #a_, #b_); \
  283. } while(0)
  284. #define litest_assert_double_ne_epsilon(a_, b_, epsilon_)\
  285. do { \
  286. __typeof__(a_) _a = a_; \
  287. __typeof__(b_) _b = b_; \
  288. if (!(fabs((_a) - (_b)) > epsilon_)) \
  289. litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
  290. "!=", _a, _b, \
  291. #a_, #b_); \
  292. } while(0)
  293. #define litest_assert_double_gt_epsilon(a_, b_, epsilon_)\
  294. do { \
  295. __typeof__(a_) _a = a_; \
  296. __typeof__(b_) _b = b_; \
  297. if (!(_a - (epsilon_) > _b)) \
  298. litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
  299. ">", _a, _b, \
  300. #a_, #b_); \
  301. } while(0)
  302. #define litest_assert_double_ge_epsilon(a_, b_, epsilon_)\
  303. do { \
  304. __typeof__(a_) _a = a_; \
  305. __typeof__(b_) _b = b_; \
  306. if (!(_a > _b || fabs((_a) - (_b)) < epsilon_)) \
  307. litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
  308. ">=", _a, _b, \
  309. #a_, #b_); \
  310. } while(0)
  311. #define litest_assert_double_lt_epsilon(a_, b_, epsilon_)\
  312. do { \
  313. __typeof__(a_) _a = a_; \
  314. __typeof__(b_) _b = b_; \
  315. if (!(_a < _b - (epsilon_))) \
  316. litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
  317. "<", _a, _b, \
  318. #a_, #b_); \
  319. } while(0)
  320. #define litest_assert_double_le_epsilon(a_, b_, epsilon_)\
  321. do { \
  322. __typeof__(a_) _a = a_; \
  323. __typeof__(b_) _b = b_; \
  324. if (!(_a < _b || fabs((_a) - (_b)) < epsilon_)) \
  325. litest_fail_comparison_double(__FILE__, __LINE__, __func__,\
  326. "<=", _a, _b, \
  327. #a_, #b_); \
  328. } while(0)
  329. #define litest_assert_comparison_double_(a_, op_, b_) \
  330. litest_assert_comparison_double_epsilon_(a_, op_, b_, LITEST_DEFAULT_EPSILON)
  331. #define litest_assert_double_eq(a_, b_)\
  332. litest_assert_double_eq_epsilon((a_), (b_), LITEST_DEFAULT_EPSILON)
  333. #define litest_assert_double_ne(a_, b_)\
  334. litest_assert_double_ne_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
  335. #define litest_assert_double_lt(a_, b_)\
  336. litest_assert_double_lt_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
  337. #define litest_assert_double_le(a_, b_)\
  338. litest_assert_double_le_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
  339. #define litest_assert_double_gt(a_, b_)\
  340. litest_assert_double_gt_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
  341. #define litest_assert_double_ge(a_, b_)\
  342. litest_assert_double_ge_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
  343. void
  344. _litest_assert_strv_substring(char **strv,
  345. char *substring,
  346. const char *file,
  347. const char *func,
  348. int line);
  349. #define litest_assert_strv_substring(strv_, substring_) \
  350. _litest_assert_strv_substring(strv_, substring_, __FILE__, __func__, __LINE__)
  351. void
  352. _litest_assert_strv_no_substring(char **strv,
  353. char *substring,
  354. const char *file,
  355. const char *func,
  356. int line);
  357. #define litest_assert_strv_no_substring(strv_, substring_) \
  358. _litest_assert_strv_no_substring(strv_, substring_, __FILE__, __func__, __LINE__)
  359. void
  360. litest_backtrace(const char *func);
  361. enum litest_device_type {
  362. LITEST_NO_DEVICE = -1,
  363. /* Touchpads and associated devices */
  364. LITEST_ACER_HAWAII_TOUCHPAD = -1000,
  365. LITEST_GENERIC_USBCOMBO_TOUCHPAD,
  366. LITEST_AIPTEK,
  367. LITEST_ALPS_3FG,
  368. LITEST_ALPS_DUALPOINT,
  369. LITEST_ALPS_SEMI_MT,
  370. LITEST_APPLETOUCH,
  371. LITEST_ATMEL_HOVER,
  372. LITEST_BCM5974,
  373. LITEST_ELANTECH_TOUCHPAD,
  374. LITEST_GENERIC_PRESSUREPAD,
  375. LITEST_MAGIC_TRACKPAD,
  376. LITEST_SYNAPTICS_CLICKPAD_X220,
  377. LITEST_SYNAPTICS_HOVER_SEMI_MT,
  378. LITEST_SYNAPTICS_I2C,
  379. LITEST_SYNAPTICS_PHANTOMCLICKS,
  380. LITEST_SYNAPTICS_PRESSUREPAD,
  381. LITEST_SYNAPTICS_RMI4,
  382. LITEST_SYNAPTICS_TOPBUTTONPAD,
  383. LITEST_SYNAPTICS_TOUCHPAD,
  384. LITEST_TOUCHPAD_PALMPRESSURE_ZERO,
  385. LITEST_WACOM_INTUOS5_FINGER,
  386. /* Touchscreens */
  387. LITEST_CALIBRATED_TOUCHSCREEN,
  388. LITEST_GENERIC_MULTITOUCH_SCREEN,
  389. LITEST_GENERIC_SINGLETOUCH,
  390. LITEST_MS_SURFACE_COVER,
  391. LITEST_MULTITOUCH_FUZZ_SCREEN,
  392. LITEST_NEXUS4_TOUCH_SCREEN,
  393. LITEST_PROTOCOL_A_SCREEN,
  394. LITEST_TOUCHSCREEN_INVALID_RANGE,
  395. LITEST_TOUCHSCREEN_MT_TOOL_TYPE,
  396. LITEST_WACOM_ISDV4_E6_FINGER,
  397. /* Pointing devices and keyboards */
  398. LITEST_MOUSE,
  399. LITEST_MOUSE_PS2,
  400. LITEST_KEYBOARD,
  401. LITEST_TRACKPOINT,
  402. LITEST_ABSINFO_OVERRIDE,
  403. LITEST_ACER_HAWAII_KEYBOARD,
  404. LITEST_GENERIC_USBCOMBO_KEYBOARD,
  405. LITEST_ANKER_MOUSE_KBD,
  406. LITEST_APPLE_KEYBOARD,
  407. LITEST_CYBORG_RAT,
  408. LITEST_HP_WMI_HOTKEYS,
  409. LITEST_IGNORED_MOUSE,
  410. LITEST_KEYBOARD_ALL_CODES,
  411. LITEST_KEYBOARD_BLACKWIDOW,
  412. LITEST_KEYBOARD_BLADE_STEALTH,
  413. LITEST_KEYBOARD_BLADE_STEALTH_VIDEOSWITCH,
  414. LITEST_KEYBOARD_LOGITECH_MEDIA_KEYBOARD_ELITE,
  415. LITEST_KEYBOARD_QUIRKED,
  416. LITEST_LENOVO_SCROLLPOINT,
  417. LITEST_LOGITECH_TRACKBALL,
  418. LITEST_MAGICMOUSE,
  419. LITEST_MOUSE_FORMAT_STRING,
  420. LITEST_MOUSE_GLADIUS,
  421. LITEST_MOUSE_LOW_DPI,
  422. LITEST_MOUSE_ROCCAT,
  423. LITEST_MOUSE_VIRTUAL,
  424. LITEST_MOUSE_WHEEL_CLICK_ANGLE,
  425. LITEST_MOUSE_WHEEL_CLICK_COUNT,
  426. LITEST_MOUSE_WHEEL_TILT,
  427. LITEST_MOUSE_WHEEL_HIRES_DISABLED,
  428. LITEST_MS_NANO_TRANSCEIVER_MOUSE,
  429. LITEST_SONY_VAIO_KEYS,
  430. LITEST_SYNAPTICS_TRACKPOINT_BUTTONS,
  431. LITEST_THINKPAD_EXTRABUTTONS,
  432. LITEST_VMWARE_VIRTMOUSE,
  433. LITEST_WHEEL_ONLY,
  434. LITEST_XEN_VIRTUAL_POINTER,
  435. /* Switches */
  436. LITEST_LID_SWITCH,
  437. LITEST_LID_SWITCH_SURFACE3,
  438. LITEST_KEYPAD_SLIDE_SWITCH,
  439. LITEST_TABLET_MODE_UNRELIABLE,
  440. /* Special devices */
  441. LITEST_DELL_CANVAS_TOTEM,
  442. LITEST_DELL_CANVAS_TOTEM_TOUCH,
  443. LITEST_GPIO_KEYS,
  444. LITEST_YUBIKEY,
  445. /* Tablets */
  446. LITEST_ELAN_TABLET,
  447. LITEST_HUION_TABLET,
  448. LITEST_HUION_Q620M_DIAL,
  449. LITEST_PLOOPY_PAVONIS_STYLUS,
  450. LITEST_QEMU_TABLET,
  451. LITEST_TABLET_DOUBLEDIAL_PAD,
  452. LITEST_TABLET_REL_DIAL_PAD,
  453. LITEST_UCLOGIC_TABLET,
  454. LITEST_WACOM_BAMBOO_16FG_PEN,
  455. LITEST_WACOM_BAMBOO_2FG_FINGER,
  456. LITEST_WACOM_BAMBOO_2FG_PAD,
  457. LITEST_WACOM_BAMBOO_2FG_PEN,
  458. LITEST_WACOM_CALIBRATED_TABLET_PEN,
  459. LITEST_WACOM_CINTIQ_12WX_PEN,
  460. LITEST_WACOM_CINTIQ_13HDT_FINGER,
  461. LITEST_WACOM_CINTIQ_13HDT_PAD,
  462. LITEST_WACOM_CINTIQ_13HDT_PEN,
  463. LITEST_WACOM_CINTIQ_24HDT_PAD,
  464. LITEST_WACOM_CINTIQ_24HD_PEN,
  465. LITEST_WACOM_CINTIQ_PRO16_FINGER,
  466. LITEST_WACOM_CINTIQ_PRO16_PAD,
  467. LITEST_WACOM_CINTIQ_PRO16_PEN,
  468. LITEST_WACOM_EKR,
  469. LITEST_WACOM_HID4800_PEN,
  470. LITEST_WACOM_INTUOS3_PAD,
  471. LITEST_WACOM_INTUOS5_PAD,
  472. LITEST_WACOM_INTUOS5_PEN,
  473. LITEST_WACOM_ISDV4_4200_PEN,
  474. LITEST_WACOM_ISDV4_524C_PEN,
  475. LITEST_WACOM_ISDV4_E6_PEN,
  476. LITEST_WACOM_MOBILESTUDIO_PRO_16_PAD,
  477. LITEST_WALTOP,
  478. };
  479. #define LITEST_DEVICELESS -2
  480. #define LITEST_DISABLE_DEVICE -1
  481. #define LITEST_ANY 0
  482. #define LITEST_TOUCHPAD bit(0)
  483. #define LITEST_CLICKPAD bit(1)
  484. #define LITEST_BUTTON bit(2)
  485. #define LITEST_KEYS bit(3)
  486. #define LITEST_RELATIVE bit(4)
  487. #define LITEST_WHEEL bit(5)
  488. #define LITEST_TOUCH bit(6)
  489. #define LITEST_SINGLE_TOUCH bit(7)
  490. #define LITEST_APPLE_CLICKPAD bit(8)
  491. #define LITEST_TOPBUTTONPAD bit(9)
  492. #define LITEST_SEMI_MT bit(10)
  493. #define LITEST_POINTINGSTICK bit(11)
  494. #define LITEST_FAKE_MT bit(12)
  495. #define LITEST_ABSOLUTE bit(13)
  496. #define LITEST_PROTOCOL_A bit(14)
  497. #define LITEST_HOVER bit(15)
  498. #define LITEST_ELLIPSE bit(16)
  499. #define LITEST_TABLET bit(17)
  500. #define LITEST_DISTANCE bit(18)
  501. #define LITEST_TOOL_SERIAL bit(19)
  502. #define LITEST_TILT bit(20)
  503. #define LITEST_TABLET_PAD bit(21)
  504. #define LITEST_RING bit(22)
  505. #define LITEST_STRIP bit(23)
  506. #define LITEST_TRACKBALL bit(24)
  507. #define LITEST_LEDS bit(25)
  508. #define LITEST_SWITCH bit(26)
  509. #define LITEST_IGNORED bit(27)
  510. #define LITEST_NO_DEBOUNCE bit(28)
  511. #define LITEST_TOOL_MOUSE bit(29)
  512. #define LITEST_DIRECT bit(30)
  513. #define LITEST_TOTEM bit(31)
  514. #define LITEST_FORCED_PROXOUT bit(32)
  515. #define LITEST_PRECALIBRATED bit(33)
  516. #define LITEST_DIAL bit(34)
  517. /* this is a semi-mt device, so we keep track of the touches that the tests
  518. * send and modify them so that the first touch is always slot 0 and sends
  519. * the top-left of the bounding box, the second is always slot 1 and sends
  520. * the bottom-right of the bounding box.
  521. * Lifting any of two fingers terminates slot 1
  522. */
  523. struct litest_semi_mt {
  524. bool is_semi_mt;
  525. int tracking_id;
  526. /* The actual touches requested by the test for the two slots
  527. * in the 0..100 range used by litest */
  528. struct {
  529. double x, y;
  530. } touches[2];
  531. };
  532. struct litest_device {
  533. enum litest_device_type which;
  534. struct libevdev *evdev;
  535. struct libevdev_uinput *uinput;
  536. struct libinput *libinput;
  537. struct quirks *quirks;
  538. bool owns_context;
  539. struct libinput_device *libinput_device;
  540. struct litest_device_interface *interface;
  541. struct {
  542. struct input_event events[64];
  543. size_t nevents;
  544. } frame;
  545. int ntouches_down;
  546. int skip_ev_syn;
  547. struct litest_semi_mt semi_mt; /** only used for semi-mt device */
  548. void *private; /* device-specific data */
  549. };
  550. struct axis_replacement {
  551. int32_t evcode;
  552. double value;
  553. };
  554. /**
  555. * Same as litest_axis_set_value but allows for ranges outside 0..100%
  556. */
  557. static inline void
  558. litest_axis_set_value_unchecked(struct axis_replacement *axes, int code, double value)
  559. {
  560. while (axes->evcode != -1) { /* NOLINT(clang-analyzer-security.ArrayBound) */
  561. if (axes->evcode == code) {
  562. axes->value = value;
  563. return;
  564. }
  565. axes++;
  566. }
  567. litest_abort_msg("Missing axis code %d\n", code);
  568. }
  569. /**
  570. * Takes a value in percent and sets the given axis to that code.
  571. */
  572. static inline void
  573. litest_axis_set_value(struct axis_replacement *axes, int code, double value)
  574. {
  575. litest_assert_double_ge(value, 0.0);
  576. litest_assert_double_le(value, 100.0);
  577. litest_axis_set_value_unchecked(axes, code, value);
  578. }
  579. struct libinput *
  580. litest_create_context(void);
  581. /* Adds the given plugin dir to the context but does *not* initialize
  582. * the plugins */
  583. struct libinput *
  584. litest_create_context_with_plugindir(const char *plugindir);
  585. void
  586. litest_destroy_context(struct libinput *li);
  587. DEFINE_TRIVIAL_CLEANUP_FUNC(struct libinput *, litest_destroy_context);
  588. #define _litest_context_destroy_ _cleanup_(litest_destroy_contextp)
  589. void
  590. litest_context_set_user_data(struct libinput *li, void *data);
  591. void *
  592. litest_context_get_user_data(struct libinput *li);
  593. void
  594. litest_disable_log_handler(struct libinput *libinput);
  595. void
  596. litest_restore_log_handler(struct libinput *libinput);
  597. void
  598. litest_set_log_handler_bug(struct libinput *libinput);
  599. struct litest_parameters;
  600. /**
  601. * Create a new set of parameters for a test case.
  602. *
  603. * This function takes a variable set of arguments in the format
  604. * [name, type, count, arg1, arg2, arg3, ..], for example:
  605. *
  606. * litest_parameter_new("axis", 'u', 2, ABS_X, ABS_Y,
  607. * "direction", 's', 4, "north", "south", "east", "west",
  608. * NULL);
  609. *
  610. * Parsing stops at the first null name argument.
  611. */
  612. struct litest_parameters *
  613. _litest_parameters_new(const char *name, ...);
  614. /* Helper to ensure it's always null-terminated */
  615. #define litest_parameters_new(name_, ...) \
  616. _litest_parameters_new(name_, __VA_ARGS__, NULL)
  617. #define litest_with_parameters(params_, ...) \
  618. for (struct litest_parameters *params_ = litest_parameters_new(__VA_ARGS__); \
  619. params_; \
  620. params_ = litest_parameters_unref(params_))
  621. #define _LITEST_NAMED_I32(v_, n_, ...) (struct litest_named_i32){ .value = v_, .name = n_ }
  622. /* Helper to default second argument to stringification of first argument.
  623. * This allows for two uses of this macro:
  624. * - litest_named_i32(0) expands to { 0, "0" }
  625. * - litest_named_i32(0, "zero") expands to (effectively) { 0, "zero" }
  626. */
  627. #define litest_named_i32(...) _LITEST_NAMED_I32(__VA_ARGS__, #__VA_ARGS__)
  628. struct litest_named_i32 {
  629. int32_t value;
  630. const char *name;
  631. };
  632. struct litest_parameters_permutation_value {
  633. struct list link;
  634. char name[128];
  635. const struct multivalue value;
  636. };
  637. /**
  638. * Argument for the callback function to litest_parameters_permutations().
  639. * This is simple wrapper around a linked list that contains all elements
  640. * of the current permutation.
  641. */
  642. struct litest_parameters_permutation {
  643. struct list values; /* struct litest_parameters_permutation_value */
  644. };
  645. /**
  646. * Callback function invoked for each permutation of a struct litest_parameters.
  647. */
  648. typedef int (*litest_parameters_permutation_func_t)(
  649. struct litest_parameters_permutation *permutation,
  650. void *userdata);
  651. /**
  652. * Permutates the given parameters and calls func for every possible
  653. * permutation. If func returns a nonzero status, permutation stops
  654. * and that nonzero status is returned to the caller.
  655. *
  656. * Userdata is passed through as-is.
  657. */
  658. int
  659. litest_parameters_permutations(struct litest_parameters *params,
  660. litest_parameters_permutation_func_t func,
  661. void *userdata);
  662. struct litest_parameters *
  663. litest_parameters_ref(struct litest_parameters *p);
  664. struct litest_parameters *
  665. litest_parameters_unref(struct litest_parameters *params);
  666. #define litest_add(func_, ...) \
  667. _litest_add(__FILE__, #func_, func_, __VA_ARGS__)
  668. #define litest_add_ranged(func_, ...) \
  669. _litest_add_ranged(__FILE__, #func_, func_, __VA_ARGS__)
  670. #define litest_add_parametrized(func_, ...) \
  671. _litest_add_parametrized(__FILE__, #func_, func_, __VA_ARGS__)
  672. #define litest_add_for_device(func_, ...) \
  673. _litest_add_for_device(__FILE__, #func_, func_, __VA_ARGS__)
  674. #define litest_add_ranged_for_device(func_, ...) \
  675. _litest_add_ranged_for_device(__FILE__, #func_, func_, __VA_ARGS__)
  676. #define litest_add_parametrized_for_device(func_, ...) \
  677. _litest_add_parametrized_for_device(__FILE__, #func_, func_, __VA_ARGS__)
  678. #define litest_add_no_device(func_) \
  679. _litest_add_no_device(__FILE__, #func_, func_)
  680. #define litest_add_parametrized_no_device(func_, ...) \
  681. _litest_add_parametrized_no_device(__FILE__, #func_, func_, __VA_ARGS__)
  682. #define litest_add_ranged_no_device(func_, ...) \
  683. _litest_add_ranged_no_device(__FILE__, #func_, func_, __VA_ARGS__)
  684. #define litest_add_deviceless(func_) \
  685. _litest_add_deviceless(__FILE__, #func_, func_)
  686. #define litest_add_parametrized_deviceless(func_, params) \
  687. _litest_add_parametrize_deviceless(__FILE__, #func_, func_, params)
  688. void
  689. _litest_add(const char *name,
  690. const char *funcname,
  691. const void *func,
  692. int64_t required_feature,
  693. int64_t excluded_feature);
  694. void
  695. _litest_add_ranged(const char *name,
  696. const char *funcname,
  697. const void *func,
  698. int64_t required,
  699. int64_t excluded,
  700. const struct range *range);
  701. void
  702. _litest_add_parametrized(const char *name,
  703. const char *funcname,
  704. const void *func,
  705. int64_t required,
  706. int64_t excluded,
  707. struct litest_parameters *params);
  708. void
  709. _litest_add_for_device(const char *name,
  710. const char *funcname,
  711. const void *func,
  712. enum litest_device_type type);
  713. void
  714. _litest_add_ranged_for_device(const char *name,
  715. const char *funcname,
  716. const void *func,
  717. enum litest_device_type type,
  718. const struct range *range);
  719. void
  720. _litest_add_parametrized_for_device(const char *name,
  721. const char *funcname,
  722. const void *func,
  723. enum litest_device_type type,
  724. struct litest_parameters *params);
  725. void
  726. _litest_add_no_device(const char *name, const char *funcname, const void *func);
  727. void
  728. _litest_add_parametrized_no_device(const char *name,
  729. const char *funcname,
  730. const void *func,
  731. struct litest_parameters *params);
  732. void
  733. _litest_add_ranged_no_device(const char *name,
  734. const char *funcname,
  735. const void *func,
  736. const struct range *range);
  737. void
  738. _litest_add_deviceless(const char *name, const char *funcname, const void *func);
  739. void
  740. _litest_add_parametrized_deviceless(const char *name,
  741. const char *funcname,
  742. const void *func,
  743. struct litest_parameters *params);
  744. struct litest_device *
  745. litest_create_device(enum litest_device_type which);
  746. struct litest_device *
  747. litest_add_device(struct libinput *libinput, enum litest_device_type which);
  748. struct libevdev_uinput *
  749. litest_create_uinput_device_from_description(const char *name,
  750. const struct input_id *id,
  751. const struct input_absinfo *abs,
  752. const int *events);
  753. struct litest_device *
  754. litest_create(enum litest_device_type which,
  755. const char *name_override,
  756. struct input_id *id_override,
  757. const struct input_absinfo *abs_override,
  758. const int *events_override);
  759. struct litest_device *
  760. litest_create_device_with_overrides(enum litest_device_type which,
  761. const char *name_override,
  762. struct input_id *id_override,
  763. const struct input_absinfo *abs_override,
  764. const int *events_override);
  765. struct litest_device *
  766. litest_add_device_with_overrides(struct libinput *libinput,
  767. enum litest_device_type which,
  768. const char *name_override,
  769. struct input_id *id_override,
  770. const struct input_absinfo *abs_override,
  771. const int *events_override);
  772. struct litest_device *
  773. litest_current_device(void);
  774. void
  775. litest_grab_device(struct litest_device *d);
  776. void
  777. litest_ungrab_device(struct litest_device *d);
  778. void
  779. litest_device_destroy(struct litest_device *d);
  780. DEFINE_DESTROY_CLEANUP_FUNC(litest_device);
  781. const char *
  782. litest_event_type_str(enum libinput_event_type type);
  783. int
  784. _litest_dispatch(struct libinput *li, const char *func, int line);
  785. #define litest_dispatch(li_) \
  786. _litest_dispatch(li_, __func__, __LINE__)
  787. void
  788. litest_event(struct litest_device *t, unsigned int type, unsigned int code, int value);
  789. void
  790. litest_event_unchecked(struct litest_device *d,
  791. unsigned int type,
  792. unsigned int code,
  793. int value);
  794. int
  795. litest_auto_assign_value(struct litest_device *d,
  796. const struct input_event *ev,
  797. int slot,
  798. double x,
  799. double y,
  800. struct axis_replacement *axes,
  801. bool touching);
  802. void
  803. litest_touch_up(struct litest_device *d, unsigned int slot);
  804. void
  805. litest_touch_move(struct litest_device *d, unsigned int slot, double x, double y);
  806. void
  807. litest_touch_move_extended(struct litest_device *d,
  808. unsigned int slot,
  809. double x,
  810. double y,
  811. struct axis_replacement *axes);
  812. void
  813. litest_touch_sequence(struct litest_device *d,
  814. unsigned int slot,
  815. double x1,
  816. double y1,
  817. double x2,
  818. double y2,
  819. int steps);
  820. void
  821. litest_touch_down(struct litest_device *d, unsigned int slot, double x, double y);
  822. void
  823. litest_touch_down_extended(struct litest_device *d,
  824. unsigned int slot,
  825. double x,
  826. double y,
  827. struct axis_replacement *axes);
  828. void
  829. litest_touch_move_to(struct litest_device *d,
  830. unsigned int slot,
  831. double x_from,
  832. double y_from,
  833. double x_to,
  834. double y_to,
  835. int steps);
  836. void
  837. litest_touch_move_to_extended(struct litest_device *d,
  838. unsigned int slot,
  839. double x_from,
  840. double y_from,
  841. double x_to,
  842. double y_to,
  843. struct axis_replacement *axes,
  844. int steps);
  845. void
  846. litest_touch_move_two_touches(struct litest_device *d,
  847. double x0,
  848. double y0,
  849. double x1,
  850. double y1,
  851. double dx,
  852. double dy,
  853. int steps);
  854. void
  855. litest_touch_move_three_touches(struct litest_device *d,
  856. double x0,
  857. double y0,
  858. double x1,
  859. double y1,
  860. double x2,
  861. double y2,
  862. double dx,
  863. double dy,
  864. int steps);
  865. void
  866. litest_tablet_set_tool_type(struct litest_device *d, unsigned int code);
  867. void
  868. litest_tablet_proximity_in(struct litest_device *d,
  869. double x,
  870. double y,
  871. struct axis_replacement *axes);
  872. void
  873. litest_tablet_proximity_out(struct litest_device *d);
  874. void
  875. litest_tablet_tip_down(struct litest_device *d,
  876. double x,
  877. double y,
  878. struct axis_replacement *axes);
  879. void
  880. litest_tablet_tip_up(struct litest_device *d,
  881. double x,
  882. double y,
  883. struct axis_replacement *axes);
  884. void
  885. litest_tablet_motion(struct litest_device *d,
  886. double x,
  887. double y,
  888. struct axis_replacement *axes);
  889. void
  890. litest_pad_ring_start(struct litest_device *d, double value);
  891. void
  892. litest_pad_ring_change(struct litest_device *d, double value);
  893. void
  894. litest_pad_ring_end(struct litest_device *d);
  895. void
  896. litest_pad_strip_start(struct litest_device *d, double value);
  897. void
  898. litest_pad_strip_change(struct litest_device *d, double value);
  899. void
  900. litest_pad_strip_end(struct litest_device *d);
  901. void
  902. litest_hover_start(struct litest_device *d, unsigned int slot, double x, double y);
  903. void
  904. litest_hover_end(struct litest_device *d, unsigned int slot);
  905. void
  906. litest_hover_move(struct litest_device *d, unsigned int slot, double x, double y);
  907. void
  908. litest_hover_move_to(struct litest_device *d,
  909. unsigned int slot,
  910. double x_from,
  911. double y_from,
  912. double x_to,
  913. double y_to,
  914. int steps);
  915. void
  916. litest_hover_move_two_touches(struct litest_device *d,
  917. double x0,
  918. double y0,
  919. double x1,
  920. double y1,
  921. double dx,
  922. double dy,
  923. int steps);
  924. void
  925. litest_button_click_debounced(struct litest_device *d,
  926. struct libinput *li,
  927. unsigned int button,
  928. bool is_press);
  929. void
  930. litest_button_click(struct litest_device *d, unsigned int button, bool is_press);
  931. void
  932. litest_button_scroll(struct litest_device *d,
  933. unsigned int button,
  934. double dx,
  935. double dy);
  936. void
  937. litest_button_scroll_locked(struct litest_device *d,
  938. unsigned int button,
  939. double dx,
  940. double dy);
  941. void
  942. litest_keyboard_key(struct litest_device *d, unsigned int key, bool is_press);
  943. void
  944. litest_switch_action(struct litest_device *d,
  945. enum libinput_switch sw,
  946. enum libinput_switch_state state);
  947. void
  948. litest_wait_for_event(struct libinput *li);
  949. void
  950. _litest_wait_for_event_of_type(struct libinput *li, const char *func, int lineno, ...);
  951. #define litest_wait_for_event_of_type(li_, ...) \
  952. _litest_wait_for_event_of_type(li_, __func__, __LINE__, __VA_ARGS__, -1)
  953. void
  954. litest_drain_events(struct libinput *li);
  955. void
  956. _litest_drain_events_of_type(struct libinput *li, ...);
  957. #define litest_drain_events_of_type(li_, ...) \
  958. _litest_drain_events_of_type(li_, __VA_ARGS__, -1)
  959. #define litest_assert_event_type(e_, want_) \
  960. _litest_assert_event_type(e_, want_, __func__, __LINE__)
  961. void
  962. _litest_assert_event_type(struct libinput_event *event,
  963. enum libinput_event_type want,
  964. const char *func,
  965. int lineno);
  966. #define litest_assert_event_type_is_one_of(ev_, ...) \
  967. _litest_assert_event_type_is_one_of(ev_, __func__, __LINE__, __VA_ARGS__, -1)
  968. void
  969. _litest_assert_event_type_is_one_of(struct libinput_event *event,
  970. const char *func,
  971. int lineno,
  972. ...);
  973. #define litest_assert_event_type_not_one_of(ev_, ...) \
  974. _litest_assert_event_type_not_one_of(ev_, __func__, __LINE__, __VA_ARGS__, -1)
  975. void
  976. _litest_assert_event_type_not_one_of(struct libinput_event *event,
  977. const char *func,
  978. int lineno,
  979. ...);
  980. #define litest_assert_empty_queue(li_) \
  981. _litest_assert_empty_queue(li_, __func__, __LINE__)
  982. void
  983. _litest_assert_empty_queue(struct libinput *li, const char *func, int line);
  984. void
  985. litest_assert_touch_sequence(struct libinput *li);
  986. void
  987. litest_assert_touch_motion_frame(struct libinput *li);
  988. void
  989. litest_assert_touch_down_frame(struct libinput *li);
  990. void
  991. litest_assert_touch_up_frame(struct libinput *li);
  992. void
  993. litest_assert_touch_cancel(struct libinput *li);
  994. struct libinput_event_pointer *
  995. litest_is_button_event(struct libinput_event *event,
  996. unsigned int button,
  997. enum libinput_button_state state);
  998. struct libinput_event_pointer *
  999. litest_is_axis_event(struct libinput_event *event,
  1000. enum libinput_event_type axis_type,
  1001. enum libinput_pointer_axis axis,
  1002. enum libinput_pointer_axis_source source);
  1003. bool
  1004. litest_is_high_res_axis_event(struct libinput_event *event);
  1005. struct libinput_event_pointer *
  1006. litest_is_motion_event(struct libinput_event *event);
  1007. struct libinput_event_touch *
  1008. litest_is_touch_event(struct libinput_event *event, enum libinput_event_type type);
  1009. struct libinput_event_keyboard *
  1010. litest_is_keyboard_event(struct libinput_event *event,
  1011. unsigned int key,
  1012. enum libinput_key_state state);
  1013. struct libinput_event_gesture *
  1014. litest_is_gesture_event(struct libinput_event *event,
  1015. enum libinput_event_type type,
  1016. int nfingers);
  1017. struct libinput_event_tablet_tool *
  1018. litest_is_tablet_event(struct libinput_event *event, enum libinput_event_type type);
  1019. struct libinput_event_tablet_pad *
  1020. litest_is_pad_button_event(struct libinput_event *event,
  1021. unsigned int button,
  1022. enum libinput_button_state state);
  1023. struct libinput_event_tablet_pad *
  1024. litest_is_pad_dial_event(struct libinput_event *event, unsigned int number);
  1025. struct libinput_event_tablet_pad *
  1026. litest_is_pad_ring_event(struct libinput_event *event,
  1027. unsigned int number,
  1028. enum libinput_tablet_pad_ring_axis_source source);
  1029. struct libinput_event_tablet_pad *
  1030. litest_is_pad_strip_event(struct libinput_event *event,
  1031. unsigned int number,
  1032. enum libinput_tablet_pad_strip_axis_source source);
  1033. struct libinput_event_tablet_pad *
  1034. litest_is_pad_key_event(struct libinput_event *event,
  1035. unsigned int key,
  1036. enum libinput_key_state state);
  1037. struct libinput_event_switch *
  1038. litest_is_switch_event(struct libinput_event *event,
  1039. enum libinput_switch sw,
  1040. enum libinput_switch_state state);
  1041. struct libinput_event_tablet_tool *
  1042. litest_is_proximity_event(struct libinput_event *event,
  1043. enum libinput_tablet_tool_proximity_state state);
  1044. double
  1045. litest_event_pointer_get_value(struct libinput_event_pointer *ptrev,
  1046. enum libinput_pointer_axis axis);
  1047. enum libinput_pointer_axis_source
  1048. litest_event_pointer_get_axis_source(struct libinput_event_pointer *event);
  1049. #define litest_assert_key_event(li_, key_, state_) \
  1050. _litest_assert_key_event(li_, key_, state_, __func__, __LINE__)
  1051. void
  1052. _litest_assert_key_event(struct libinput *li,
  1053. unsigned int key,
  1054. enum libinput_key_state state,
  1055. const char *func,
  1056. int lineno);
  1057. #define litest_assert_button_event(li_, button_, state_) \
  1058. _litest_assert_button_event(li_, button_, state_, __func__, __LINE__)
  1059. void
  1060. _litest_assert_button_event(struct libinput *li,
  1061. unsigned int button,
  1062. enum libinput_button_state state,
  1063. const char *func,
  1064. int line);
  1065. #define litest_assert_switch_event(li_, sw_, state_) \
  1066. _litest_assert_switch_event(li_, sw_, state_, __func__, __LINE__)
  1067. void
  1068. _litest_assert_switch_event(struct libinput *li,
  1069. enum libinput_switch sw,
  1070. enum libinput_switch_state state,
  1071. const char *func,
  1072. int lineno);
  1073. void
  1074. litest_assert_scroll(struct libinput *li,
  1075. enum libinput_event_type axis_type,
  1076. enum libinput_pointer_axis axis,
  1077. int minimum_movement);
  1078. void
  1079. litest_assert_axis_end_sequence(struct libinput *li,
  1080. enum libinput_event_type axis_type,
  1081. enum libinput_pointer_axis axis,
  1082. enum libinput_pointer_axis_source source);
  1083. #define litest_assert_only_typed_events(...) \
  1084. _litest_assert_only_typed_events(__VA_ARGS__, __func__, __LINE__)
  1085. void
  1086. _litest_assert_only_typed_events(struct libinput *li,
  1087. enum libinput_event_type type,
  1088. const char *func,
  1089. int line);
  1090. void
  1091. litest_assert_only_axis_events(struct libinput *li, enum libinput_event_type axis_type);
  1092. void
  1093. litest_assert_no_typed_events(struct libinput *li, enum libinput_event_type type);
  1094. #define litest_assert_tablet_button_event(li_, button_, state_) \
  1095. _litest_assert_tablet_button_event(li_, button_, state_, __func__, __LINE__)
  1096. void
  1097. _litest_assert_tablet_button_event(struct libinput *li,
  1098. unsigned int button,
  1099. enum libinput_button_state state,
  1100. const char *func,
  1101. int lineno);
  1102. #define litest_assert_tablet_axis_event(li_) \
  1103. _litest_assert_tablet_axis_event(li_, __func__, __LINE__)
  1104. void
  1105. _litest_assert_tablet_axis_event(struct libinput *li, const char *func, int lineno);
  1106. #define litest_assert_tablet_proximity_event(li_, state_) \
  1107. _litest_assert_tablet_proximity_event(li_, state_, __func__, __LINE__)
  1108. void
  1109. _litest_assert_tablet_proximity_event(struct libinput *li,
  1110. enum libinput_tablet_tool_proximity_state state,
  1111. const char *func,
  1112. int lineno);
  1113. #define litest_assert_tablet_tip_event(li_, state_) \
  1114. _litest_assert_tablet_tip_event(li_, state_, __func__, __LINE__)
  1115. void
  1116. _litest_assert_tablet_tip_event(struct libinput *li,
  1117. enum libinput_tablet_tool_tip_state state,
  1118. const char *func,
  1119. int lineno);
  1120. #define litest_assert_pad_button_event(li_, button_, state_) \
  1121. _litest_assert_pad_button_event(li_, button_, state_, __func__, __LINE__)
  1122. void
  1123. _litest_assert_pad_button_event(struct libinput *li,
  1124. unsigned int button,
  1125. enum libinput_button_state state,
  1126. const char *func,
  1127. int lineno);
  1128. #define litest_assert_pad_key_event(li_, key_, state_) \
  1129. _litest_assert_pad_key_event(li_, key_, state_, __func__, __LINE__)
  1130. void
  1131. _litest_assert_pad_key_event(struct libinput *li,
  1132. unsigned int key,
  1133. enum libinput_key_state state,
  1134. const char *func,
  1135. int lineno);
  1136. #define litest_assert_gesture_event(...) \
  1137. _litest_assert_gesture_event(__VA_ARGS__, __func__, __LINE__)
  1138. void
  1139. _litest_assert_gesture_event(struct libinput *li,
  1140. enum libinput_event_type type,
  1141. int nfingers,
  1142. const char *func,
  1143. int line);
  1144. struct libevdev_uinput *
  1145. litest_create_uinput_device(const char *name, struct input_id *id, ...);
  1146. struct libevdev_uinput *
  1147. litest_create_uinput_abs_device(const char *name,
  1148. struct input_id *id,
  1149. const struct input_absinfo *abs,
  1150. ...);
  1151. void
  1152. _litest_timeout(struct libinput *li, const char *func, int lineno, int millis);
  1153. #define litest_timeout(li_, millis) \
  1154. _litest_timeout(li_, __func__, __LINE__, millis)
  1155. #define litest_timeout_tap(li_) litest_timeout(li_, 300)
  1156. #define litest_timeout_tapndrag(li_) litest_timeout(li_, 520)
  1157. #define litest_timeout_debounce(li_) litest_timeout(li_, 30)
  1158. #define litest_timeout_softbuttons(li_) litest_timeout(li_, 300)
  1159. #define litest_timeout_buttonscroll(li_) litest_timeout(li_, 300)
  1160. #define litest_timeout_scroll_button_lock_grace(li_) litest_timeout(li_, 600)
  1161. #define litest_timeout_wheel_scroll(li_) litest_timeout(li_, 600)
  1162. #define litest_timeout_edgescroll(li_) litest_timeout(li_, 300)
  1163. #define litest_timeout_finger_switch(li_) litest_timeout(li_, 140)
  1164. #define litest_timeout_middlebutton(li_) litest_timeout(li_, 70)
  1165. #define litest_timeout_dwt_short(li_) litest_timeout(li_, 220)
  1166. #define litest_timeout_dwt_long(li_) litest_timeout(li_, 520)
  1167. #define litest_timeout_gesture(li_) litest_timeout(li_, 120)
  1168. #define litest_timeout_gesture_scroll(li_) litest_timeout(li_, 180)
  1169. #define litest_timeout_gesture_hold(li_) litest_timeout(li_, 300)
  1170. #define litest_timeout_gesture_quick_hold(li_) litest_timeout(li_, 60)
  1171. #define litest_timeout_trackpoint(li_) litest_timeout(li_, 320)
  1172. #define litest_timeout_tablet_proxout(li_) litest_timeout(li_, 170)
  1173. #define litest_timeout_touch_arbitration(li_) litest_timeout(li_, 100)
  1174. #define litest_timeout_hysteresis(li_) litest_timeout(li_, 90)
  1175. #define litest_timeout_3fg_drag_or_swipe(li_) litest_timeout(li_, 90)
  1176. #define litest_timeout_3fg_drag(li_) litest_timeout(li_, 800)
  1177. #define litest_timeout_eraser_button(li_) litest_timeout(li_, 50)
  1178. struct litest_logcapture {
  1179. char **errors;
  1180. char **infos;
  1181. char **debugs;
  1182. char **bugs;
  1183. };
  1184. void
  1185. litest_logcapture_destroy(struct litest_logcapture *c);
  1186. DEFINE_DESTROY_CLEANUP_FUNC(litest_logcapture);
  1187. struct litest_logcapture *
  1188. litest_logcapture_setup(struct libinput *li);
  1189. struct litest_logcapture *
  1190. litest_logcapture_remove(struct libinput *li, struct litest_logcapture *capture);
  1191. #define litest_with_logcapture(li_, capture_) \
  1192. for (struct litest_logcapture *capture_ = litest_logcapture_setup(li_); \
  1193. capture_ != NULL; \
  1194. capture_ = litest_logcapture_remove(li_, capture_))
  1195. void
  1196. _litest_assert_logcapture_no_errors(struct litest_logcapture *c,
  1197. const char *file,
  1198. const char *func,
  1199. int lineno);
  1200. #define litest_assert_logcapture_no_errors(c_) \
  1201. _litest_assert_logcapture_no_errors(c_, __FILE__, __func__, __LINE__)
  1202. #define litest_with_event_frame(dev_) \
  1203. for (bool _i = ({litest_push_event_frame(dev_); true; }); \
  1204. _i; \
  1205. ({ litest_pop_event_frame(dev_); _i = false; }))
  1206. void
  1207. litest_push_event_frame(struct litest_device *dev);
  1208. void
  1209. litest_pop_event_frame(struct litest_device *dev);
  1210. void
  1211. litest_filter_event(struct litest_device *dev, unsigned int type, unsigned int code);
  1212. void
  1213. litest_unfilter_event(struct litest_device *dev, unsigned int type, unsigned int code);
  1214. void
  1215. litest_semi_mt_touch_down(struct litest_device *d,
  1216. struct litest_semi_mt *semi_mt,
  1217. unsigned int slot,
  1218. double x,
  1219. double y);
  1220. void
  1221. litest_semi_mt_touch_move(struct litest_device *d,
  1222. struct litest_semi_mt *semi_mt,
  1223. unsigned int slot,
  1224. double x,
  1225. double y);
  1226. void
  1227. litest_semi_mt_touch_up(struct litest_device *d,
  1228. struct litest_semi_mt *semi_mt,
  1229. unsigned int slot);
  1230. static inline void
  1231. litest_enable_3fg_drag(struct libinput_device *device, unsigned int nfingers)
  1232. {
  1233. enum libinput_config_3fg_drag_state enabled;
  1234. switch (nfingers) {
  1235. case 3:
  1236. enabled = LIBINPUT_CONFIG_3FG_DRAG_ENABLED_3FG;
  1237. break;
  1238. case 4:
  1239. enabled = LIBINPUT_CONFIG_3FG_DRAG_ENABLED_4FG;
  1240. break;
  1241. default:
  1242. litest_abort_msg("Invalid finger count");
  1243. break;
  1244. }
  1245. enum libinput_config_status status =
  1246. libinput_device_config_3fg_drag_set_enabled(device, enabled);
  1247. litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
  1248. }
  1249. static inline void
  1250. litest_enable_tap(struct libinput_device *device)
  1251. {
  1252. enum libinput_config_status status, expected;
  1253. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1254. status = libinput_device_config_tap_set_enabled(device,
  1255. LIBINPUT_CONFIG_TAP_ENABLED);
  1256. litest_assert_int_eq(status, expected);
  1257. }
  1258. static inline void
  1259. litest_disable_tap(struct libinput_device *device)
  1260. {
  1261. enum libinput_config_status status, expected;
  1262. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1263. status = libinput_device_config_tap_set_enabled(device,
  1264. LIBINPUT_CONFIG_TAP_DISABLED);
  1265. litest_assert_int_eq(status, expected);
  1266. }
  1267. static inline void
  1268. litest_set_tap_map(struct libinput_device *device,
  1269. enum libinput_config_tap_button_map map)
  1270. {
  1271. enum libinput_config_status status, expected;
  1272. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1273. status = libinput_device_config_tap_set_button_map(device, map);
  1274. litest_assert_int_eq(status, expected);
  1275. }
  1276. static inline void
  1277. litest_enable_tap_drag(struct libinput_device *device)
  1278. {
  1279. enum libinput_config_status status, expected;
  1280. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1281. status = libinput_device_config_tap_set_drag_enabled(
  1282. device,
  1283. LIBINPUT_CONFIG_DRAG_ENABLED);
  1284. litest_assert_int_eq(status, expected);
  1285. }
  1286. static inline void
  1287. litest_disable_tap_drag(struct libinput_device *device)
  1288. {
  1289. enum libinput_config_status status, expected;
  1290. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1291. status = libinput_device_config_tap_set_drag_enabled(
  1292. device,
  1293. LIBINPUT_CONFIG_DRAG_DISABLED);
  1294. litest_assert_int_eq(status, expected);
  1295. }
  1296. static inline bool
  1297. litest_has_2fg_scroll(struct litest_device *dev)
  1298. {
  1299. struct libinput_device *device = dev->libinput_device;
  1300. return !!(libinput_device_config_scroll_get_methods(device) &
  1301. LIBINPUT_CONFIG_SCROLL_2FG);
  1302. }
  1303. static inline void
  1304. litest_enable_2fg_scroll(struct litest_device *dev)
  1305. {
  1306. enum libinput_config_status status, expected;
  1307. struct libinput_device *device = dev->libinput_device;
  1308. status = libinput_device_config_scroll_set_method(device,
  1309. LIBINPUT_CONFIG_SCROLL_2FG);
  1310. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1311. litest_assert_int_eq(status, expected);
  1312. libinput_device_config_scroll_set_natural_scroll_enabled(device, 0);
  1313. }
  1314. static inline void
  1315. litest_enable_edge_scroll(struct litest_device *dev)
  1316. {
  1317. enum libinput_config_status status, expected;
  1318. struct libinput_device *device = dev->libinput_device;
  1319. status = libinput_device_config_scroll_set_method(device,
  1320. LIBINPUT_CONFIG_SCROLL_EDGE);
  1321. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1322. litest_assert_int_eq(status, expected);
  1323. libinput_device_config_scroll_set_natural_scroll_enabled(device, 0);
  1324. }
  1325. static inline bool
  1326. litest_has_clickfinger(struct litest_device *dev)
  1327. {
  1328. struct libinput_device *device = dev->libinput_device;
  1329. uint32_t methods = libinput_device_config_click_get_methods(device);
  1330. return methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
  1331. }
  1332. static inline bool
  1333. litest_has_btnareas(struct litest_device *dev)
  1334. {
  1335. struct libinput_device *device = dev->libinput_device;
  1336. uint32_t methods = libinput_device_config_click_get_methods(device);
  1337. return methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
  1338. }
  1339. static inline void
  1340. litest_enable_clickfinger(struct litest_device *dev)
  1341. {
  1342. enum libinput_config_status status, expected;
  1343. struct libinput_device *device = dev->libinput_device;
  1344. status = libinput_device_config_click_set_method(
  1345. device,
  1346. LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
  1347. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1348. litest_assert_int_eq(status, expected);
  1349. }
  1350. static inline void
  1351. litest_set_clickfinger_map(struct litest_device *dev,
  1352. enum libinput_config_clickfinger_button_map map)
  1353. {
  1354. enum libinput_config_status status, expected;
  1355. struct libinput_device *device = dev->libinput_device;
  1356. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1357. status = libinput_device_config_click_set_clickfinger_button_map(device, map);
  1358. litest_assert_int_eq(status, expected);
  1359. }
  1360. static inline void
  1361. litest_enable_buttonareas(struct litest_device *dev)
  1362. {
  1363. enum libinput_config_status status, expected;
  1364. struct libinput_device *device = dev->libinput_device;
  1365. status = libinput_device_config_click_set_method(
  1366. device,
  1367. LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
  1368. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1369. litest_assert_int_eq(status, expected);
  1370. }
  1371. static inline void
  1372. litest_enable_drag_lock_sticky(struct libinput_device *device)
  1373. {
  1374. enum libinput_config_status status, expected;
  1375. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1376. status = libinput_device_config_tap_set_drag_lock_enabled(
  1377. device,
  1378. LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_STICKY);
  1379. litest_assert_int_eq(status, expected);
  1380. }
  1381. static inline void
  1382. litest_enable_drag_lock(struct libinput_device *device)
  1383. {
  1384. enum libinput_config_status status, expected;
  1385. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1386. status = libinput_device_config_tap_set_drag_lock_enabled(
  1387. device,
  1388. LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_TIMEOUT);
  1389. litest_assert_int_eq(status, expected);
  1390. }
  1391. static inline void
  1392. litest_disable_drag_lock(struct libinput_device *device)
  1393. {
  1394. enum libinput_config_status status, expected;
  1395. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1396. status = libinput_device_config_tap_set_drag_lock_enabled(
  1397. device,
  1398. LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
  1399. litest_assert_int_eq(status, expected);
  1400. }
  1401. static inline void
  1402. litest_enable_middleemu(struct litest_device *dev)
  1403. {
  1404. struct libinput_device *device = dev->libinput_device;
  1405. enum libinput_config_status status, expected;
  1406. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1407. status = libinput_device_config_middle_emulation_set_enabled(
  1408. device,
  1409. LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
  1410. litest_assert_int_eq(status, expected);
  1411. }
  1412. static inline void
  1413. litest_disable_middleemu(struct litest_device *dev)
  1414. {
  1415. struct libinput_device *device = dev->libinput_device;
  1416. enum libinput_config_status status, expected;
  1417. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1418. status = libinput_device_config_middle_emulation_set_enabled(
  1419. device,
  1420. LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
  1421. litest_assert_int_eq(status, expected);
  1422. }
  1423. static inline void
  1424. litest_sendevents_off(struct litest_device *dev)
  1425. {
  1426. struct libinput_device *device = dev->libinput_device;
  1427. enum libinput_config_status status, expected;
  1428. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1429. status = libinput_device_config_send_events_set_mode(
  1430. device,
  1431. LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
  1432. litest_assert_int_eq(status, expected);
  1433. }
  1434. static inline void
  1435. litest_sendevents_on(struct litest_device *dev)
  1436. {
  1437. struct libinput_device *device = dev->libinput_device;
  1438. enum libinput_config_status status, expected;
  1439. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1440. status = libinput_device_config_send_events_set_mode(
  1441. device,
  1442. LIBINPUT_CONFIG_SEND_EVENTS_ENABLED);
  1443. litest_assert_int_eq(status, expected);
  1444. }
  1445. static inline void
  1446. litest_sendevents_ext_mouse(struct litest_device *dev)
  1447. {
  1448. struct libinput_device *device = dev->libinput_device;
  1449. enum libinput_config_status status, expected;
  1450. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1451. status = libinput_device_config_send_events_set_mode(
  1452. device,
  1453. LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE);
  1454. litest_assert_int_eq(status, expected);
  1455. }
  1456. static inline void
  1457. litest_enable_hold_gestures(struct libinput_device *device)
  1458. {
  1459. enum libinput_config_status status, expected;
  1460. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1461. status = libinput_device_config_gesture_set_hold_enabled(
  1462. device,
  1463. LIBINPUT_CONFIG_HOLD_ENABLED);
  1464. litest_assert_int_eq(status, expected);
  1465. }
  1466. static inline void
  1467. litest_disable_hold_gestures(struct libinput_device *device)
  1468. {
  1469. enum libinput_config_status status, expected;
  1470. expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
  1471. status = libinput_device_config_gesture_set_hold_enabled(
  1472. device,
  1473. LIBINPUT_CONFIG_HOLD_DISABLED);
  1474. litest_assert_int_eq(status, expected);
  1475. }
  1476. static inline bool
  1477. litest_touchpad_is_external(struct litest_device *dev)
  1478. {
  1479. struct udev_device *udev_device;
  1480. const char *prop;
  1481. bool is_external;
  1482. if (libinput_device_get_id_vendor(dev->libinput_device) == VENDOR_ID_WACOM)
  1483. return true;
  1484. udev_device = libinput_device_get_udev_device(dev->libinput_device);
  1485. prop = udev_device_get_property_value(udev_device, "ID_INTEGRATION");
  1486. is_external = prop && streq(prop, "external");
  1487. udev_device_unref(udev_device);
  1488. return is_external;
  1489. }
  1490. static inline int
  1491. litest_send_file(int sock, int fd)
  1492. {
  1493. char buf[40960];
  1494. int n = read(fd, buf, 40960);
  1495. litest_assert_int_gt(n, 0);
  1496. return write(sock, buf, n);
  1497. }
  1498. static inline int
  1499. litest_slot_count(struct litest_device *dev)
  1500. {
  1501. if (dev->which == LITEST_ALPS_3FG)
  1502. return 2;
  1503. return libevdev_get_num_slots(dev->evdev);
  1504. }
  1505. static inline bool
  1506. litest_has_palm_detect_size(struct litest_device *dev)
  1507. {
  1508. double width, height;
  1509. unsigned int vendor;
  1510. unsigned int bustype;
  1511. int rc;
  1512. vendor = libinput_device_get_id_vendor(dev->libinput_device);
  1513. bustype = libevdev_get_id_bustype(dev->evdev);
  1514. if (vendor == VENDOR_ID_WACOM)
  1515. return 0;
  1516. if (bustype == BUS_BLUETOOTH)
  1517. return 0;
  1518. if (vendor == VENDOR_ID_APPLE)
  1519. return 0;
  1520. rc = libinput_device_get_size(dev->libinput_device, &width, &height);
  1521. return rc == 0 && width >= 70;
  1522. }
  1523. #endif /* LITEST_H */