forked from drath/libratbag
Test: add a set_button test
Which currently fails. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
@@ -122,6 +122,15 @@ test_read_button(struct ratbag_button *button)
|
||||
ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_MACRO);
|
||||
}
|
||||
|
||||
static int
|
||||
test_write_button(struct ratbag_button *button,
|
||||
const struct ratbag_button_action *action)
|
||||
{
|
||||
/* check if the device is still valid */
|
||||
assert(ratbag_get_drv_data(button->profile->device) != NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test_fake_probe(struct ratbag_device *device)
|
||||
{
|
||||
@@ -166,6 +175,6 @@ struct ratbag_driver test_driver = {
|
||||
.write_profile = test_write_profile,
|
||||
.set_active_profile = test_set_active_profile,
|
||||
.read_button = test_read_button,
|
||||
.write_button = NULL,
|
||||
.write_button = test_write_button,
|
||||
.write_resolution_dpi = NULL,
|
||||
};
|
||||
|
||||
@@ -727,6 +727,30 @@ START_TEST(device_buttons_ref_unref)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(device_buttons_set)
|
||||
{
|
||||
struct ratbag *r;
|
||||
struct ratbag_device *d;
|
||||
struct ratbag_profile *p;
|
||||
struct ratbag_button *b;
|
||||
|
||||
struct ratbag_test_device td = sane_device;
|
||||
td.num_buttons = 10;
|
||||
|
||||
r = ratbag_create_context(&abort_iface, NULL);
|
||||
d = ratbag_device_new_test_device(r, &td);
|
||||
p = ratbag_device_get_profile(d, 1);
|
||||
b = ratbag_profile_get_button(p, 0);
|
||||
|
||||
ratbag_button_set_button(b, 3);
|
||||
|
||||
ratbag_button_unref(b);
|
||||
ratbag_profile_unref(p);
|
||||
ratbag_device_unref(d);
|
||||
ratbag_unref(r);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static Suite *
|
||||
test_context_suite(void)
|
||||
{
|
||||
@@ -762,6 +786,7 @@ test_context_suite(void)
|
||||
tc = tcase_create("buttons");
|
||||
tcase_add_test(tc, device_buttons);
|
||||
tcase_add_test(tc, device_buttons_ref_unref);
|
||||
tcase_add_test(tc, device_buttons_set);
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
return s;
|
||||
|
||||
Reference in New Issue
Block a user