1
0
forked from drath/libratbag

32 Commits

Author SHA1 Message Date
Yaroslav Chvanov
d259da5d42 test: check that active profile can't be disabled
This is failing right now.
2023-03-09 18:33:02 +03:00
Yaroslav Chvanov
890d8313fd test: check that disabled profile can't made active
This is failing right now.
2023-03-09 18:31:38 +03:00
Yaroslav Chvanov
87f1409b7a test: remove usage of the deprecated LED type field 2023-02-25 14:02:37 +03:00
Peter Hutterer
bf127d4c68 Move the ReportRate into the profile
We don't have mice that can do report rates per resolutions, so let's not
commit to that.

This is a DBus API break but also a break in ratbagd, piper will need to
update to fetch the rate/rates from the profile object now.

It's a ratbagctl break as well, ratbagctl info changes slightly and the
resolution is not argument anymore for the rate.

Fixes #645

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-27 11:31:59 +10:00
Jente Hidskes
9b3c33a2fe Convert LED effect rate in Hz to effect duration in ms
As discussed in https://github.com/libratbag/piper/issues/175
2017-11-15 08:53:56 +01:00
Peter Hutterer
bacdab2596 Sanity-check the list of dpi values and report rates
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-17 10:55:14 +02:00
Peter Hutterer
f592cabcd7 Replace the resolutions min/max with an explicit list of dpi values
Previously, we could get a min/max value but there was no guarantee that it
any value in between would actually work on the device. Some devices have a
discrete number of resolutions (e.g. 500, 1000, 2000, 2500), most others have
at least a minimum step size (so 1234 isn't a valid dpi value).

Change the min/max to a discrete list of which resolutions are supported. This
allows a UI to adjust its interface dynamically - e.g. a combobox if there are
only 3 resolutions or a slider if there are a million of them.

This is a DBus API break

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-13 17:46:05 +02:00
Peter Hutterer
b140bc2827 test: add dpi min/max tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-13 17:46:05 +02:00
Peter Hutterer
186d626c40 Remove RATBAG_LED_TYPE_UNKNOWN from the enum list
A driver is supposed to know what type an LED is, unknown doesn't help anyone
here. So replace this with a private #define and abort when a driver doesn't
set the type. This also adds a requirement that any driver initializing a LED
must have the read_led() function, otherwise we can't fill it in correctly.

And bump the enum up by one, the first valid value should start at 1 (or some
other non-boolean value).

Related #365
Fixes #364

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-09 19:12:17 +02:00
Peter Hutterer
dfc433cb74 test: fix LED indexing
Leftover from when we used the LED type as indices, that hasn't been true for
a while.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-09 19:12:17 +02:00
Peter Hutterer
d26d5b83f1 test: set RATBAG_TEST in code, not in meson
It's a fixed value so it's much easier to set this in the test binaries rather
than requiring the user to set this in the env before running a test manually.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-04 18:53:25 +10:00
Peter Hutterer
5f98d8d029 ratbagd: rename test's button type to action_type
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-25 18:24:10 +02:00
Peter Hutterer
f6e5dd6c2c test: disable core dumps in the test suite
No need for this to end up in the journal

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-24 10:32:41 +02:00
Peter Hutterer
37c8dec45c Fix the various scan-build warnings for dead assignments
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-11 10:50:22 +02:00
Ilya Guterman
0c0a6d39cb Add the ability to set LED effects 2017-02-22 10:10:03 +10:00
Ilya Guterman
3f83d5057d libratbag api support LEDs 2017-02-10 09:48:32 +10:00
Benjamin Tissoires
717505daef Test: add a set_button test
Which currently fails.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-03-14 16:20:56 +01:00
Benjamin Tissoires
8ede0b734f Test: make sure the macros ref/unref are tested
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-03-14 16:20:53 +01:00
Benjamin Tissoires
090851fce1 Test: add some generic tests for the buttons
Currently only ref/unref

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-03-14 16:20:50 +01:00
Peter Hutterer
e1c3449d03 Merge branch 'WIP/remove_default_profile' of https://github.com/bentiss/libratbag 2016-02-11 11:01:22 +10:00
Benjamin Tissoires
ff2d9713f7 Remove the default profile capability
We do not have any driver using it, and we are not sure this will even
be required. Before releasing a version with this, remove it. We
can always re-add this later if the need appears.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-02-10 15:22:25 +01:00
Benjamin Tissoires
80fd187c3c Dynamically allocate the resolutions
We were limited to MAX_RESOLUTIONS (10). Also, this allows to know
during ratbag_device_init_profiles() if the device supports
switchable resolutions.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2016-02-10 14:39:38 +01:00
Benjamin Tissoires
0fccfc2338 test: check for the active resolution in the device
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2016-02-09 15:15:46 +01:00
Peter Hutterer
a36f83606c Always return NULL from the _unref() calls
There's no good reason to return the object from the unref() call other than
for testing purposes, and we can work around this by using valgrind instead.
The API is a lot more consistent when we always return NULL.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-10-13 08:19:30 +10:00
Peter Hutterer
a3aacd3a99 Drop the _by_index suffix
This is the default, if we need a _by_name or so later we can add it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-16 00:55:12 +10:00
Peter Hutterer
9c53dcc717 test: reduce the ref/unref test runs to 256
Nothing special about 1000, 256 checks the 2-byte boundary and beyond that
we're just testing whether the computer can count. Let's assume it can.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-07 10:44:25 +10:00
Peter Hutterer
fb709c876a test: add more refcounting test cases
And change some to drop all parent refs before we even test the struct we want
to test. This way we're more likely to blow up during the test too.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-07 10:44:25 +10:00
Benjamin Tissoires
4f57efb98f test: add a test where we unref everything but the button
Similar to device_freed_before_profile but one layer after.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-07 10:44:25 +10:00
Benjamin Tissoires
5aa1c0b65d test: Add a test to use profile after unref-ing the device
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-07 10:44:18 +10:00
Peter Hutterer
dc24ae3aaa Fix the ref/unref dependency
The current code has the profile ref the device, but the device has no back-ref to
the profile. The following code will free the profile from underneath the
client, despite the caller still having a valid ref:

p = ratbag_device_get_profile_by_index(device, 0);
ratbag_profile_ref(p);
ratbag_device_unref(device);

Fix this by not using refs internally. After probe, the device is static
anyway, so the various refs internally aren't needed. Instead, we also ref/unref
the parent struct whenever we ref/unref a struct. Thus, whenevever the device
refcount reaches zero, we know the caller has no ref active.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-07 10:16:19 +10:00
Benjamin Tissoires
7b2a43f17c testdrv: make sure .remove() is called only once
And be sure to not call it twice if the sanity check fails.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2015-09-04 11:59:04 -04:00
Peter Hutterer
28a94d0974 Add a test suite
Two components are added here: a test driver that takes a struct
ratbag_test_device and sets that device up as a ratbag device.
That device is returned to the tests and then checked for sanity.

The ratbag_device_new_test_device() requires the environment variable
RATBAG_TEST set, otherwise we abort. It's also 'hidden' in a separate source
file, so it won't show up in doxygen. And if the test are disabled, this
function does nothing and the test driver never gets registered.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-09-03 16:28:43 -04:00